Solved

How to execute a shortcut with delphi?

Posted on 2002-04-20
7
1,246 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
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now