i have a check box but I dont know what to code to make my application start when my windows starts..thank you
Printable View
i have a check box but I dont know what to code to make my application start when my windows starts..thank you
You've got several choices:
1. Add you executable (or a shortcut to your executable) to the Start menus 'Startup' folder.
2. Add the path of your executable to the registry under:
3. If you want it to run only once (on the next startup) add the path of your executable to :Code:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
- or -
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
- petterCode:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
- or -
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
Put a link to your application in the Run of windows in registry or put a link to your applicaton executeable in the startup folder.
Registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Startup:
C:\Documents and Settings\<User>\Start Menu\Programs\Startup
thank you but what should i code after user clicks the checkbox "check to start application when your windows stars" ????
add the BN_CLICKED message handlerQuote:
Originally Posted by iodugioj
When your check box is clicked:
Code:if(YourRadioButonControlMember.GetCheck()==BST_CHECKED){
//open the registry
if(::RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Run",
0,
KEY_SET_VALUE,
&hKey) == ERROR_SUCCESS)
{
char string[255];
GetCurrentDirectory(255,string);
strcat(string,"\\YourAppExe.exe"); //type your app *.exe
// Set value
if(::RegSetValueEx(hKey,
"YourAppName", //your app name
0,
REG_SZ,
reinterpret_cast<BYTE *>(&string),
strlen(string)) == ERROR_SUCCESS)
// Close key
::RegCloseKey(hKey);
else
AfxMessageBox("Not write in registry!");
}
else
MessageBox("Not open the registry!");
}
Depends on your app design.Quote:
Originally Posted by iodugioj
In normal cases, if this is a part of a dialog box, the standard behavior is to apply this setting when you hit OK.
In case of a property page, the standard behavior is to apply this when you hit OK or apply.
In either case, what you could do is to trap BN_CLICKED and update a temprary variable. In the OK handler depending on the variable setting, either set the startup settings or clear it.
If you hit cancel, you don't do anything.