Start program when Vista starts
- From: Brad Blanchard <nadie137@xxxxxxxxxxx>
- Date: Mon, 23 Jul 2007 10:27:56 +0200
Up until now, I've given the user the option to start programs with
Windows the CreateShellLink function found in LibWinShell. This works
fine up to XP but Vista gives me a 'Permission denied' message when it
tries to create the .lnk file.
Apparently one workaround is to create a separate program which uses
the CreateShellLink function and then call that program from the
original one using ShellExecuteEx() API and supply the "runas" verb as
one of its parameters.
A C++ programmer told me that none of this is necessary - that the
'start with Windows' setting can be controlled with a Registry entry
and he sent me the following function. I understand most of it, but
what is the Delphi equivalent of SHSetValue()?
If someone could tranlate this function to Delphi, it would be a real
help. Thanks.
void SetAutoRestartApp( bool bOnOrOff )
{
static TCHAR * pKey =
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
static TCHAR * pValue = _T("MyProg_1");
CString csX;
// Get the full path to the running executable
// e.g. C:\Program Files\MyProg\MyProg.exe
GlbGetApplicationFilename( csX );
// Insert double quotes before
// and after the full path
csX.Insert( 0, _T('"') );
csX += _T('"');
if ( bOnOrOff ) {
SHSetValue( HKEY_CURRENT_USER, pKey, pValue, REG_SZ,
(LPCTSTR)csX,
csX.GetLength() );
} else {
SHDeleteValue( HKEY_CURRENT_USER, pKey, pValue );
}
}
--
Brad Blanchard
http://www.braser.com
.
- Follow-Ups:
- Re: Start program when Vista starts
- From: Hans-Peter Diettrich
- Re: Start program when Vista starts
- From: Brad Blanchard
- Re: Start program when Vista starts
- From: Maarten Wiltink
- Re: Start program when Vista starts
- Prev by Date: ~~www.runescape-golds.com~~ buy cheap runescape gold/money!
- Next by Date: Using LIB Files in Delphi
- Previous by thread: ~~www.runescape-golds.com~~ buy cheap runescape gold/money!
- Next by thread: Re: Start program when Vista starts
- Index(es):