본문 바로가기

Programming/MFC

WinExec

WinExec

출처 큰형님의 블로그 | 큰형님
원문 http://blog.naver.com/twoeun/10292309



TheWinExecfunction runs the specified application.

//WinExec 함수는 지정된 응용프로그램을 실행시킨다

This function is provided for compatibility with 16-bit Windows. Win32-based applications should use theCreateProcessfunction.

//이 함수는 16-bit 윈도우에 적합하게 준비한다. Win32-기반 응용프로그램은 CreateProcess 함수를 사용해야한다

UINT WinExec( LPCSTRlpCmdLine,// address of command lineUINTuCmdShow// window style for new application);

Parameters

lpCmdLine
Pointer to a null-terminated character string that contains the command line (filename plus optional parameters) for the application to be executed.
//실행될 응용프로그램에 대한 명령어(파일이름을 포함한 생략할수있는 인수)를 포함하는 널종료문자열을 포인트한다
If the name of the executable file in thelpCmdLineparameter does not contain a directory path, the system searches for the executable file in this sequence:
// lpCmdLine인수가 실행가능한 이름을 경로에 포함되어있지 않으면, 시스템은 다음순서로 실행가능한 파일을 찾는다
 
  1. The directory from which the application loaded.//응용프로그램이 불려질 디렉토리
  2. The current directory.//현 디렉토리
  3. The Windows system directory. TheGetSystemDirectoryfunction retrieves the path of this directory.//윈도우 시스템 디렉토리. GetSystemDirectory 함수가 검색한 경로
  4. The Windows directory. TheGetWindowsDirectoryfunction retrieves the path of this directory.//윈도우 디렉토리.  GetSystemDirectory 함수가 검색한 경로
  5. The directories listed in the PATH environment variable.//경로환경변수안의 디렉토리 목록

 uCmdShow

Specifies how a Windows-based application window is to be shown and is used to supply thewShowWindowmember of theSTARTUPINFOparameter to theCreateProcessfunction.
//윈도우기반 응용프로그램 윈도우가 어떻게 보열질것인지를 나타내고 CreateProcess 함수에서 STARTUPINFO인수의 wShowWindow멤버를 공급하는데 사용한다
For a list of the acceptable values, see the description of thenCmdShowparameter of theShowWindowfunction.
//허용 가능한 값의 목록은 ShowWindow함수의 nCmdShow인수를 보라
 For a non-Windows – based application, the PIF file, if any, for the application determines the window state.
//윈도우기반이 아닌 응용프로그램에서, PIF파일같은, 응용프로그램에 대한 윈도우 상태를 결정한다.

Return Values

If the function succeeds, the return value is greater than 31.

If the function fails, the return value is one of the following error values:

Value Meaning
0 The system is out of memory or resources.
ERROR_BAD_FORMAT The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).
ERROR_FILE_NOT_FOUND The specified file was not found.
ERROR_PATH_NOT_FOUND The specified path was not found.

Remarks

In Win32, theWinExecfunction returns when the started process calls theGetMessagefunction or a time-out limit is reached.

//Wind32에서, WinExec함수는 시작된 프로세스가 GetMessage함수를 호출하거나 시간제약에 도달될때 리턴된다

To avoid waiting for the time out delay, call theGetMessagefunction as soon as possible in any process started by a call toWinExec.

//시간지연에 대한것을 피하려면, WinExec 호출에 의해 시작된 어떤 프로세스를 가능한 빨리 GetMessage함수로 호출하라

See Also

Processes and Threads Overview,Process and Thread Functions,CreateProcess,GetMessage,GetSystemDirectory,GetWindowsDirectory,LoadModule,ShowWindow