PDA

View Full Version : Set Computer Name


sphair
11-01-2004, 06:59 AM
I need to set the computer name during installation. Does anyone know if I can do this through registry or something? Any tips welcome.

gspillane
11-01-2004, 05:49 PM
Hi Sphair,

I don't know if it's as simple as a registry entry but I suspect not because I found an API called SetComputerName. I haven't tried it but I expect it's what you want. If this is the case, unless Friedrich adds it as a function you would have to write it into a short DLL and call the function. Let me know if you need any help, the API looks pretty easy and Friedrich's DLL's are a dream.

Best Regards,
Geoff Spillane
Data Down Under

linder
11-02-2004, 06:54 AM
You can do the following:

1) Set Variable %NEWCOMPUTERNAME% to YourNewComputerName
2) Use "Call DLL Function" with the following parameters:

Library: kernel32.dll
Function: SetComputerNameA
Calling Convention: __stdcall
Parameter Types: *string
Function Parameters: %NEWCOMPUTERNAME%

If the function succeeds, the %_SB_RETURN% value is a nonzero value.

Applications using this function must have administrator rights. You have to reboot the machine.

Does this help?

gspillane
11-02-2004, 04:35 PM
Hi Friedrich,

This is great. Does this mean that I can call most API functions direct from their Windows DLL without having to go through the hassle of prototyping, creating a lib, and a Clarion DLL etc?

Best Regards,
Geoff Spillane
Data Down Under

linder
11-03-2004, 12:13 AM
Hi Geoff,

Yes, that's correct ;-) You can directly call most Windows API functions from within the script. And of course, you can add your own DLLs (unlimited number) and call into your own functions.

Thanks,

sphair
11-03-2004, 06:25 AM
Calling into DLLs works like a charm yes. We use this alot in our installation script.

But maybe it would be an idea to implement (later, not now :) a function which reflects the Get System Information, which is called Set System Information, which lets you select from a dropdown common system configurations settings like Set Computer Name.

linder
11-03-2004, 08:19 AM
Thank you for your suggestion. Good idea. It's on the drawing board now :)