The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: skywalker on July 10, 2006, 01:50:30 AM

Title: Autostart a program
Post by: skywalker on July 10, 2006, 01:50:30 AM
This isn't working correctly, all it does is start explorer.
It writes it OK to the registry.

.data

run_subkey      db "SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0
run_name        db "netscp.exe",0
run_path        db "C:\Program Files\Netscape\Netscape",0

.data?
tmp dd ?


.code

start:

     invoke  RegCreateKeyEx, HKEY_CURRENT_USER, ADDR run_subkey, 0, 0, 0, KEY_WRITE, 0, ADDR tmp, 0
        cmp     eax, ERROR_SUCCESS
        jne     @f
        invoke  RegSetValueEx, [tmp], ADDR run_name, 0, REG_SZ, ADDR run_path, sizeof run_path
        invoke  RegCloseKey, [tmp]
@@:
       
    invoke ExitProcess,0
Title: Re: Autostart a program
Post by: arafel on July 10, 2006, 11:26:54 AM
run_name        db "this can be enything",0
run_path        db "C:\Program Files\Netscape\Netscape\netscp.exe",0
Title: Re: Autostart a program
Post by: P1 on July 10, 2006, 06:17:48 PM
Working Code:
invoke RegSetValueEx, hKey1, addr szKname, 0, REG_SZ, addr szW6, cbData
invoke RegCloseKey, hKey1
Why are you using the key handle as an indirect reference?

Regards,  P1  :8)
Title: Re: Autostart a program
Post by: Casper on July 10, 2006, 07:47:31 PM
Actually

run_name        db "Netscape", 0
run_path        db "C:\Program Files\Netscape\netscp.exe", 0


I think Arafel accidently had one too many directory entries, he was following your lead, though.  :naughty:

I do not have Netscape installed on my computer but I am attaching a project that correctly writes and AutoStarts K-Meleon for me.  K-Meleon is not the default browser so I am positive it is working correctly.  I am using both Arafel's and P1's corrections, both are accurate.

Paul


[attachment deleted by admin]
Title: Re: Autostart a program
Post by: skywalker on July 11, 2006, 01:34:24 AM
Trying to delete the netscape entry, I can delete the whole Run key, but only want to delete
the netscape entry.

.data

szKeyName       BYTE    "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\netscape",0
 

.code

start:

invoke RegDeleteKey,HKEY_CURRENT_USER,ADDR szKeyName
invoke ExitProcess,NULL
Title: Re: Autostart a program
Post by: skywalker on July 15, 2006, 02:20:59 AM
That wasn't too bad to figure out. 

.data?

    tmp dd ?

    .data

sub_key         db "SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0 ; address of null terminated subkey
key_value       db "netscape",0                                      ; address of value to be deleted

    .code

start:


invoke SHDeleteValue, HKEY_CURRENT_USER, ADDR sub_key, ADDR key_value