Article View: comp.lang.pascal.delphi.misc
Article #390Re: How to start a program when Windows Start ??
From: James M Sandbrook
Date: Sat, 22 May 1999 00:00
Date: Sat, 22 May 1999 00:00
88 lines
3618 bytes
3618 bytes
This is from the Borland.com Frequently Asked Questions
http://www.borland.com/devsupport/delphi/qanda/
===================
Question and Answer Database
FAQ1894D.txt Running apps on Windows startup
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How can I get my application to run every time Windows starts?
Answer:
The following demonstrates how to add your application to the
Windows boot sequence. Code is demonstrated for both the Win32 and
Win16 platforms.
uses
Registry, {For Win32}
IniFiles; {For Win16}
{$IFNDEF WIN32}
const MAX_PATH = 144;
{$ENDIF}
{For Win32}
procedure TForm1.Button1Click(Sender: TObject);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.LazyWrite := false;
reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',
false);
reg.WriteString('My App', Application.ExeName);
reg.CloseKey;
reg.free;
end;
{For Win16}
procedure TForm1.Button2Click(Sender: TObject);
var
WinIni : TIniFile;
WinIniFileName : array[0..MAX_PATH] of char;
s : string;
begin
GetWindowsDirectory(WinIniFileName, sizeof(WinIniFileName));
StrCat(WinIniFileName, '\win.ini');
WinIni := TIniFile.Create(WinIniFileName);
s := WinIni.ReadString('windows',
'run',
'');
if s = '' then
s := Application.ExeName else
s := s + ';' + Application.ExeName;
WinIni.WriteString('windows',
'run',
s);
WinIni.Free;
end;
===================
Hope this helps!
-- All the best from James Sandbrook.
****************************************************************
http://ssapcs.interspeed.net/index.html
Charlie Calvert talks about Delphi's future
HTML-New Zealand Web Site Links-Family-Delphi-Pascal-
School Projects-Computer Terms-Interviews with Dr Bob
and Marco CantοΏ½ - And our Delphi e-group.
****************************************************************
Eric wrote:
> Hello,
>
> Is it possible to automatic start a program when Windows 95/98 start ?
> I know if we put the program in the Registry/RUN, or put it in StartUp
> Folder it will automatic start when Windows start.
>
> But, if I don't want to put it in Registry/RUN or put it in Startup
> folder, can it also automatic startup when Windows95/98 start ???
>
> Best regards,
> Eric
Technical Details
Message-ID:
<37468221.E3B1D279@xtra.co.nz>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<374593A1.F906E181@yahoo.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: fd817,2cf87a2ba5181993 X-Google-Attributes: gidfd817,public X-Google-Thread: 1043cf,2cf87a2ba5181993 X-Google-Attributes: gid1043cf,public X-Google-Thread: 10baee,2cf87a2ba5181993 X-Google-Attributes: gid10baee,public From: James M Sandbrook <jms@xtra.co.nz> Subject: Re: How to start a program when Windows Start ?? Date: 1999/05/22 Message-ID: <37468221.E3B1D279@xtra.co.nz> X-Deja-AN: 481344857 Content-Transfer-Encoding: 8bit References: <374593A1.F906E181@yahoo.com> X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@xtra.co.nz X-Trace: titan.xtra.co.nz 927367939 2662970 210.55.161.124 (22 May 1999 10:12:19 GMT) Organization: ssapcs Ltd Mime-Version: 1.0 Reply-To: ssapcs@xtra.co.nz NNTP-Posting-Date: 22 May 1999 10:12:19 GMT Newsgroups: comp.lang.pascal.delphi.misc,alt.comp.lang.borland-delphi,borland.public.delphi.objectpascal