Solved

Problem with shellexecute ?

Posted on 2004-04-07
18
468 Views
Last Modified: 2010-04-05
Hi guys
I use shellexecute to run another application by my program
this instruction success with most of programs , but it is not work well with games programs ,some times don't do anything and another time give me an error
I want to run any program without any problem .

thanks
0
Comment
Question by:peruzzi
[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
  • 9
  • 8
18 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10779070
Try this

 function CreateProcessSimple(
  sExecutableFilePath : string )
    : string;
var
  pi: TProcessInformation;
  si: TStartupInfo;
begin
  FillMemory( @si, sizeof( si ), 0 );
  si.cb := sizeof( si );

  CreateProcess(
    Nil,

    // path to the executable file:
    PChar( sExecutableFilePath ),

    Nil, Nil, False,
    NORMAL_PRIORITY_CLASS, Nil, Nil,
    si, pi );

  // "after calling code" such as
  // the code to wait until the
  // process is done should go here

  CloseHandle( pi.hProcess );
  CloseHandle( pi.hThread );
end;


SHane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10779086
sorry,

Then call it like - CreateProcessSimple( 'C:\MyApp.exe' );

Shane
0
 
LVL 5

Accepted Solution

by:
Hypoviax earned 20 total points
ID: 10781186
Just a query shane, why would shellexecute not work? In every instance i've tried to run a program it has worked using code such as

shellexecute(handle,'open',pchar(filepath),'','',sw_show);

Regards,

Hypoviax
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!

 

Author Comment

by:peruzzi
ID: 10781702
Hi
Hypoviax, you are right ,its my fault I wrote SW_SHOWNORMAL

thanks for you and thanks for shan
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10782670
I dont know, but it looks lke he didn't like your answer either - "B"

<Smile>

Shane
0
 

Author Comment

by:peruzzi
ID: 10785852
sorry shan
but your answer didn't solve my problem
and the bad thing is that the accepted answer didn't work with all applications

I choose the wrong answer to be accepted.

sorry again
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10785898
Hmm, what didn't my procedure do?

Could you elaborate more on both Hypoviax's and mine, as to why they didn't work, what you received for any errors, etc.

Shane
0
 

Author Comment

by:peruzzi
ID: 10786024
Hi
your code and Hypoviax's code run the game for part of second and then close without give any error !!!!!

0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10786104
Is the game a dos game or Windows game?

Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10786138
Hey Hypoviax, I guess it doesn't work in every instance.... <SMILE>

"Just a query shane, why would shellexecute not work? In every instance i've tried to run a program it has worked using code such as"

Shane
0
 

Author Comment

by:peruzzi
ID: 10786182
It is windows program like fifa2004
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10786317
Well, i have tested my procedure over and over with all kinds of Dos, & windows programs, and it works fine. So does the SHellExecute method of the API. Try it yourself, with some applications on your machine and you will see. There is something else about your program that hasn't been disclosed to us.  

SO its a game like Fifa2002 - you can't tell us what game it is?

Shane
0
 

Author Comment

by:peruzzi
ID: 10806431
Hi guys
I tried to use (winexec function)
it success when I  use opendialog component with this code on the button :

if opendialog1.Execute then
winexec(pchar(opendialog1.FileName),sw_show);

but if I write in the code of button :

winexec(pchar('c:\my game.exe'),sw_show);

the game not work and I see an error message( zsystem defulte output
game release only support packed scenes)

so what you say

I am waiting .............
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10806453
Try renaming the Executable (right click choose rename)

from

my game.exe

to

mygame.exe

SHane
0
 

Author Comment

by:peruzzi
ID: 10808654
the problem isn't on space in the exename
because the function do the same wronge with exename don't have space


0
 

Author Comment

by:peruzzi
ID: 10808661
shane , your procedure do the same wronge with the same error message
0
 

Author Comment

by:peruzzi
ID: 10815698
where are you guys

help me
0
 

Author Comment

by:peruzzi
ID: 10821738
Hi guys
stop you search for solution
because I find  where  the problem is

when I try to run the game ,the game start but it try to get its data from the folder of my application
so I use setcurrentdir to go to the folder of game.

I wish you understand me
thanks for your help
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
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…
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

623 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