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

Launching Shortcuts (lnk files)

121 views
Skip to first unread message

Andrew Jameson

unread,
Mar 9, 2005, 5:24:38 AM3/9/05
to
Hi,
I need to be able to launch lnk files and obtain the PID for the launched
application ... I realize that not all apps will have a PID such as explorer
but most will.

I currently use CreateProcess and can therefore obtain the PID directly but
have to do a bit of preprocessing on the lnk file to get the executable name
from the lnk.

I now need to be able to deal with folder shortcuts and can't quite figure
out a 'nice' generic solution to launch such lnk files.

Backtracking a little, I experimented with ShellExecuteEx, passing it the
actual lnk file ... it deals with all that I want but I can't figure out how
to get anything that will enable me to get the PID ... as it's a lnk file,
even the hProcess returned value is zero.

So is there a way to preprocess a lnk file so that I can pass it on to
CreateProcess or is there another solution ? (by the way, I need it to work
with Windows 98 so stuff like GetProcessID won't be an option.)

Thanks

Andrew


Troels Jakobsen

unread,
Mar 9, 2005, 7:00:22 PM3/9/05
to
You get the PIDL from IShellLink.GetIDList.

You can find a component and a demo here that I think does what you want:
http://subsimple.com/delphi.asp (ShellLinker).

Troels


"Andrew Jameson" <con...@softspotsoftware.com> wrote in message
news:422e...@newsgroups.borland.com...

Andrew Jameson

unread,
Mar 10, 2005, 3:56:47 AM3/10/05
to
Many thanks Troels ... sorry, I'm actually after the Process ID (PID) and
not the Pointer to an Item iDentifier List (PIDL).

As I said, CreateProcess does give me the PID whereas ShellExecute doesn't
and maybe there's a way to get it ?

I've actually solved my problem ... I preprocess all shortcuts to get the
target executable using IShellLink and if it's not an exe then I get the
associated executable from FindExecutable. Now the only shortcut that I
have problems with is a folder shortcut and I wouldn't get a PID for this
anyway ... so my workaround is to call ShellExecute if CreateProcess fails.

(I'm writing an application launch manager and need to monitor all launched
applications - providing restrictions to limit the number of launched
instances and to automatically close all launched applications when the
launch manager closes.)

By the way, your Delphi examples are excellent ! ... very impressed !

Andrew

"Troels Jakobsen" <do...@like.spam> wrote in message
news:422f8e22$1...@newsgroups.borland.com...

Troels Jakobsen

unread,
Mar 11, 2005, 2:17:54 AM3/11/05
to
He, I should get to know my acronyms better.

Troels

"Andrew Jameson" <con...@softspotsoftware.com> wrote in message

news:42300bbd$1...@newsgroups.borland.com...

0 new messages