问题描述
这是赵春生的代码要生成一个程序,如果有大量的重复代码应该可以制作成类吧?我想问下下面代码制作成类要怎写?内存地址若要放入阵列每个窗口只要回调阵列的地址能办到吗?EX:当前有三个地址0x1025040,0x1025041,0x1025042分别对应三个TextBox如何改写下面代码?privatevoidbutton_go_Click(objectsender,EventArgse){IntPtrPinballHandle;IntPtrPinballScoreAddressPointer=(IntPtr)0x1025040;//内存0x1025040中的值+0x52->PinballScoreAddressuint[]PinballScoreAddress=newuint[1];//游戏分数的内存地址uint[]PinballScoreWrite=newuint[]{0x3B94AF80};//将分数改为:999600000uint[]PinballScoreRead=newuint[1];//用来存放当前分数//"3DPinball"在“Windows任务管理器”中显示为"PINBALL.EXE",但作为//GetProcessesByName的参数使用时并不能包含扩展名".EXE"。System.Diagnostics.Process[]PinballProcessID=System.Diagnostics.Process.GetProcessesByName("PINBALL");//根据进程名获取进程IDif(PinballProcessID.Length!=0){PinballHandle=ProcessMemoryWorkApi.OpenProcess(0x1F0FFF,0,(UInt32)PinballProcessID[0].Id);//PROCESS_ALL_ACCESS=0x1F0FFFProcessMemoryWorkApi.ReadProcessMemory(PinballHandle,PinballScoreAddressPointer,PinballScoreAddress,4,(IntPtr)0);//通过指针得到PinballScoreAddressPinballScoreAddress[0]=PinballScoreAddress[0]+0x52;//PinballScoreAddress+0x52才是游戏分数的内存地址ProcessMemoryWorkApi.ReadProcessMemory(PinballHandle,(IntPtr)PinballScoreAddress[0],PinballScoreRead,4,(IntPtr)0);//当前游戏分数MessageBox.Show("当前分数为:"+PinballScoreRead[0].ToString()+"n"+"分数即将被修改成:999600000","ProcessMemoryWork_Demo");ProcessMemoryWorkApi.WriteProcessMemory(PinballHandle,(IntPtr)PinballScoreAddress[0],PinballScoreWrite,4,(IntPtr)0);//修改游戏分数ProcessMemoryWorkApi.CloseHandle(PinballHandle);}elseMessageBox.Show(""3DPinball"还没有运行吧?","ProcessMemoryWork_Demo");}
解决方案
解决方案二:
C#中所有的代码都装在类中。我反要问你,难道你有办法不把代码写在类里面么?
解决方案三:
publicclass我是类{publicvoid我是方法(){}}在项目中右键添加类即可
解决方案四:
我或许问错应该说是制作一个方法让事件回调里面的函数
解决方案五:
引用3楼的回复:
我或许问错应该说是制作一个方法让事件回调里面的函数
还是先看看书看看教学视频吧