这段代码怎么写成类
这是赵春生的代码要生成一个程序, 如果有大量的重复代码
应该可以制作成类吧? 我想问下下面代码制作成类要怎写?
内存地址若要放入阵列
每个窗口只要回调阵列的地址能办到吗?
EX:
当前有三个地址 0x1025040 , 0x1025041 , 0x1025042
分别对应三个TextBox
如何改写下面代码?
--------------------编程问答-------------------- C#中所有的代码都装在类中。我反要问你,难道你有办法不把代码写在类里面么? --------------------编程问答-------------------- public class 我是类 {
private void button_go_Click(object sender, EventArgs e)
{
IntPtr PinballHandle;
IntPtr PinballScoreAddressPointer = (IntPtr)0x1025040; //内存0x1025040中的值+0x52->PinballScoreAddress
uint[] PinballScoreAddress = new uint[1]; //游戏分数的内存地址
uint[] PinballScoreWrite = new uint[] { 0x3B94AF80 }; //将分数改为:999600000
uint[] PinballScoreRead = new uint[1]; //用来存放当前分数
//"3D Pinball"在“Windows 任务管理器”中显示为"PINBALL.EXE",但作为
//GetProcessesByName的参数使用时并不能包含扩展名".EXE"。
System.Diagnostics.Process[] PinballProcessID
= System.Diagnostics.Process.GetProcessesByName("PINBALL"); //根据进程名获取进程ID
if (PinballProcessID.Length != 0)
{
PinballHandle = ProcessMemoryWorkApi.OpenProcess(0x1F0FFF, 0, (UInt32)PinballProcessID[0].Id); //PROCESS_ALL_ACCESS=0x1F0FFF
ProcessMemoryWorkApi.ReadProcessMemory(PinballHandle, PinballScoreAddressPointer, PinballScoreAddress, 4, (IntPtr)0);//通过指针得到PinballScoreAddress
PinballScoreAddress[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);
}
else
MessageBox.Show("\"3D Pinball\" 还没有运行吧?", "ProcessMemoryWork_Demo");
}
public void 我是方法()
{
}
}
在项目中右键添加类即可 --------------------编程问答--------------------
我或许问错
应该说是制作一个方法
让事件回调里面的函数 --------------------编程问答--------------------
还是先看看书 看看教学视频吧
补充:.NET技术 , C#