Solved

How to execute a shortcut with delphi?

Posted on 2002-04-20
7
1,227 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

11 Experts available now in Live!

Get 1:1 Help Now