|
-
June 9th, 1999, 02:26 AM
#1
Using registry...
Hi..
Here's a new question for you programmers..
I'm writing an application which should start up with Windows, but without having a 'myapp.lnk' in the start up menu..So, to do this, I thought I should use the registry, but the problem is that I never used registry before...So, imagine I have the full path of my app in
CString myPath = "c:\mypath\myapp.exe";
..then, how can I add it into registry so that the app start up automatically with Windows..I think that I should write it into
HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run
in the registry, is this right ?..
If so, how can I write myPath into it if it doesn't already exists ?..hey, also I would like to know how I can remove it ?
Could you send me some sample code..?
Thanks a lot.. 
-Cedric-
-
June 10th, 1999, 12:28 AM
#2
Re: Using registry...
Hi,
You have to use the follwing piece of code. The RegOpenKeyEx creates the key for you. Use RegSetValueEx to set the path of the exe you want to write.
char filepath[] = "c:\mypath\myapp.exe";
HKEY hKey;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run\\",0,KEY_ALL_ACCESS,&hKey);
LONG i = RegSetValueEx( hKey,"YourApp",0,REG_SZ,(BYTE*) filepath,sizeof(filepath)+1);
RegCloseKey(hKey);
Regards,
M. Jose Wilson,
Software Engineer,
Aditi Technologies Pvt Ltd,
Bangalore,
India.
-
June 10th, 1999, 05:28 AM
#3
Re: Using registry...
thanks a lot...I'll try this code.. 
-Cedric-
-
June 10th, 1999, 06:28 AM
#4
Re: Using registry...
Sorry, RegOpenKeyEx() does NOT create the key if it does not already exist. The required function is RegCreateKeyEx(), which will create it if it does not exist or just open it if it does exist.
-
June 10th, 1999, 06:29 AM
#5
Re: Using registry...
RegOpenKeyEx() does NOT create the key if it does not already exist. The required function is RegCreateKeyEx(), which will create it if it does not exist or just open it if it does exist.
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
|