Grupos de Google ya no admite nuevas publicaciones ni suscripciones de Usenet. El contenido anterior sigue siendo visible.

placing shortcut on desktop

Visto 48 veces
Saltar al primer mensaje no leído

Martin

no leída,
20 mar 2007, 22:23:3620/3/07
a

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

no leída,
20 mar 2007, 23:36:1420/3/07
a

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

no leída,
20 mar 2007, 23:46:3620/3/07
a

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)

no leída,
21 mar 2007, 0:44:3221/3/07
a

"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

no leída,
21 mar 2007, 10:52:3521/3/07
a

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

no leída,
24 mar 2007, 17:04:4024/3/07
a

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

Liz

no leída,
24 mar 2007, 19:25:1424/3/07
a
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

no leída,
24 mar 2007, 19:20:4424/3/07
a
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)

no leída,
25 mar 2007, 1:33:4825/3/07
a

"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

no leída,
30 mar 2007, 23:32:5430/3/07
a

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

Martin

0 mensajes nuevos