Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2006 Feb : Be Carzing in CreateProcess( )

www.cryer.info
Managed Newsgroup Archive

Be Carzing in CreateProcess( )

Subject:Be Carzing in CreateProcess( )
Posted by:"Lovewormcn" (loveworm..@hotmail.com)
Date:Mon, 13 Feb 2006 10:37:29

I wote a small delphi prgram to practice CretaeProcess,

    for il:=1 to 3 do begin
      pidIe:=MyWinExec('C:\Program Files\Internet Explorer\IEXPLORE.EXE');
      pHandle:=OpenProcess(PROCESS_ALL_ACCESS,false,pidIe);
      TerminateProcess(pHandle,0);
      CloseHandle(pHandle);
    end;-
In the 1st  loop (il=1) OpenProcess works right and IE works right too.

but in the 2nd loop(il=2) OpenProcess works right but IE is error,IE
reports that:Application initlize(0xc000142) Error

in the 3th loop(il=3) that happend too.
Why?I'll be crazing.....-

  function MyWinExec(pName:pAnsiChar;IsShow:Boolean=true):Cardinal;
  var
    si:STARTUPINFO;
    pi:PROCESS_INFORMATION;
    Name:array[0..199] of char;
  begin
    ZeroMemory(@Name,200);
    si.cb:=SizeOf(si);
    si.lpReserved:=nil;
    si.lpTitle:=nil;
    si.dwFlags:=STARTF_USESHOWWINDOW;
    if IsSHow then si.wShowWindow:=SW_SHOW else si.wShowWindow:=SW_HIDE;
    strcopy(Name,pName);
    CreateProcess(nil,
                  Name,
                  nil,
                  nil,
                  true,
                  NORMAL_PRIORITY_CLASS ,
                  nil,
                  nil,
                  si,
                  pi);
    Result:=pi.dwProcessId;
    CloseHandle(pi.hThread);
    CloseHandle(pi.hProcess);
  end;

Replies:

www.cryer.info
Managed Newsgroup Archive