• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1117
  • Last Modified:

ShellExecute to a Shortcut - How to

Hi experts,

I need to know how to ShellExecute to a Shortcut ?

Anyone know how?

Thanks

ST3VO
0
ST3VO
Asked:
ST3VO
  • 6
  • 6
  • 5
2 Solutions
 
JohnjcesCommented:
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
 
MerijnBSr. Software EngineerCommented:
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
 
JohnjcesCommented:
MerijnB,

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

John
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.

 
MerijnBSr. Software EngineerCommented:
sorry, hadn't seen your comment when I posted mine
0
 
JohnjcesCommented:
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
 
ST3VOAuthor Commented:
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
 
MerijnBSr. Software EngineerCommented:
I think this is a security precaution to prevent you from running something from a webpage.
0
 
ST3VOAuthor Commented:
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
 
MerijnBSr. Software EngineerCommented:
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
 
ST3VOAuthor Commented:
No...no errors at all....the app just doesn't load!

I'll give it a go!
0
 
JohnjcesCommented:
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
 
MerijnBSr. Software EngineerCommented:
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
 
ST3VOAuthor Commented:
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
 
JohnjcesCommented:
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
 
JohnjcesCommented:
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
 
ST3VOAuthor Commented:
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
 
ST3VOAuthor Commented:
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!

  • 6
  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now