掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
"net file"の出力結果を取得するには? (ID:36580)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
パイプでも「一覧にエントリが存在しません」を取得できました。 procedure TForm1.Button1Click(Sender: TObject); const lci_BUFFSIZE = 1024; var lp_Buff: PAnsiChar; li_BuffSize, li_Count, li_ExitCode: DWORD; lh_Read, lh_Write: THandle; lr_Startup: TStartupInfo; lr_Process: TProcessInformation; lr_Security: TSecurityAttributes; begin Memo1.Clear; FillChar(lr_Security, SizeOf(lr_Security), 0); with lr_Security do begin nLength := SizeOf(lr_Security); lpSecurityDescriptor := nil; bInheritHandle := True; end; if (CreatePipe(lh_Read, lh_Write, @lr_Security, 0)) then begin FillChar(lr_Startup, SizeOf(lr_Startup), 0); with lr_Startup do begin cb := SizeOf(lr_Startup); dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW; wShowWindow := SW_HIDE; hStdInput := lh_Read; hStdOutput := lh_Write; hStdError := lh_Write; end; if (CreateProcess( nil, PChar('net file'), nil, nil, True, CREATE_NEW_CONSOLE, nil, nil, lr_Startup, lr_Process )) then begin repeat GetExitCodeProcess(lr_Process.hProcess, li_ExitCode); PeekNamedPipe(lh_Read, nil, 0, nil, @li_BuffSize, nil); if (li_BuffSize <> 0) then begin lp_Buff := AllocMem(li_BuffSize+1); try ReadFile(lh_Read, lp_Buff[0], li_BuffSize, li_Count, nil); if (li_Count > 0) then begin Memo1.Text := Memo1.Text + String(lp_Buff); end; finally FreeMem(lp_Buff); end; end; Sleep(1); Application.ProcessMessages; until (li_ExitCode <> STILL_ACTIVE); TerminateProcess(lr_Process.hProcess, 0); CloseHandle(lr_Process.hThread); CloseHandle(lr_Process.hProcess); end; CloseHandle(lh_Read); CloseHandle(lh_Write); end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.