-
September 6th, 2005, 05:28 PM
#1
Start when windows starts
i have a check box but I dont know what to code to make my application start when my windows starts..thank you
Come a little closer...
I'll be good to you...
-
September 6th, 2005, 05:41 PM
#2
Re: Start when windows starts
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:
Code:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
- or -
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
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\RunOnce
- or -
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
- petter
-
September 6th, 2005, 05:42 PM
#3
Re: Start when windows starts
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
þ|êâšë rä†è rëþ|ïëš †hª† hë|þëd
-
September 6th, 2005, 05:50 PM
#4
Re: Start when windows starts
thank you but what should i code after user clicks the checkbox "check to start application when your windows stars" ????
Come a little closer...
I'll be good to you...
-
September 6th, 2005, 06:05 PM
#5
Re: Start when windows starts
Originally Posted by iodugioj
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 handler
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!");
}
Last edited by g_gili; September 6th, 2005 at 06:10 PM.
Please use code tags [code] [/code]
We would change the world, but God won't give us the sourcecode..
Undocumented futures are fun and useful....
_________
Gili
-
September 6th, 2005, 07:37 PM
#6
Re: Start when windows starts
Originally Posted by iodugioj
thank you but what should i code after user clicks the checkbox "check to start application when your windows stars" ????
Depends on your app design.
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|