05-29-2020 02:02 AM
Is there any function in user32. DLL that you can get?
Can you teach me how to use it?Or use another dell file
05-29-2020 04:27 AM - edited 05-29-2020 04:46 AM
Which host name? TCP/IP host name? Windows network name?
TCP/IP host name is very easy. Just use a String to IP node with the input empty and then feed it into IP to String and you receive the current TCP/IP host name for your machine. One complication is that the default IP address may not be what is your internet facing address so it may not have a DNS name. If you enable Multiple IP in the right click menu for the String to IP node you get back an array of IP addresses, one for each network adapter (that includes virtual network adapters) in your system and you can query their name until you get one that is not a dot format address.
Windows host name is more complicated as there are various variants. The most common name (and least meaningful) can be retrieved with the GetComputerName() Windows API as described here. It's in kernel32.dll and there are many VIs around that already call this function.
05-29-2020 11:12 AM
Why does it show an attempt to access an invalid address
05-29-2020 11:14 AM
05-29-2020 11:23 AM
Both of the previously linked threads are from the early 2000's. I think access to the core windows DLLs isn't as available any more.
You could try .NET instead. I find Dns.GetHostName works fine.
05-29-2020 11:59 AM - edited 05-29-2020 12:04 PM
@Kyle97330 wrote:
Both of the previously linked threads are from the early 2000's. I think access to the core windows DLLs isn't as available any more.
You could try .NET instead. I find Dns.GetHostName works fine.
The Win32 API is still fully functional and accessible unless you run on a Windows IoT (non Enterprise) platform.
Both VIs work fine on my computer using Windows 10 and LabVIEW 2018.
The problem is likely that the library path got somehow messed up. There should be ONLY kernel32.dll and nothing else in the library path box. Also I have no idea why the name of the variable got localized. They were standard ASCII characters and should not be renamed no matter what locale your computer is using.
Ohhh you didn't download the VIs in the links I provided but created your own. A LabVIEW string handle is NOT compatible with a LPSTR pointer. Download the VI in the second link and use that instead of trying to do your own experiments when not understanding the C datatypes.