Solved

How to execute a shortcut with delphi?

Posted on 2002-04-20
7
1,300 Views
Last Modified: 2008-03-17
Hi!

I created a shortcut which refers to a local directory and I would like to launch it using delphi so it will open a file browser window with the listing of this directory.

How can I do to launch the created shortcut? or is there a way to open a file browser window without using shortcuts?

Thanks in advance!

Christophe
0
Comment
Question by:christophemonin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 6955817
Hi christophemonin,

you have to execute command "explorer C:\SomeDirectory".


----
Igor.

0
 
LVL 9

Accepted Solution

by:
ITugay earned 100 total points
ID: 6955822
Hi christophemonin,

here is an example:

uses
   ..., ShellApi,.....

const
  SomeDirectory = 'D:\PROJECTS';

procedure TForm1.SpeedButton4Click(Sender: TObject);
var
  S: String;
begin
  S := '/c explorer '+SomeDirectory;
  ShellExecute(handle,'open','command', @S[1], nil,SW_HIDE);
end;

-----
Igor
0
 
LVL 17

Expert Comment

by:geobul
ID: 6955899
Hi,
Another version:

uses
  ShellApi;

var
 SomeDirectory: string = 'C:\Program Files';

procedure TForm1.Button1Click(Sender: TObject);
begin
   ShellExecute(handle,'explore',PChar(SomeDirectory), nil, nil,SW_SHOWNORMAL);
end;

Regards, Geo
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:ginsonic
ID: 6955976
nothing to tell more :(
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6955985
Or...

If you wish to get the target of your shortcut then read next article :

'Get Shortcut Target File'
http://www.delphi3000.com/article.asp?ID=1838

Using this info :

var Target:string;
....
Target:=GetShortcutTarget('c:\MyLink.pif');

After that is simple to run it .
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6955989
In your case the file is 'explorer'
0
 

Author Comment

by:christophemonin
ID: 6956187
Thanks for all, I prefer this one!

But is there a way to execute a shortcut without gettin executing the target?

Christophe.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question