±ÍÇÏ´Â ¼Õ´Ô À̽ʴϴÙ
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ
  
  µ¨¸¶´ç °ø½Ä ÀºÇà°èÁÂ
  ÇϳªÀºÇà 227-910235-83607
  ¿¹±ÝÁÖ ÀÌ»ó±¹(¿î¿µÁø)
ÇÁ·ÎÁ§Æ® °Ô½ÃÆÇ
ÅõÇ¥°Ô½ÃÆÇ
µ¨¸¶´ç¼Ò°³
±âÃʺÎÅÍ È°¿ë±îÁö! µ¨ÆÄÀÌ ±³À° - µ¥ºê±â¾î
Áú¹®°ú ´äº¯ Áú¹®°ú ´äº¯ ÀÔ´Ï´Ù.
±Û³»¿ë - Áú¹®°ú ´äº¯
 [´äº¯][Áú¹®] µ¨ÆÄÀÌ¿¡¼­ À©µµ¿ìÀÇ Ä¿¸Çµå ¸í·É¾î¸¦ ½ÇÇàÇÏ¿© ±× °á°ú°ªÀ» Memo1 ¿¡ Ãâ·ÂÇÏ°í ½Í½À´Ï´Ù.
½ã´õ¶ÊÀÌ
(Á¤¹®ÀÏ)
2019-01-17 ¿ÀÀü 9:39:44
491ȸ Á¶È¸


µî·ÏµÈ ÆÄÀÏÀÌ ¾ø½À´Ï´Ù.
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Edit1: TEdit;
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
function GetDosOutput(CommandLine: string; Work: string = 'C:\'): string;  { Run a DOS program and retrieve its output dynamically while it is running. }
var
  SecAtrrs: TSecurityAttributes;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  StdOutPipeRead, StdOutPipeWrite: THandle;
  WasOK: Boolean;
  pCommandLine: array[0..255] of AnsiChar;
  BytesRead: Cardinal;
  WorkDir: string;
  Handle: Boolean;
begin
  Result := '';
  with SecAtrrs do begin
    nLength := SizeOf(SecAtrrs);
    bInheritHandle := True;
    lpSecurityDescriptor := nil;
  end;
  CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SecAtrrs, 0);
  try
    with StartupInfo do
    begin
      FillChar(StartupInfo, SizeOf(StartupInfo), 0);
      cb := SizeOf(StartupInfo);
      dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
      wShowWindow := SW_HIDE;
      hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't redirect stdin
      hStdOutput := StdOutPipeWrite;
      hStdError := StdOutPipeWrite;
    end;
    WorkDir := Work;
    Handle := CreateProcess(nil, PChar('cmd.exe /C ' + CommandLine),
                            nil, nil, True, 0, nil,
                            PChar(WorkDir), StartupInfo, ProcessInfo);
    CloseHandle(StdOutPipeWrite);
    if Handle then
      try
        repeat
          WasOK := windows.ReadFile(StdOutPipeRead, pCommandLine, 255, BytesRead, nil);
          if BytesRead > 0 then
          begin
            pCommandLine[BytesRead] := #0;
            Result := Result + pCommandLine;
          end;
        until not WasOK or (BytesRead = 0);
        WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
      finally
        CloseHandle(ProcessInfo.hThread);
        CloseHandle(ProcessInfo.hProcess);
      end;
  finally
    CloseHandle(StdOutPipeRead);
  end;
end;

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
  begin
    memo1.text := GetDosOutput(edit1.text);
  end;
end;

end.

>> 1. °³¹ß/½ÇÇà Ç÷§Æû 
>>   (1) OS : 
>>   (2) °³¹ßÅø : 
>>   (3) »ç¿ë Database : 
>> 
>> 2. °³¹ß ÁßÀΠÇÁ·Î±×·¥ 
>> 
>> 3. Áú¹® ³»¿ë 
>>  
>>  ShellExecute ¸¦ ÀÌ¿ëÇÏ¿© CMD Ã¢À» ¿©´Â °ÍÀº ÀÍÈ÷ ¾Ë°í ÀÖ½À´Ï´Ù.
>>  ÇÏÁö¸¸ ±× ¿­¸° CMDâ¿¡¼­ ¾î¶°ÇÑ µµ½º ¸í·É (¿¹¸¦ µé¾î dir/w ¶ó´øÁö..)À»
>>  ½ÇÇà½ÃÄÑ ±× Ãâ·ÂµÇ´Â °ªÀ» µ¨ÆÄÀÌÀÇ ¸Þ¸ðÀå¿¡ ¿Å°Ü¿Í Ãâ·ÂÇÏ°í ½Í½À´Ï´Ù¸¸
>>  ÀÌ°Ô °ú¿¬ °¡´ÉÇÑÁö ±Ã±ÝÇÕ´Ï´Ù.
>>  ÇöÀç Á¦°¡ ¾Ë°í Àִ Áö½ÄÀ¸·Î´Â 
>>  C:\Windows\dir/w >> filelist.txt
>>  ÀÌ·±½ÄÀ¸·Î ÆÄÀϷΠÀúÀåÇÏ¿© ±× ÆÄÀÏÀ» ºÒ·¯¿À´Â ¹æ¹ý¹Û¿£ »ý°¢ÀÌ ¾È³ª³×¿ä.
>>  ¹°·Ð ´Ü¼øÈ÷ ÆÄÀϸ®½ºÆ® ¾ò¾î¿À´Â dir/w °°Àº ¸í·ÉÀ̾ߠÆÄÀϷΠÀúÀåÇÏ¿© ±× ÆÄÀÏÀ»
>>  ¸Þ¸ðÀå¿¡¼­ Àоî¿Ã¼öµµ ÀÖÁö¸¸
>>  netstat µîÀ» ÀÌ¿ëÇÏ¿© ÁÖ±âÀûÀΠ½Ã°£À» ¼³Á¤ÇÏ¿© °è¼Ó ¹èÃâµÇ´Â °ªÀ» Àоî¿Í¾ßÇϴ °æ¿ì¿¡´Â
>>  ´Ù¸¥ ¹æ¹ýÀ» »ç¿ëÇؾߠÇÒ °Í °°¾Æ¿ä.
>> 
>>  Á¤¸®ÇÏÀÚ¸é 
>>  ²À CMD Ã¢À» ¿­Áö ¾Ê°í
>>  µµ½º ¸í·É¾î¸¦ ½ÇÇàÇÏ¿© ±× °á°ú°ªÀ» ¸Þ¸ðÀå¿¡ »Ñ¸®°í ½Í½À´Ï´Ù.
>> 
>>