Advanced PowerBuilder

HomePrevious Lesson: Finding the Computer Name
Next Lesson: Reading the Value of an Environment Variable

Setting the Computer Name

Declare a local external function as shown below.
FUNCTION boolean ufx_SetComputerName(ref string &
         cname) LIBRARY "kernel32.dll" ALIAS &
         FOR "SetComputerNameA"

The following code sets your computer name to the specified one and will come into effect after you reboot your machine.
// Object: cb_set_computer_name
// Event: Clicked
String ls_ComputerName
ls_ComputerName = sle_ComputerName.Text
if ufx_SetComputerName( ls_ComputerName ) then
   MessageBox("SetComputerName", "Successfull! " + &
	    "You'll need to reboot for it to take effect")
else
   MessageBox("SetComputerName", "Failed")
end if
HomePrevious Lesson: Finding the Computer Name
Next Lesson: Reading the Value of an Environment Variable