[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Winexec and the program can do more

Posted on 2000-01-08
27
Medium Priority
?
364 Views
Last Modified: 2010-04-06

when i push my button1.click and executes the code
'winexec('c:\acrobat4.exe',sw_shownormal);
and when the program is running i want my program breath i will be able to minimize my program or anything edit memo or something
0
Comment
Question by:trausti
  • 13
  • 6
  • 3
  • +3
27 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 2334789
Could you explain it again please? I didn't quite understand what you mean...

Regards, Madshi.
0
 

Expert Comment

by:brunohe
ID: 2334794
I think he wants to call Winexec first and then minimize his application. Earm... Madshi... you're damnd fast with you replys! <g>
0
 

Author Comment

by:trausti
ID: 2334798
i want to execute application and the application is so slow to unpack the files, so i want to be able to work in my program

e.g: minimize push a button or ??????
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

Expert Comment

by:brunohe
ID: 2334799
Oh... I forgot. Did you tried

Winexec(bla...);
form.WindowState := wsminimized;

?
0
 

Expert Comment

by:brunohe
ID: 2334800
Oh, sorry. Dont use Winexec, use ShellExecute instead. You can specify a parameter in the call (Win32 API) what should happen with your app.
0
 

Author Comment

by:trausti
ID: 2334801
!!!

if i use your code

//Winexec(bla...);
//form.WindowState := wsminimized;

the application will have to finish and when it is finish then the form will minimize, i want application.processmessage or something example
0
 

Author Comment

by:trausti
ID: 2334803
!!!

if i use your code

//Winexec(bla...);
//form.WindowState := wsminimized;

the application will have to finish and when it is finish then the form will minimize, i want application.processmessage or something example
0
 

Author Comment

by:trausti
ID: 2334805
have you example with ShellExecute
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2334881
Hi bruno-he...   :-)

Well, it was chance that I was so fast this time.

ShellExecute('calc.exe', nil, nil, nil, nil, SW_MINIMIZE);

Regards, Madshi.
0
 
LVL 17

Expert Comment

by:inthe
ID: 2335122
shellexecute
('handle,'open',pchar('c:\acrobat4.exe'),nil,nil,sw_minimize);
application.processmessages;
0
 

Expert Comment

by:kifah
ID: 2335486
Hi,
If the application you need to run is to large, and need time to run, in this case you should run it within a thread.
0
 

Expert Comment

by:kalink
ID: 2335782
Use CreateProcess(...)
see documentation i MS SDK help

I have somewhere complete example including code to wait for the executing program to finish.
So if anybody is interested I can
try to find it.

0
 
LVL 20

Expert Comment

by:Madshi
ID: 2335818
And another new expert! Welcome, kalink...   :-)

May I friendly request something? Here in the Delphi forum it is common practice to lock questions with an answer only if you are the first expert in the thread, or if all other comments are evidently wrong. Otherwise it is usual to post a *comment* only. This way the questioner can later choose easily which expert helped most. Thank you for listening...   (-:

Regards, Madshi.
0
 

Author Comment

by:trausti
ID: 2336175
I need an example with createprocess thanks
0
 
LVL 17

Expert Comment

by:inthe
ID: 2336199
var
  ds: Pchar;
  i: Integer;
  si :TStartupInfo;
  sa :PSecurityAttributes;
  ppi :PProcessInformation;
  pi  :TProcessInformation;
  h : LongBool;
begin
 ds:=PChar('');
 sa:=nil;
 GetStartupInfo(si);
 h:=CreateProcess( PChar('C:\Windows\Notepad.exe),
                   PChar(''),
                   sa,
                   sa,
                   false,
                   0,
                   ds,
                   PChar('C:\Windows'),
                   si,
                   pi
                   );
 if not h then showmessage('an error occurred') else
 begin
 WaitForSingleObject(pi.hProcess,10000);
 showmessage('finished');
 end;
close;
end;




0
 
LVL 17

Expert Comment

by:inthe
ID: 2336200
but that wont let your program "breath",in fact quite the opposite WaitForSingleObject() waits until the notepad is finished before your code continues...
0
 

Author Comment

by:trausti
ID: 2336225
I need an example with createprocess thanks
0
 

Author Comment

by:trausti
ID: 2336307
I got this message

an error occurred

//if not h then showmessage('an error occurred') else

what is wrong?
0
 
LVL 17

Expert Comment

by:inthe
ID: 2336401
apart from an unterminated string here:

h:=CreateProcess( PChar('C:\Windows\Notepad.exe),
maybe change this:
PChar('C:\Windows')  to
PChar('C:\')  
 
                   
there should be no error,i tested and works ,you can tell when it works becuase my test app doesnt even repaint itself...
maybe you have older version of delphi and need to change declaration?what delphi version you have?

i really dont think this is what your after is it?
dont you want your app to continue doing its stuff or you want your app to stop completely and wait for new app to finish?


0
 

Author Comment

by:trausti
ID: 2336441
okey, thi works, my code was like this

h:=CreateProcess( PChar('Notepad.exe'),
                                                    maybe change this:
                                                    PChar('C:\winnt')  to
                                                    PChar('C:\')  
------------
alright!!! maybe you can help me with this stuff!!!

how is best to executes all values in listview?

my listview will have this values

Tasks                                    Description
-------------------------------------------------------------------
Run App:                               c:\winnt\notepad.exe
Wait:                                    10000 // 10 seconds
SendKeys:                             {ALT}fo
............
............
--------------------------------------------------------------------

so i want to run notepad, wait 10 seconds and then send "file open" to notepad and even more

0
 

Author Comment

by:trausti
ID: 2336462
okey, thi works, my code was like this

h:=CreateProcess( PChar('Notepad.exe'),
                                                    maybe change this:
                                                    PChar('C:\winnt')  to
                                                    PChar('C:\')  
------------
alright!!! maybe you can help me with this stuff!!!

how is best to executes all values in listview?

my listview will have this values

Tasks                                    Description
-------------------------------------------------------------------
Run App:                               c:\winnt\notepad.exe
Wait:                                    10000 // 10 seconds
SendKeys:                             {ALT}fo
............
............
--------------------------------------------------------------------

so i want to run notepad, wait 10 seconds and then send "file open" to notepad and even more

0
 
LVL 17

Expert Comment

by:inthe
ID: 2336505
now we get details ...

The WaitForSingleObject function returns when one of the following occurs:
1:The specified object is in the       signaled state.
2:The time-out interval elapses.

DWORD WaitForSingleObject(
    HANDLE hHandle,      // handle of object to wait for
    DWORD dwMilliseconds       // time-out interval in milliseconds  
   );

execute values from listview i never tried ..
0
 

Author Comment

by:trausti
ID: 2336510
can you give me hint, can i use a timer component or ?
0
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 2336544
shouldnt need a timer just try calling

do something;
sleep(dwMilliSecs);
do somnething else;
0
 

Author Comment

by:trausti
ID: 2336550
can you give me hint, can i use a timer component or ?
0
 

Author Comment

by:trausti
ID: 2336552
thanks
0
 

Author Comment

by:trausti
ID: 2336553
thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

590 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