News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Rename Computer Name

Started by Force, February 12, 2012, 11:58:57 PM

Previous topic - Next topic

Force

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
Never Stop Until You Are Better Than The Best

MichaelW

If the function is failing try calling the GetLastError function to get the last error code value. You can then either look up the error code value in the System Error Codes, or use the MASM32 LastError$ macro to display the system-defined string for the error code.
eschew obfuscation

RotateRight


Gunner

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.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Force

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 :))
Never Stop Until You Are Better Than The Best