Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

placing shortcut on desktop

48 views
Skip to first unread message

Martin

unread,
Mar 20, 2007, 10:23:36 PM3/20/07
to

Hello -

I am trying to place a shortcut on the desktop to call my
application which is located somewhere down the line in the
programs folder. I know how to use the Shellobj and actually
place the application on the desktop, but I want to leave the
app where it is and just put the shortcut on the desktop. I
also want to have the application icon be the shortcut icon on
the desktop. Any ideas? Thanks much.
Martin

NovaKane

unread,
Mar 20, 2007, 11:36:14 PM3/20/07
to

Navigate to your app folder, right click on the EXE file, and choose
Send To...Desktop (create shortcut). That always works for me. If
you're on Vista, I don't know. :>) Whatever you're using for the app
icon, should show up as your shortcut icon also.

Rob Kennedy

unread,
Mar 20, 2007, 11:46:36 PM3/20/07
to

Which part is giving you trouble? Have you tried any of the sample code
you found when you searched the newsgroup archives? What have you tried,
and how has it failed?

http://groups.google.com/groups?q=shellobj+shortcut+desktop&as_ugroup=*delphi*

--
Rob

Remy Lebeau (TeamB)

unread,
Mar 21, 2007, 12:44:32 AM3/21/07
to

"Martin" <mn3...@earthlink.net> wrote in message
news:46008918$1...@newsgroups.borland.com...

> I am trying to place a shortcut on the desktop

You need to use the IShellLink interface, as explained in the
following article:

Shell Links

http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/shortcuts/shortcut.asp


Gambit


Matt Lacey

unread,
Mar 21, 2007, 10:52:35 AM3/21/07
to

Don't do this in the program. Do it as part of the installation
process.
And even then only if the user requests the shortcut to be created.

Martin

unread,
Mar 24, 2007, 5:04:40 PM3/24/07
to

Actually, The IPersistFile and CreateComObject keep coming
back with undeclared identifier. I tried adding to the uses
but I've had no luck.

Liz

unread,
Mar 24, 2007, 7:25:14 PM3/24/07
to
Martin wrote:

>
> Actually, The IPersistFile and CreateComObject keep coming
> back with undeclared identifier. I tried adding to the uses
> but I've had no luck.

What version of delphi are you using, it all seems to work for me

I added ShlObj, ActiveX, ComObj to uses

and

procedure TForm1.FormCreate(Sender: TObject);
var IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
PIDL : PItemIDList;
InFolder : array[0..MAX_PATH] of Char;
TargetName : String;
LinkName : WideString;
begin
TargetName := 'c:\windows\calc.exe';

{Use TargetName:=ParamStr(0) which
returns the path and file name of the
executing program to create a link to your
Application}

IObject := CreateComObject(CLSID_ShellLink) ;
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;

with ISLink do
begin
SetPath(pChar(TargetName)) ;
SetWorkingDirectory(pChar(ExtractFilePath(TargetName))) ;
end;

// if we want to place a link on the Desktop
SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, PIDL) ;
SHGetPathFromIDList(PIDL, InFolder) ;

{
or if we want a link to appear in
some other, not-so-special, folder:
InFolder := 'c:\SomeFolder'
}

LinkName := InFolder + '\Delphi Created Link.lnk';
IPFile.Save(PWChar(LinkName), false) ;

end;

--
Liz the Brit
Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings

Rob Kennedy

unread,
Mar 24, 2007, 7:20:44 PM3/24/07
to
Martin wrote:
> Actually, The IPersistFile and CreateComObject keep coming
> back with undeclared identifier.

That means you haven't included any unit that declares those identifiers.

> I tried adding to the uses
> but I've had no luck.

What have you tried adding? When I need to know what unit something is
declared in, I do a text search on the source code.

--
Rob

Remy Lebeau (TeamB)

unread,
Mar 25, 2007, 1:33:48 AM3/25/07
to

"Martin" <mn3...@earthlink.net> wrote in message
news:46058458$1...@newsgroups.borland.com...

> Actually, The IPersistFile and CreateComObject keep
> coming back with undeclared identifier.

CreateComObject() is declared in the ComObj unit, and IPersistFile is
declared in the ActiveX unit.


Gambit


Martin

unread,
Mar 30, 2007, 11:32:54 PM3/30/07
to

Many thanks for all of the suggestions. The uses information
put me over the top. Sometimes the obvious just passes me by..

Martin

0 new messages