-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateProcessFromSystem.cpp
71 lines (63 loc) · 1.88 KB
/
CreateProcessFromSystem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// CreateProcessFromSystem.cpp : 定义应用程序的入口点。
//
#include "framework.h"
#include "CreateProcess.h"
#include "SelectFolderDlg.h"
#include "CreateProcessFromSystem.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
if (!CreateProcess::IsProcessRunAsAdmin()) {
CreateProcess::RunAsAdmin();
exit(0);
}
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, WndProc);
return 0;
}
INT_PTR CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CLOSE:
EndDialog(hWnd, 0);
break;
case WM_COMMAND:
{
int wmId = LOWORD(wParam);
// 分析菜单选择:
switch (wmId)
{
case ID_OK:
{
HWND hEdit = FindWindowEx(hWnd, NULL, "Edit", NULL);
char filePath[MAX_PATH] = { 0 };
if (hEdit != nullptr) {
GetWindowText(hEdit, filePath, MAX_PATH);
CreateProcess::CreateProcessFromParent(filePath);
}
break;
}
case ID_SELECT:
{
HWND hEdit = FindWindowEx(hWnd,NULL,"Edit", NULL);
string filePath = CSelectFolderDlg::SelectFile();
if (hEdit != nullptr) {
SetWindowText(hEdit, filePath.c_str());
}
break;
}
default:
break;
}
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
break;
}
return 0;
}