-
哄骗WindowsApi及文件操纵实现把握指定窗口的Enable Or Not
添加时间:2013-7-22 点击量:1.后台把握文件的设计
1 //后台把握设计.
2 #include<iostream>
3 #include<fstream>
4 #include<windows.h>
5 using namespace std;
6
7 int main()
8 {
9 system(title 监控后台---中国深点科技);
10 system(color a);
11 system(taskkill /im kill.exe /f );
12 char title[MAX_PATH];
13 cout<<\n\n 请输入须要监控的窗体题目名称(重视大小写):;
14 cin>>title;
15 ofstream out_file1(c:\\windows\\title1.txt);
16 if(!out_file1)
17 {
18 cout<<\n\n文件设备失败!\n\n;
19 out_file1.close();
20 }
21 else
22 {
23 out_file1<<title;
24 out_file1.close();
25 ofstream out_file2(c:\\windows\\title2.txt);
26 if(!out_file2)
27 {
28 cout<<\n\n文件设备失败!\n\n;
29 out_file2.close();
30 }
31 else
32 {
33 for(int i=2;i<=8;i++)
34 {
35 out_file2<<title<<等;
36 out_file2<<i<<个会话\n;
37
38 }
39 out_file2.close();
40 cout<<文件设备成功!\n\n;
41 cout<<监控在三秒后启动...\n\n;
42 Sleep(3000);
43 HINSTANCE open;
44 open=Shellute(NULL,TEXT(open),TEXT(kill.exe),NULL,NULL,SW_HIDE);
45 if(open)
46 {
47 cout<<监控启动成功!\n\n;
48 }
49 else
50 {
51 cout<<监控启动失败!\n\n;
52 }
53
54 }
55 }
56
57 system(pause);
58 return 0;
59 } 实验截图1.
2.主把握文件代码设计
1 //主文件.
2 #include<iostream>
3 #include<windows.h>
4 #include<string>
5 #include<fstream>
6 using namespace std;
7
8 int main()
9 {
10 char title[MAX_PATH];
11 DWORD titlelen=0;
12 HANDLE filein;
13 filein=CreateFile(
14 TEXT(c:\\windows\\title1.txt),
15 GENERIC_READ,
16 0,
17 NULL,
18 OPEN_ALWAYS,
19 FILE_ATTRIBUTE_NORMAL,
20 NULL);
21 if(filein==0)
22 {
23 cout<<获取设备文件失败,请先运行[ Control.exe ]\n;
24 system(pause);
25 return 0;
26 }
27 else
28 {
29 bool result;
30 result=ReadFile(
31 filein,
32 title,
33 60,
34 &titlelen,
35 NULL);
36 if(result)
37 {
38 CloseHandle(filein);
39
40 LPSTR name;
41 start: HWND win;
42 ifstream infile(c:\\windows\\title1.txt,ios::in);
43 infile>>title;
44 name=(LPSTR)title;
45 win=FindWindow(NULL,name);
46 if(win)
47 {
48 ShowWindow(win,SW_HIDE);
49 EnableWindow(win,FALSE);
50 cout<<OK;
51
52
53 }
54
55 ifstream infile2(c:\\windows\\title2.txt,ios::in);
56 for(int a=1;a<=8;a++)
57 {
58 infile2>>title;
59 name=(LPSTR)title;
60 //cout<<name<<\n;
61 win=FindWindow(NULL,name);
62 if(win)
63 {
64 if(ShowWindow(win,SW_HIDE))
65 {
66 EnableWindow(win,FALSE);
67 //cout<<把握成功!\n;
68 }
69 else
70 {
71 // cout<<把握失败!;
72 }
73
74 }
75
76 }
77 Sleep(3000);
78 infile.close();
79 infile2.close();
80 goto start;
81
82 }
83
84
85
86 }
87
88 return 0;
89 }3.窗口解锁文件代码设计
1 #include<iostream>
2 #include<windows.h>
3 using namespace std;
4
5 int main()
6 {
7 system(color a);
8 system(title 解锁操纵---中国深点科技);
9 HWND win;
10 char name[MAX_PATH];
11 start:
12 system(taskkill /im kill.exe /f );
13 cout<<\n\n 请输入须要解锁的窗口名(重视大小写):;
14 cin>>name;
15 win=FindWindow(NULL,(LPSTR)name);
16 if(win)
17 {
18 cout<<\n创建句柄成功!\n;
19 if(EnableWindow(win,TRUE))
20 {
21 cout<<\n解锁完成!\n;
22 }
23 else
24 {
25 cout<<\n解锁失败!\n;
26 }
27 }
28 else
29 {
30 cout<<\n创建句柄失败!\n;
31 }
32 system(pause);
33 goto start;
34 return 0;
35 } 实验截图2