- Proper way of 'autostart'
- Posted by Ufit on February 27th, 2005
What is a correct way to make a program
start 'when windows starts' ?
How to set the registry and where?
I want to put it in menu and enable/disable this function.
Please help me how to do it with MSVC++.
I appreciate your help.
U)
- Posted by Vince Morgan on February 27th, 2005
Hi Ufit,
There are a couple of methods to do what you want.
One very easy one is to create a shortcut to your app in the
users 'Startup' folder.
The other is the registry 'Run' keys. There are a number of
'Run' keys, depending on how many user profiles you may have.
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Windows\CurrentVersion\Run" ,
should work regardless of the user at the time, but I am not
absolutely certain of that.
Either way, it's a 'Run' key for a user, users, or all.
I am not an expert on the registry Ufit, though I have edited
the contents of these 'Run' keys many many times over
the years without any problem whatsoever.
Hope this helps,
Regards,
Vince Morgan
- Posted by Sten Westerback on February 28th, 2005
"Ufit" <kot_tmp0SPAMSPAM@NOpoczta.fm> wrote in message
news:cvrijn$ekd$1@news.onet.pl...
Please define more exactly what you mean with "when windows starts".
Is that...
- first thing the system does when powered on ->> driver
- run before someone logs on -> CreateService() and related stuff
- run when ANY user logs on -> Run -key or shortcut/bat in All Users'
Startup folder
- run when A user logs on -> shortcut/bat in personal profiles Startup
folder
key of your own and do the opposite....
RegOpenKey() is a good start... or some of the Sh* functions (Shell).
- Sten
- Posted by Ufit on March 2nd, 2005
I reveal a complete workink snippet of my app)
view_startup=
!(CheckMenuItem(GetMenu()->m_hMenu,ID_VIEW_STARTUP,
view_startup?
MF_UNCHECKED|MF_BYCOMMAND:MF_CHECKED|MF_BYCOMMAND) & MF_CHECKED);
HKEY hKey;
CString name; int l; char rValue[]="my application";
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run ",
0,KEY_WRITE,&hKey);
l=GetModuleFileName(NULL,name.GetBufferSetLength(5 12),512);
name.Insert(0,'\"'); name.Insert(l+1,"\" -gototray");
if(view_startup)
RegSetValueEx(hKey,rValue,0,REG_SZ,
(BYTE*)name.GetBuffer(512),name.GetLength());
else
RegDeleteValue(hKey,rValue);
RegCloseKey(hKey);
thanks again
U)