How can SilkTest return the current HostName within Windows XP?
Within Windows XP, a user may set a machine HostName, this is useful in connecting to remote machines etc.
In order to aid the automation of remote tests, it may be necessary to be able to determine what the current host name of the local machine is at runtime. This can be achieved by querying a specific registry entry within the Windows registry.
The following script queries this entry and then determines the machine"s HostName.
The result is then printed to the results file.
[ ] //Borland Code [ ] use "msw32.inc" [ ] [-] testcase HostName() appstate none [ ] //Get regvalue for reg entry: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters [ ] [ ] //RegKey value for Host name [ ] //NV Hostname is the current domain returned for this computer. [ ] [ ] INTEGER iKey = HKEY_LOCAL_MACHINE // defined in msw32.inc [ ] STRING sPath = "SYSTEM\ControlSet001\Services\Tcpip\Parameters\" [ ] String sItem = "NV Hostname" [ ] String sCurrentTheme = "" [ ] [ ] [ ] String sRegValue = SYS_GetRegistryValue (iKey, sPath, sItem) [ ] //Print (SYS_GetRegistryValue (iKey, sPath, sItem)) [ ] [ ] Print("The current Computer Host Name is: ",sRegValue) [ ] //End Borland Code