Solved

ShellExecute to a Shortcut - How to

Posted on 2007-12-05
17
1,030 Views
Last Modified: 2012-06-27
Hi experts,

I need to know how to ShellExecute to a Shortcut ?

Anyone know how?

Thanks

ST3VO
0
Comment
Question by:ST3VO
[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
  • 6
  • 6
  • 5
17 Comments
 
LVL 18

Assisted Solution

by:Johnjces
Johnjces earned 250 total points
ID: 20414690
if shellexecute(handle, nil, Pchar('C:\Documents and Settings\johns\Desktop\fileZilla.lnk'), nil, nil, SW_SHOW) < 32 then
    ShowMessage('Unable to open file');

or...

if shellexecute(handle, nil, Pchar('C:\Program Files\JCITS Systems\CDLibrary\THE CD Library.url'), nil, nil, SW_SHOW) < 32 then
    ShowMessage('Unable to open file');

if an URL


if that is the kind of shortcut you are seeking. A shortcut on my desktop. Could be a shortcut put anywhere. The .lnk is always hidden.

John
0
 
LVL 19

Accepted Solution

by:
MerijnB earned 250 total points
ID: 20414711
see this example:
procedure TForm3.Button1Click(Sender: TObject);
begin
 ShellExecute(0, nil, 'c:\notepad.lnk', nil, nil, SW_SHOWNORMAL);
end;

Open in new window

0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20414764
MerijnB,

That's what I have.... Other than you have a 0 handle.

John
0
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!

 
LVL 19

Expert Comment

by:MerijnB
ID: 20414783
sorry, hadn't seen your comment when I posted mine
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20414865
As a side note, if you want to create an URL shortcut make a text file with a .url extension and write:

[InternetShortcut]
URL=http://delphi.about.com

Save it anywhere.

John
0
 

Author Comment

by:ST3VO
ID: 20416097
Hmmm.....In my situation none seem to work.

I'll explain better.

I've written an active Form Control which is deployed in a web page.
OnClick it uses Shellexecute to Run an Application.
The Application actually does run BUT this application is a control application which itself shellexecutes other .exe (apps).

By using Shellexecute directly to run the .exe, it will run the exe but this opened .exe will not run other .exe from it.

So, I decided to try via a Shortcut, which it why I'm asking here.

The problem is that the shortcut don't run the .exe from the Active Form.

Any ideas of how to solve this issue please?

Thanks

ST3VO
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 20417836
I think this is a security precaution to prevent you from running something from a webpage.
0
 

Author Comment

by:ST3VO
ID: 20418225
I can actually get it to run!

This with the case:

1 -----Active Form
              |___Loads App1.exe (works ok)
                                       |___Load external exe (Doesn't work)

So, it's not that the Active Form doesn't run the .exe ....It's the .exe that it loads that doesn't load the external app from itself.

p.s: This works fine if I load the application directly bypassing the Active Form!

0
 
LVL 19

Expert Comment

by:MerijnB
ID: 20418274
Do you get any errors from app1.exe?
If not, build in some logging so you can see where things are going wrong.
and why can't you start external.exe directly?
0
 

Author Comment

by:ST3VO
ID: 20418320
No...no errors at all....the app just doesn't load!

I'll give it a go!
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20419732
St3vo and EE Moderator,

I do not mean to complain. But...

This question has gone from a fairly simple,

"I need to know how to ShellExecute to a Shortcut ?"

to a second and much broader question;

"I've written an active Form Control which is deployed in a web page. OnClick it uses Shellexecute to Run an Application. The Application actually does run BUT this application is a control application which itself shellexecutes other .exe (apps). By using Shellexecute directly to run the .exe, it will run the exe but this opened .exe will not run other .exe from it. So, I decided to try via a Shortcut, which it why I'm asking here. The problem is that the shortcut don't run the .exe from the Active Form."

I do not believe this is proper and am asking the moderator and you to rethink this question.

Close it and ask again properly and in its entire context, or something.

Open to discussion from other experts as well if I am all wet, wrong, or too complaining etc.!

John
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 20419783
I tend to doubt.

For one part I agree with you, on the other hand, ST3VO is always _very_ generous with his points (he actually _always_ gives 500 points) even for very simple questions.

If this question was awarded with < 100 points I'd agree, now I'm not sure...
0
 

Author Comment

by:ST3VO
ID: 20420141
Thanks MerijnB for your comment! It's my pleasure, because you guys are always there to help!

Any 95% of the time I need an answer ASAP and your guys are giving me your knowledge and time!

I wish I was at least a decent programmer but I am not, although I DO try my best to learn things as quick as possible! I learn every day with the help you your guys!

About this question, Yes, I agree that I didn't explain myself properly. This is because I thought that executing a shortcut would solve the problem but it hasn't.

I agree that all I asked is to perform a shellexecute on a .lnk file, so if you wan't just assign those points and open another question!

Thanks again and sorry about that!

ST3VO
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20420345
It's not that I desire the points nor is it about the points... really!

It's about being full and open with the problem you are trying to solve. I realize at times we believe that there is a simple solution but it does not turn out to be simple.

I really like to help and provide as much information that I know. But don't we deserve all the information from the "gitgo?

But, IMHO (for what it is worth), questions should not grow whether you assign 50 points or 1000 points. If the question is answered and answered correctly, then it should be closed.

If the question grows into something completely different like executing an application from an application from a link then I believe that is entirely separate and a new question. I believe that in most your questions (from what I have read), you should supply as much information to those that might help you at the very beginning. Read through some posts and see how they have grown?

Show some snippets of what you've done and where the problem is. Is simply closing and reopening an ADOQuery going to solve your problem?

I could be really off base. I am not flaming, but I too am trying to learn. About this forum and more about Delphi.

Again... my opinion and how I read the rules.

My rant and 2 cents.

Thanks and sorry if I offended someone or if they took this the wrong way!

John
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20420520
Last of my 2 cents....

Would a batch file work for you?

Create a batch .bat file with the path and executable contained therein. Try and create a link to the batch file and see if that works.

John
0
 

Author Closing Comment

by:ST3VO
ID: 31413174
Here are the points! Question closed! Yes...the asked question a question and got an answer but as MerijnB said I am usualy very generous with the points and the gradings because I appreciate your time and effort and a bit of flexibility would have been appreciated considering the number of questions I ask and the grades I give.
But never mind! I'll be more careful next time!
Thanks

ST3VO
0
 

Author Comment

by:ST3VO
ID: 20420553
OK, I'll try ...thanks!!!
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

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

695 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