Link to home
Start Free TrialLog in
Avatar of christophemonin
christophemonin

asked on

How to execute a shortcut with delphi?

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
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

Hi christophemonin,

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


----
Igor.

ASKER CERTIFIED SOLUTION
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of geobul
geobul

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
nothing to tell more :(
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 .
In your case the file is 'explorer'
Avatar of christophemonin

ASKER

Thanks for all, I prefer this one!

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

Christophe.