
05.06.2009, 16:42
|
Активный
|
|
Регистрация: 29.03.2009
Сообщения: 300
Репутация: 94
|
|
Я бы сделала так...
Код:
procedure TForm1.Button1Click(Sender: TObject);
var
WinDir: PChar;
cmdPath: string;
_si: STARTUPINFO;
_pi: PROCESS_INFORMATION;
begin
GetMem(WinDir, MAX_PATH);
try
GetWindowsDirectory(WinDir, MAX_PATH);
cmdPath := StrPas(WinDir) + '\system32\cmd.exe';
FillChar(_si, SizeOf(_si), 0);
_si.cb := SizeOf(_si);
_si.dwFlags := STARTF_USESHOWWINDOW;
_si.wShowWindow := SW_HIDE;
CreateProcess(nil, PChar(cmdPath + ' /c "ipconfig /all > ipreport.txt"'),
nil, nil, False, CREATE_DEFAULT_ERROR_MODE, nil,
PChar(ExtractFileDir(Application.ExeName)), _si, _pi);
WaitForSingleObject(_pi.hProcess, INFINITE);
CloseHandle(_pi.hProcess);
CloseHandle(_pi.hThread);
if not FileExists('ipreport.txt') then Exit;
Memo1.Lines.LoadFromFile('ipreport.txt');
DeleteFile('ipreport.txt');
finally
FreeMem(WinDir, MAX_PATH);
end;
end;
|