Article View: borland.public.cppbuilder.nativeapi
Article #11121Re: How do i make my app start automaticaly with windows?
From: Jos
Date: Sat, 28 Feb 2004 13:17
Date: Sat, 28 Feb 2004 13:17
37 lines
2240 bytes
2240 bytes
"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
Technical Details
Message-ID:
<404094e7$1@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>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 05:39:26 PST From: "Jos" <josnospambranders@fastmail.fm> Newsgroups: borland.public.cppbuilder.nativeapi References: <404089b6@newsgroups.borland.com> Subject: Re: How do i make my app start automaticaly with windows? Date: Sat, 28 Feb 2004 14:17:07 +0100 Lines: 39 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: 81.83.213.3 Message-ID: <404094e7$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1077974247 81.83.213.3 (28 Feb 2004 05:17:27 -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