-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrc.cpp
More file actions
61 lines (54 loc) · 1.27 KB
/
src.cpp
File metadata and controls
61 lines (54 loc) · 1.27 KB
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
#include <Windows.h>
#include <Urlmon.h>
#include <iostream>
using namespace std;
#pragma comment(lib,"Urlmon.lib")
void Downloader()
{
TCHAR szUrl[MAX_PATH] = TEXT("https://raw.githubusercontent.com/wangkuiwu/datastructs_and_algorithm/master/pictures/graph/iterator/03.jpg");
TCHAR szFile[MAX_PATH] = TEXT("d:\\dowm.jpg");
HRESULT hResult = URLDownloadToFile(NULL, szUrl, szFile, 0, NULL);
//WinExec("d:\\mynotepad.exe", SW_SHOW);
}
int StartProcess()
{
PROCESS_INFORMATION pi = { 0 };
STARTUPINFO si = { 0 };
si.cb = sizeof(STARTUPINFO);
bool bRet = CreateProcess(TEXT("c:\\windows\\system32\\notepad.exe"), NULL, NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi);
if (false == bRet)
{
cout << "CreateProcess Error!" << endl;
return -1;
}
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
int TerminateProcess()
{
HWND hNoteWnd = FindWindow(NULL,TEXT("ɨÀ×"));
if (NULL == hNoteWnd)
{
return -1;
}
DWORD dwNotePid = 0;
GetWindowThreadProcessId(hNoteWnd,&dwNotePid);
if (0 == dwNotePid)
{
return -1;
}
HANDLE hNoteHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwNotePid);
if (NULL == hNoteHandle)
{
return -1;
}
TerminateProcess(hNoteHandle, 0);
CloseHandle(hNoteHandle);
return 0;
}
int main()
{
TerminateProcess();
system("pause");
return 0;
}