谁能帮我把这个用win32的WriteProcessMemory函数用BCB编的代码转换成C#的代码啊
以下是BCB代码:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <windows.h>
#include <iostream>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
using namespace std;
LONG address = 0x438CE9;
BYTE newvalue[] = {0x1};
BYTE newvalue2[] = {0x12};
HWND hwnd;
HANDLE phandle;
DWORD pid;
LONG data=1000000;
LONG readdata=0;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
hwnd = FindWindow(NULL, "Form2");
if (hwnd != 0)
{
GetWindowThreadProcessId(hwnd, &pid);
phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
}else
{
//cout << "Could not find the window.";
//cin.get();
return;
}
if (phandle != 0)
{
WriteProcessMemory(phandle, (LPVOID)address, (LPVOID)&newvalue[0], 2, NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
newvalue[0]=newvalue[0]+1;
if (phandle != 0)
{
//Edit1->Text=(BYTE) newvalue[0];
WriteProcessMemory(phandle, (LPVOID)(0x438CE9), (LPVOID)&newvalue[0], 2, NULL);
}
}
请帮我填到如下的C#代码中:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
namespace WriteProcess
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}