PDA

View Full Version : Hostname



ibwhoib
04-08-2002, 03:22 PM
Does anyone know how to retrieve the Hostname (Network ID) of the computer you are installing to?

thanks,
ib

gbaroni
04-09-2002, 05:27 AM
If you mean Computer Name, try use this code:

...
STRING svPCName;
NUMBER nvSize;
begin
...
#define NET_REG_PC_NAME "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName"

#define NET_KEY_PC_NAME "ComputerName"

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

RegDBGetKeyValueEx(NET_REG_PC_NAME, NET_KEY_PC_NAME, nvType, svPCName, nvSize)
end;


In "svPCName" you can retrieve the name of computer.
I hope this help you.

ibwhoib
04-09-2002, 08:16 AM
I had the same idea of using the registry at first, but I found another way using the Kernel32.dll.

prototype BOOL Kernel32.GetComputerName(BYREF string, BYREF number);

string szComputerName[100];
number nBufferSize;

GetComputerName(szComputerName,nBufferSize);

This worked for me.

Thanks for your help.

RobertDickau
04-09-2002, 12:54 PM
For that matter, there's a built-in MSI property called ComputerName (which internally uses GetComputerName to get its value), whose value you can get with MsiGetProperty.