Article View: borland.public.cppbuilder.nativeapi
Article #11122Re: How do i make my app start automaticaly with windows?
From: Tuga
Date: Sat, 28 Feb 2004 15:01
Date: Sat, 28 Feb 2004 15:01
45 lines
2463 bytes
2463 bytes
"Jos" <josnospambranders@fastmail.fm> escreveu na mensagem news:404094e7$1@newsgroups.borland.com... > "Tuga" <nmp@ispgaya.pt> wrote in message > news:404089b6@newsgroups.borland.com... > > Hi every1. > > The subject of my message says everything. > > I know that i can put my app in the registry > > How can i do it? > > Use the \Software\Microsoft\Windows\CurrentVersion\Run key in the registry. > You can choose whether to make it apply for every user, or only for the > current user. > For every user you will need administrator rights in NT/2000/XP/2003. > > ******************************************** > char progfilename[MAX_PATH]; > HKEY hKey; > > // get the name of your exe > GetModuleFileName(0,progfilename,MAX_PATH); > HKEY hRoot = HKEY_LOCAL_MACHINE; > // use HKEY_CURRENT_USER if it's only for the current user > if(RegOpenKeyEx(hRoot,"Software",0,KEY_ALL_ACCESS,&hKey) > !=ERROR_SUCCESS) return; > if(RegOpenKeyEx(hKey,"Microsoft",0,KEY_ALL_ACCESS,&hKey) > !=ERROR_SUCCESS) return; > if(RegOpenKeyEx(hKey,"Windows",0,KEY_ALL_ACCESS,&hKey) > !=ERROR_SUCCESS) return; > if(RegOpenKeyEx(hKey,"CurrentVersion",0,KEY_ALL_ACCESS,&hKey) > !=ERROR_SUCCESS) return; > if(RegOpenKeyEx(hKey,"Run",0,KEY_ALL_ACCESS,&hKey) > !=ERROR_SUCCESS) return; > RegSetValueEx(hKey,"NameOfMyProgram",0,REG_SZ, > (BYTE*)progfilename,MAX_PATH); > RegCloseKey(hKey); > ************************************************ > -- > > Jos Branders > > Thanks Jos.
Technical Details
Message-ID:
<4040ad2e@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<404089b6@newsgroups.borland.com> <404094e7$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,50d0bf19daf250a1 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-28 07:09:33 PST From: "Tuga" <nmp@ispgaya.pt> Newsgroups: borland.public.cppbuilder.nativeapi References: <404089b6@newsgroups.borland.com> <404094e7$1@newsgroups.borland.com> Subject: Re: How do i make my app start automaticaly with windows? Date: Sat, 28 Feb 2004 15:01:06 -0000 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 213.22.154.160 Message-ID: <4040ad2e@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1077980462 213.22.154.160 (28 Feb 2004 07:01:02 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail