?
Solved

How to execute a shortcut with delphi?

Posted on 2002-04-20
7
Medium Priority
?
1,324 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Industry Leaders: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

762 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