Hey fellows, How can i do the following ? I made a little program (good huh?), if you run that program "normally" by double clicking it shows a dialog box, but what i want now is add to my program that you put it in the autostart or win.ini or registry, anyways so that it start when windows starts, but at that point it is supposed to perform different operations than by double clicking it, like not showing a window, just changing a button (the start button) You guys have an idea about that ? Regards Typhoon
Posted on 2001-04-10 22:38:00 by Typhoon
write to the registry its really easy!!

.data
subkeyname        db "Software\Microsoft\Windows\CurrentVersion\Run",0
stringvalue       db "NameOfApp",0
path              dd "C:/RestOfPathHere",0
.code
LOCAL Disp:DWORD
LOCAL pKey:DWORD
;im guna be lazy here, it wont work for Win2k but what r u going to do right???
invoke RegCreateKeyEx,HKEY_CURRENT_USER,addr subkeyname,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,addr pKey,addr Disp
invoke RegSetValueEx,pKey,addr stringvalue,NULL,REG_SZ, addr path,sizeof path
invoke RegCloseKey,pKey
and a restart should do her I think, correct me if im wrong. Hope it helps -brad
Posted on 2001-04-10 23:22:00 by Rage9
Thanks Brad, you were right and it works fine for me, but i can't get the new value i set, deleted after i closed and started my program again, i tried to use RegDeleteValue but i don't know the value of the handle for the key where i set my program could you give me an example how that works ? Regards typhoon This message was edited by Typhoon, on 4/11/2001 9:46:48 PM This message was edited by Typhoon, on 4/11/2001 10:02:36 PM
Posted on 2001-04-11 21:41:00 by Typhoon
ok, say where to delete the value of the key we wrote to start the prog:

.data
subkeyname        db "Software\Microsoft\Windows\CurrentVersion\Run",0
stringvalue       db "NameOfApp",0

.code
LOCAL Disp:DWORD
LOCAL pKey:DWORD
invoke RegCreateKeyEx,HKEY_CURRENT_USER,addr subkeyname,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,addr pKey,addr Disp
invoke RegDeleteValue,pKey,addr stringvalue
invoke RegCloseKey,pKey
bam gone! now the program wont load at startup anymore. what if you want to delete the whole key? Note, best not to run this exact code on your system or your screwed. FOR YOUR EDUCATION ONLY!!!! :) More Notes: Windows 95: The RegDeleteKey function deletes a key and all its descendents. Windows NT: The RegDeleteKey function deletes the specified key. This function cannot delete a key that has subkeys.

.data
subkeyname        db "Software\Microsoft\Windows\CurrentVersion\Run",0


.code
LOCAL Disp:DWORD
LOCAL pKey:DWORD
invoke RegCreateKeyEx,HKEY_CURRENT_USER,addr subkeyname,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,addr pKey,addr Disp
invoke RegDeleteKey,pKey,addr subkeyname
invoke RegCloseKey,pKey
Hopfuly this helps, any questions refer to your api, and if you cant figure it out dont be afraid to post or drop me a line. -brad
Posted on 2001-04-12 00:58:00 by Rage9
Thanks i got a way figured out, but got stuck with a new problem, may be have a look at the last thread i posted Many Thanks Typhoon The last thread was about deleting a registry value after program restart
Posted on 2001-04-12 01:13:00 by Typhoon
Typhoon, if you want your program to behave differently on windows startup, just add a custom command line parameter to the autorun entry in the registry and check for it when your program starts.
Posted on 2001-04-12 08:50:00 by Tola
Well I see 2 options here: 1)if you want you can write your path to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce this will make your program load once and then windows will delete the key for u. 2)just right a value like '1' or somthing to some key in registry, then each time your program loads just have it check for that value, if the value matches do this, or this, or this... -brad
Posted on 2001-04-12 10:06:00 by Rage9