thanx for reply
but this is my simple delphi application i want to write the code with my aplication code.
Main Topics
Browse All Topicshi expert
I have a desktop application just like gtalk or yahoo i needs to start it automatically on system startup
how can i do this.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Code for building the statup shortcut link automatically. It uses the applications title, filename, and icon to build the link.
HTH,
Russell
//////////////////////////
//
// Function : AddSelfStartup
//
// Parameters :
// AllUsers - Boolean value indicating if this should apply
// to all users, or only the current user
//
// Returns : HResult status of the IShellLink handling. On success S_OK
// will be returned.
//
// Notes : Routine expects the following units in the uses clause:
//
// Forms, ComObj, ActiveX, ShlObj
//
// Forms is required for access to the Application instance,
// and the latter are required for the COM functionality.
//
//////////////////////////
function AddSelfStartup(AllUsers: Boolean = False): HResult;
function CheckSetStatus(CheckStatus
begin
// Resource protection
try
// Set outbound status
SetStatus:=CheckStatus;
finally
// Determine if this was a success
result:=Succeeded(CheckSta
end;
end;
var
lpwszPath: Array [0..MAX_PATH] of WideChar;
lpszPath: Array [0..MAX_PATH] of Char;
pvFile: IPersistFile;
pvLink: IShellLink;
dwPath: DWORD;
const
STARTUP_PATH = '%s\Start Menu\Programs\Startup\';
begin
// Initialize the com library
if CheckSetStatus(CoInitializ
begin
// Resource protection
try
// Attempt to create instance of shell link
if CheckSetStatus(CoCreateIns
begin
// Resource protection
try
// Get the executable filename (null terminate result)
lpszPath[GetModuleFileName
// Update the link settings
if CheckSetStatus(pvLink.SetP
begin
// Set the description (don't care about status)
pvLink.SetDescription(PCha
// Query for IPersistFile
if CheckSetStatus(pvLink.Quer
begin
// Resource protection
try
// Determine if current user or all users
if AllUsers then
// Expand the path
dwPath:=ExpandEnvironmentS
else
// Expand the path
dwPath:=ExpandEnvironmentS
// Concat the application filename with the extension of .lnk
StrLCat(@lpszPath, PChar(ChangeFileExt(Extrac
// Convert to wide char
MultiByteToWideChar(CP_ACP
// Save to file
result:=pvFile.Save(@lpwsz
finally
// Release the interface
pvFile:=nil;
end;
end;
end;
finally
// Release the interface
pvLink:=nil;
end;
end;
finally
// Uninit the com library
CoUninitialize;
end;
end;
end;
----
// Example usage
AddSelfStartup(True);
It depends on the accessability level that the developer wishes to expose to the user. There is no right / wrong way, it just depends on the intent. If you wish to make it easy for your user to control (remove) a startup item, then placing it in the startup folder makes sense. If you wish to keep the novice user from modifying the startup of your program, then the registry makes sense.
Russell
// Example using registry
function AddRegSelfStartup(AllUsers
function CheckSetStatus(CheckStatus
begin
// Resource protection
try
// Set outbound status
SetStatus:=CheckStatus;
finally
// Determine if this was a success
result:=(CheckStatus = ERROR_SUCCESS);
end;
end;
var
hkBase: HKEY;
hkRun: HKEY;
dwDisp: DWORD;
begin
// Check key to open
if AllUsers then
// Use local machine key
hkBase:=HKEY_LOCAL_MACHINE
else
// Use current user key
hkBase:=HKEY_CURRENT_USER;
// Attempt to create / open the key
if CheckSetStatus(RegCreateKe
begin
// Resource protection
try
// Set the value (account for null as well)
result:=RegSetValueEx(hkRu
finally
// Close the key
RegCloseKey(hkRun);
end;
end;
end;
Programmatically Edit Registry to Run Your Delphi Application on Windows Startup
By programmatically editing the Windows Registry, using the TRegistry object, you can you can "automagically" start programs whenever Windows launches.
The procedure you can use to force "auto-run-on-Windows-start
procedure RunOnStartup(const sCmdLine: string; bRunOnce: boolean = false; Remove: Boolean = false) ;
var
sKey: string;
Section: string;
const
ApplicationTitle = Your Application TITLE;
begin
if (bRunOnce) then
sKey := 'Once'
else
sKey := '';
Section := 'Software\Microsoft\Window
with TRegIniFile.Create('') do
try
RootKey := HKEY_LOCAL_MACHINE;
if Remove then
DeleteKey(Section, ApplicationTitle)
else
WriteString(Section, ApplicationTitle, sCmdLine) ;
finally
Free;
end;
end;
On Vista, if the user running the application does not have admin rights the above code would fail, due to UAC!
Business Accounts
Answer for Membership
by: talkinsmakPosted on 2008-12-05 at 09:16:38ID: 23106605
Add it to the startup folder.
1. Locate the .exe of the application
2. Right click you start button, choose "Explore"
3. Navigate to "All users" if you want it to start for everyone or your "Username" if you only want it to start fo ryou.
4. Drill down to start menu, programs, startup
5. Right click the .exe you want to start up and choose copy and then paste it in the startup folder.
Hope that helps