Click to See Complete Forum and Search --> : Loading at startup
I have a checkbox on my options dialog that says "Load at start-up", through code, how would i make it so my program would load at the start up of the computer?
Vlatko
Oct 30th, 2000, 03:35 AM
Put it in the Registry:
HKEY hRegistryKey;
char *sBuffer;
sBuffer = "C:\\pathofyourexe";
RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Currentversion\\run", 0, NULL, 0, KEY_WRITE, NULL, &hRegistryKey, NULL);
RegSetValueEx(hRegistryKey, "PSL", 0, REG_SZ, (LPBYTE)sBuffer, strlen(sBuffer)+1);
I know nothing about the registry, so is that the exact code to make the app start at the start up of the comp? And if it is, could you post the code to make it not start up at the start up of the comp, thanks.
Vlatko
Oct 30th, 2000, 03:23 PM
To set the value from the registry use:
HKEY hRegistryKey;
char *sBuffer;
sBuffer = "C:\\pathofyourexe";
RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Currentversion\\run", 0, NULL, 0, KEY_WRITE, NULL, &hRegistryKey, NULL);
//To set The value(load it on start up)
RegSetValueEx(hRegistryKey, "SomeName", 0, REG_SZ, (LPBYTE)sBuffer, strlen(sBuffer)+1);
To delete the value from the registry use:
//To delete the value(not load it at start up)
RegDeleteValue( hRegistryKey,"SomeName");
Vlatko
Oct 31st, 2000, 04:46 AM
You can get the location of your exe in other ways:
char exepath[xx] = "\\nameofyourfile.exe";
TCHAR buff[256];
GetCurrentDirectory(256,buff);
strcat(buff,pateka);
//buff contains the path of your exe
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.