Hello !..
in Windows.hlp
BOOL SetComputerName(
LPCTSTR lpComputerName // address of new computer name
);
and it's my code
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
.data
AppName db "Rename",0
compName db "Toshiba",0
err db "Failed",0
ok db "Succeed",0
.code
start:
invoke SetComputerName,addr compName
.if eax!=0
invoke MessageBox,NULL,addr ok,addr AppName,MB_OK
jmp Exit
.endif
invoke MessageBox,NULL,addr err,addr AppName,MB_OK
Exit:
invoke ExitProcess,NULL
end start
Something wrong with this code or it just dsnt work on Windows 7
Thanks
Force
If the function is failing try calling the GetLastError function (http://msdn.microsoft.com/en-us/library/windows/desktop/ms679360(v=vs.85).aspx) to get the last error code value. You can then either look up the error code value in the System Error Codes (http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx), or use the MASM32 LastError$ macro to display the system-defined string for the error code.
SetComputerName
See first line of docs here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724930(v=vs.85).aspx
for reason it is not working.
Fist line of doc is
QuoteSets a new NetBIOS name for the local computer. The name is stored in the registry and the name change takes effect the next time the user restarts the computer.
Instead, look at the remarks section:
QuoteRemarks
Applications using this function must have administrator rights.
Windows 7
IS NOT Windows 2K, or XP, it is a totally different beast. Many things can only be done with Admin rights.
I just tried it on another computer with XP
SUCCEED
yeah after restarting i saw new name
that means it doesnt work on Win 7 or my computer is getting crazy i dont know :))