Recent

Author Topic: How i use CreateProcess ?  (Read 11901 times)

leandrojcbh

  • Newbie
  • Posts: 5
How i use CreateProcess ?
« on: December 05, 2013, 05:49:51 pm »
Hello!

I try to use in Lazarus:

uses

shellapi, process, windows;


(CreateProcess(pwidechar('\program files\test\hello.exe'), Nil, Nil, Nil,
  False, CREATE_NEW_CONSOLE, Nil, Nil, StartupInfo, ProcessInformation));

Error:

unit1.pas(40,71) Error: Identifier not found "ProcessInformation" !

Help!

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: How i use CreateProcess ?
« Reply #1 on: December 05, 2013, 06:00:38 pm »
processinformation afaik is a variable that you must declare. See MSDN

leandrojcbh

  • Newbie
  • Posts: 5
Re: How i use CreateProcess ?
« Reply #2 on: December 05, 2013, 06:33:35 pm »
But How?

I want do execute a .exe file!
Can you help!

I´m lost!

leandrojcbh

  • Newbie
  • Posts: 5
Re: How i use CreateProcess ?
« Reply #3 on: December 05, 2013, 06:35:15 pm »
This is my prog:


unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Dialogs, Menus,
  StdCtrls, Buttons, ExtCtrls, ComCtrls, DbCtrls, shellapi, process,
  windows, winceproc, winceint;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  ProcessInformation:tProcessInformation;

begin

  CreateProcess(pwidechar('volume.exe'), Nil, Nil, Nil,
  False, CREATE_NEW_CONSOLE, Nil, Nil, StartupInfo, ProcessInformation);
end;

end.


What is wrong?

leandrojcbh

  • Newbie
  • Posts: 5
Re: How i use CreateProcess ?
« Reply #4 on: December 05, 2013, 08:41:13 pm »
I get it!

Thanks!!!

tranminhchien

  • New Member
  • *
  • Posts: 20
Re: How i use CreateProcess ?
« Reply #5 on: December 29, 2013, 01:55:54 pm »
But How?

I want do execute a .exe file!
Can you help!

I´m lost!
if you just want to execute a .exe file, you can use shellExecute for more simplier. For example :

ShellExecute(0, nil, 'notepad.exe', nil, nil, 1);

this function is included in unit shellapi :)

 

TinyPortal © 2005-2018