현재 드라이브의 최상위 디렉토리에 있는 test.exe 파일을 실행
01: #include "stdafx.h"
02: #include <stdio.h>
03: #include <direct.h>
04: #include <shellapi.h>
05:
06: int APIENTRY WinMain(HINSTANCE hInstance,
07: HINSTANCE hPrevInstance,
08: LPSTR lpCmdLine,
09: int nCmdShow)
10: {
11: int curDrive;
12: char exeCmd[256];
13:
14: memset(exeCmd, NULL, sizeof(exeCmd));
15:
16: // 현재 드라이브 할당
17: curDrive = _getdrive();
18:
19: // Execute current drive:\test.exe
20: sprintf(exeCmd, "%c:\\test.exe", curDrive+'a'-1);
21: ShellExecute(NULL, "open", exeCmd, NULL, NULL, NULL);
22:
23: return 0;
24: }
'Code review' 카테고리의 다른 글
[C]file divide (0) | 2009.05.27 |
---|---|
[WinApi]CreateFile() (0) | 2009.05.27 |
[C]배열과 포인터 - ''[]''의 의미와 사용예 (0) | 2009.05.27 |