Q&A

  • 도스쪽에 관한.
안녕하세요...

궁금한게 있어서 이렇게 씁니다.

질문: 도스에 나타난 글은 메모장에 나타나게 하고 싶은데 어떻게 해야 할지 모르겠내요...



예: 도스에서 어떤 프로그램을 실행했는데 그 프로그램의 옵션이나 다른 어떤글이 나온것을 메모장에 나타나게요.





정말 필요해서입니다. 도와주세요...

만일 공개가 불가능하면 메일에 써주셔도 됩니다. 그리고 예제소스까지 주시면 도욱 고맙겠습니다.

즐거운 코딩이 되시길...

4  COMMENTS
  • Profile
    구창민 1999.05.06 05:58
    한만택 wrote:

    > 안녕하세요...

    > 궁금한게 있어서 이렇게 씁니다.

    > 질문: 도스에 나타난 글은 메모장에 나타나게 하고 싶은데 어떻게 해야 할지 모르겠내요...

    >

    > 예: 도스에서 어떤 프로그램을 실행했는데 그 프로그램의 옵션이나 다른 어떤글이 나온것을 메모장에 나타나게요.

    >

    >

    > 정말 필요해서입니다. 도와주세요...

    > 만일 공개가 불가능하면 메일에 써주셔도 됩니다. 그리고 예제소스까지 주시면 도욱 고맙겠습니다.

    > 즐거운 코딩이 되시길...



    한만택님 안녕하세요?

    아래글을 보시고 도움되시길 바랍니다.

    Redirecting DOS App Output D2 D3 D4

    A function to execute a DOS or Win32 consoloe mode application and wait for it to close before continuing. Input for the app can be directed from a file, and the output will be redirected to a file.

    uses

    Controls, Windows, SysUtils, Forms;



    {---------------------------CreateDOSProcessRedirected--------------------------

    Description : executes a (DOS!) app defined in the CommandLine parameter

    redirected to take input from InputFile (optional) and give

    output to OutputFile

    Result : True on success

    Parameters : CommandLine : the command line for app, including full path

    InputFile : the ascii file where from the app takes input,

    empty if no input needed/required.

    OutputFile : the ascii file to which the output is redirected

    ErrMsg : additional error message string. Can be empty

    Error checking : YES

    Target : Delphi 2, 3, 4

    Author : Theodoros Bebekis, email bebekis@otenet.gr

    Notes :

    Example call : CreateDOSProcessRedirected('C:MyDOSApp.exe',

    'C:InputPut.txt',

    'C:OutPut.txt',

    'Please, record this message')

    -------------------------------------------------------------------------------}

    function CreateDOSProcessRedirected(const CommandLine, InputFile, OutputFile,

    ErrMsg :string): boolean;

    const

    ROUTINE_ID = '[function: CreateDOSProcessRedirected]';

    var

    OldCursor : TCursor;

    pCommandLine : array[0..MAX_PATH] of char;

    pInputFile,

    pOutPutFile : array[0..MAX_PATH] of char;

    StartupInfo : TStartupInfo;

    ProcessInfo : TProcessInformation;

    SecAtrrs : TSecurityAttributes;

    hAppProcess,

    hAppThread,

    hInputFile,

    hOutputFile : THandle;

    begin

    Result := FALSE;



    { check for InputFile existence }

    if (InputFile <> '') and (not FileExists(InputFile)) then

    raise Exception.CreateFmt(ROUTINE_ID + #10 + #10 +

    'Input file * %s *' + #10 +

    'does not exist' + #10 + #10 +

    ErrMsg, [InputFile]);



    hAppProcess := 0;

    hAppThread := 0;

    hInputFile := 0;

    hOutputFile := 0;



    { save the cursor }

    OldCursor := Screen.Cursor;

    Screen.Cursor := crHourglass;



    try

    { copy the parameter Pascal strings to null terminated strings }

    StrPCopy(pCommandLine, CommandLine);

    StrPCopy(pInputFile, InputFile);

    StrPCopy(pOutPutFile, OutputFile);



    { prepare SecAtrrs structure for the CreateFile calls. This SecAttrs

    structure is needed in this case because we want the returned handle to

    be inherited by child process. This is true when running under WinNT.

    As for Win95, the parameter is ignored. }

    FillChar(SecAtrrs, SizeOf(SecAtrrs), #0);

    SecAtrrs.nLength := SizeOf(SecAtrrs);

    SecAtrrs.lpSecurityDescriptor := nil;

    SecAtrrs.bInheritHandle := TRUE;



    if InputFile <> '' then

    begin

    { create the appropriate handle for the input file }

    hInputFile := CreateFile(

    pInputFile, { pointer to name of the file }

    GENERIC_READ or GENERIC_WRITE, { access (read-write) mode }

    FILE_SHARE_READ or FILE_SHARE_WRITE, { share mode }

    @SecAtrrs, { pointer to security attributes }

    OPEN_ALWAYS, { how to create }

    FILE_ATTRIBUTE_NORMAL

    or FILE_FLAG_WRITE_THROUGH, { file attributes }

    0); { handle to file with attrs to copy }



    { is hInputFile a valid handle? }

    if hInputFile = INVALID_HANDLE_VALUE then

    raise Exception.CreateFmt(ROUTINE_ID + #10 + #10 +

    'WinApi function CreateFile returned an invalid handle value' + #10 +

    'for the input file * %s *' + #10 + #10 +

    ErrMsg, [InputFile]);

    end else

    { we aren't using an input file }

    hInputFile := 0;



    { create the appropriate handle for the output file }

    hOutputFile := CreateFile(

    pOutPutFile, { pointer to name of the file }

    GENERIC_READ or GENERIC_WRITE, { access (read-write) mode }

    FILE_SHARE_READ or FILE_SHARE_WRITE, { share mode }

    @SecAtrrs, { pointer to security attributes }

    CREATE_ALWAYS, { how to create }

    FILE_ATTRIBUTE_NORMAL

    or FILE_FLAG_WRITE_THROUGH, { file attributes }

    0 ); { handle to file with attrs to copy }



    { is hOutputFile a valid handle? }

    if hOutputFile = INVALID_HANDLE_VALUE then

    raise Exception.CreateFmt(ROUTINE_ID + #10 + #10 +

    'WinApi function CreateFile returned an invalid handle value' + #10 +

    'for the output file * %s *' + #10 + #10 +

    ErrMsg, [OutputFile]);



    { prepare StartupInfo structure }

    FillChar(StartupInfo, SizeOf(StartupInfo), #0);

    StartupInfo.cb := SizeOf(StartupInfo);

    StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;

    StartupInfo.wShowWindow := SW_HIDE;

    StartupInfo.hStdOutput := hOutputFile;

    StartupInfo.hStdInput := hInputFile;



    { create the app }

    Result := CreateProcess(

    NIL, { pointer to name of executable module }

    pCommandLine, { pointer to command line string }

    NIL, { pointer to process security attributes }

    NIL, { pointer to thread security attributes }

    TRUE, { handle inheritance flag }

    HIGH_PRIORITY_CLASS, { creation flags }

    NIL, { pointer to new environment block }

    NIL, { pointer to current directory name }

    StartupInfo, { pointer to STARTUPINFO }

    ProcessInfo); { pointer to PROCESS_INF }



    { wait for the app to finish its job and take the handles to free them later }

    if Result then

    begin

    WaitforSingleObject(ProcessInfo.hProcess, INFINITE);

    hAppProcess := ProcessInfo.hProcess;

    hAppThread := ProcessInfo.hThread;

    end else

    raise Exception.Create(ROUTINE_ID + #10 + #10 +

    'Function failure' + #10 + #10 + ErrMsg);



    finally

    { close the handles

    Kernel objects, like the process and the files we created in this case,

    are maintained by a usage count.

    So, for cleaning up purposes we have to close the handles

    to inform the system that we don't need the objects anymore }

    if hOutputFile <> 0 then

    CloseHandle(hOutputFile);

    if hInputFile <> 0 then

    CloseHandle(hInputFile);

    if hAppThread <> 0 then

    CloseHandle(hAppThread);

    if hAppProcess <> 0 then

    CloseHandle(hAppProcess);

    { restore the old cursor }

    Screen.Cursor:= OldCursor;

    end;

    end; { CreateDOSProcessRedirected }







  • Profile
    한만택 1999.05.06 09:27
    소스는 고맙게 받았습니다.



    그런데 아직 초보라서 이해가 잘않가는데 실행화일과 소스(화일)를 올려주시면 않될찌...

    저는 3.0을 사용하고 있거든요.



    부탁드립니다. 그럼 안녕히.. 꾸벅

  • Profile
    글쎄요. 1999.05.06 18:50
    ///

    리다이렉트 콤포넌트입니다. 예제도 있구요.

    도움이 되시길...

    유즈넷에서 퍼 온 것임.

    PK

  • Profile
    글쎄요. 1999.05.06 18:56
    ZiP파일이 업로드 안 되네요...

    • 이정욱
      1999.05.07 16:50
      쩝.. 질문을 이해를 못하겠네요... 조금 더 자세한 질문을 올려주세요. 장영선 wrote: > 지금 제가 ...
    • 김봉재
    • 1999.05.06 19:09
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 1999.05.06 19:43
      김봉재 wrote: > 라이브러리를 설치한 순서는 다음과 같습니다... > > 1. RXCTL4.DPK를 읽어서 Compile...
    • 김봉재
      1999.05.06 23:39
      한 wrote: > 김봉재 wrote: > > 라이브러리를 설치한 순서는 다음과 같습니다... > > > > 1. RXCTL4.D...
    • 강동희
    • 1999.05.06 18:34
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.06 18:48
      컴포넌트 생성시 Create 콘스트럭터에서 AOwner를 이용하시면 됩니다. (AOwner as TForm).Left 와 (AOwner...
    • 이정욱
      1999.05.06 18:40
      나이렉스(http://www.nilex.net)의 팁게시판에 가시면 있습니다. '깜빡'이라는 단어로 검색해 보세요. 보...
    • 이호선
    • 1999.05.06 17:55
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.06 18:36
      에구.. 죄송하지만 LightLib의 제품군들은 Luxent사에서 이제 더 이상 안나올것이라고 하네요. 즉, 없어진 ...
    • 정인철
      1999.05.06 18:32
      유수 wrote: > 안녕하세요. > > DBGrid에 TQuery(Query1)를 연결 시켜 놨습니다. > > TQuery에는...
    • 유수
      1999.05.07 00:14
      답변 감사합니다. 델파이를 쓴지는 오래되었는데, DB를 시작한지 얼마 되지 않아, 어려움이 많습니다...
    • 안명호
    • 1999.05.06 06:24
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      1999.05.06 06:32
      안명호 wrote: > 메모 박스에서 상속 받은 컴포넌트엔 Perform 메소드가 > 있는걸로 알고 있습니다. > ...
    • 안명호
    • 1999.05.06 06:22
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      1999.05.06 06:28
      안명호 wrote: > 리치 에디트 박스의 삽입/수정 상태을 알기 위해서 > 다음과 같은 코딩을 하였습니다. ...
    • sonny7
    • 1999.05.06 04:57
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      1999.05.06 06:04
      sonny7 wrote: > 기본적으로 델파이 1.0에서는 에디트박스가 좌측정렬만 되고 > > 우측정렬이 Object I...
    • 한만택
    • 1999.05.06 04:40
    • 4 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      1999.05.06 05:58
      한만택 wrote: > 안녕하세요... > 궁금한게 있어서 이렇게 씁니다. > 질문: 도스에 나타난 글은 메모장...
    • 한만택
      1999.05.06 09:27
      소스는 고맙게 받았습니다. 그런데 아직 초보라서 이해가 잘않가는데 실행화일과 소스(화일)를 올려주시...
    • 글쎄요.
      1999.05.06 18:50
      /// 리다이렉트 콤포넌트입니다. 예제도 있구요. 도움이 되시길... 유즈넷에서 퍼 온 것임. PK
    • 글쎄요.
      1999.05.06 18:56
      ZiP파일이 업로드 안 되네요...
    • 김영애
    • 1999.05.06 04:30
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 하윤철
      1999.05.06 18:39
      소계낼때... QRExpr.Expression의 Function 중에 SUM(필드) 쓰셨지요. 그 바로 아래에 Count(필드)가 있습...
    • 정재균
      1999.05.08 01:22
      게임방 관리 프로그램은 일종의 네트워 관리 프로그램과 유사한 형태를 갖습니다. 즉 클라이언트/서버 구...
    • 구창민
      1999.05.06 06:24
      김진영 wrote: > 델파이 공부를 시작 한지 얼마 되지 않았습니다.. > 정말 초보단계에요.. > 그런데 게...
    • Heaven
    • 1999.05.05 13:30
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      1999.05.06 06:20
      Heaven wrote: > 안녕하세요? > 질문이 있습니다. > > 제가 마스터/디테일 관계의 데이타베이스 프로...
    • 이상철
    • 1999.05.05 06:04
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      1999.05.06 06:10
      이상철 wrote: > 안녕하세요 델파이 를 무지 좋아하는 상철입니당 > 소스는 정확히 몰르구요 하지만 대충...
    • 강경중
    • 1999.05.05 04:14
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 1999.05.05 06:23
      강경중 wrote: > 저는 네트웍 체팅 프로르램을 짤려고 하는 초보 델피언 입니다. > 채팅 클라이언트가 실...
    • 고혜정
    • 1999.05.05 03:58
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 신인재
      1999.05.05 05:08
      음냐 이것은 약간의 꽁수가 필요하네요...하지만 무지 간단해요... QRShape를 이용하는 방법인데 이것...
    • 김영해
      1999.05.05 06:34
      신인재 wrote: > 음냐 이것은 약간의 꽁수가 필요하네요...하지만 무지 간단해요... > > QRShape를 이...
    • 이호선
    • 1999.05.05 02:24
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.06 11:46
      LightLib의 Image를 말씀하시는것입니까? 그렇다면 그것보다는 ImageLib를 추천해 드립니다. LightLib의 ...
    • 안치봉
      1999.05.05 02:28
      왕초보 wrote: > 프로젝트를 진행할때 필요에 따라 새로운 폼을 만들고 저의 경우에는 > 폼 레벨에서 fon...
    • 배재민
    • 1999.05.05 00:28
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 신인재
      1999.05.05 04:36
      아래의 내용을 살펴보니.. try ...finally.. 의 사용에 대해 이해가 조금 부족한듯 싶습니다. finall...
    • 하윤철
      1999.05.05 00:45
      송수정 wrote: > 델파이 3.0을 쓰고 있습니다. > DB에 있는 내용을 레포트로 출력하고자 할때 > 퀵레...