0
私の意図は、継承可能なオプションを持つ子プロセスにコマンドパラメータとして渡す入出力の匿名パイプとハンドルを作成することでした。以下は、Pascal(Lazarus)コードからの抜粋です(パイプ書き込みを開始するボタンはありません...)。パイプ通信とコマンドパラメータ
procedure TForm2.Button1Click(Sender: TObject);
var pi: tprocessinformation;
si: tstartupinfo;
h1, h2: thandle;
begin
createpipe(h1, h2, nil, 300); // --getlasterror returns 0
caption:= inttostr(h1)+ ' '+ inttostr(h2); // just to check
si.cb:= sizeof(si);
zeromemory(@si, sizeof(si));
createprocess(nil, pchar('ChildProject.exe '+ caption), nil, nil, true, 0, nil, nil, si, pi);
end;
子プロセスコード(私は意図的に別スレッドを使用していませんでした)
procedure TForm3.Button2Click(Sender: TObject);
var d: dword;
hin, hout: thandle;
begin
if paramcount= 2 then
begin
hout:= strtoint(paramstr(1));
hin:= strtoint(paramstr(2));
caption:= inttostr(hout)+ ' '+ inttostr(hin);
end;
readfile(hin, a, 8, d, nil);
label1.caption:= inttostr(d)+ ' '+ inttostr(getlasterror);
end;
子プロセスが正しいハンドルを表示するキャプションを始めたが、私は(私din'tは、親から送信された開始)ボタンを押したときに、エラーでのReadFile終了は(6)無効なハンドルをコード - 。 子供は親のパイプハンドルを継承していると思ったので、私は自由に使うことができますが、明らかに何か間違っています。
任意のヘルプ
同じ問題がSECURITY_ATTRIBUTESにあったことに気づいた同じ瞬間。ありがとうございました。 – Djole