Solved

Create Process

Posted on 2004-05-02
4
462 Views
Last Modified: 2010-04-05
In Ms SDK, there is a function createprocess. But I don't know how I can use it in Delphi. Can you give me a example how to use createprocess to get infomation from that command line
c:\php\php.exe c:\test\a.php

a.php

<?php
$a=12;
echo '<html>';
echo $a;
echo '</html>';
?>

In the command, it show out
<html>12</html>

Can I get that information with createprocess?
0
Comment
Question by:AkaZn
[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
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
shaneholmes earned 50 total points
ID: 10972783
CreateProcess  is  function  used  to  start  programmes,  it  gives  you  more  control
then  ShellExcute.  It is not used to get information from the command line, rather used to run and application and pass information through the command line. Although, you have control over thge parameters.

The applications called by ShellExecute will run asynchronously, that
is, the execution of our application continues without waiting to the end
of the application called by ShellExecute.

If we want an application to
execute synchronously, we shouldn't use ShellExecute, but a code like
the following:


Here  is  an  example  of  using  CreateProcess  to  start  notepad.exe,  then  show  some information  return  by  CreateProcess.



procedure  TForm1.CreateNotepad;
var
    startinfo  :  TStartupInfo;
    processinfo  :  TProcessInformation;
begin
    FillChar(startinfo,SizeOf(TStartupInfo),0);
    with  startinfo  do
      begin
          cb  :=  SizeOf(TStartupInfo);
          dwFlags  :=  STARTF_FORCEONFEEDBACK  or  STARTF_FORCEOFFFEEDBACK
      end;

    CreateProcess('C:\windows\notepad.exe',  '',  Nil,  0,  False,
                                              CREATE_DEFAULT_ERROR_MODE    or  CREATE_NEW_PROCESS_GROUP  or
                                              NORMAL_PRIORITY_CLASS,  Nil  ,'c:\windows\desktop',
                                              startinfo,processinfo);
    with  processinfo  do
      begin
        Label1.Caption  :=  'Process  Handle  :  '  +  IntToHex(hProcess,8);
        Label2.Caption  :=  'Thred  Handle  :  '      +  IntToHex(hThread,8);
        Label3.Caption  :=  'Process  ID  :  '          +  IntToHex(dwProcessId,8);
        Label4.Caption  :=  'Thred  ID  :  '              +  IntToHex(dwThreadId,8);
      end;

end;


http://www.delphicorner.f9.co.uk/articles/wapi4.htm
http://www.chami.com/tips/delphi/122096D.html


Shane
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10976629

  AkaZn, it you want to use the so called "command line" from PHP, you don't need CreateProcess API. You need to do this:

  <?
    $cmdLine = genenv("QUERY_STRING");
  ?>
0
 

Author Comment

by:AkaZn
ID: 10983731
Which I want is use Delphi to get information from what the program (php.exe) show in the command line after I run it. I am a newbie at some part so don't laught at me (BTW I am not natural born English speaker too). I have found that if I use >filename the information I want will be written to a file instead of write to the command console. This topic is how to use create process so I will give point to shaneholmes. But can anyone tell me how use shellexcute and createprocess (I have try but Delphi said it can't find the function). I think it is the same as how to include shell32.dll and shell32.lib. Thank you, everyone who helped me.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10983996

   Yep, it seems that Shane's answer deserves the points. I agree. Well, about the missing functions ... you probably don't put the unit they are declared in uses clause. CreateProcess in declared in Windows unit and it is added by default. ShellExecute is in ShellAPI unit.

    uses ..., ShellAPI;
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 70
Mobile Keyboard covers the display of the TMemo 3 115
DBGrid or StringGrid ? 6 137
TAction.OnAfterExecute? 2 32
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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