各位老师好,我一个项目中调用了其它进程(此程序不是我开发的,为第三方开发)这是我的错误部分的代码
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hWnd,out string lpString, int nMaxCount);
[DllImport("user32.dll")]
public static extern int GetClassName(IntPtr hWnd,out string lpString, int nMaxCount);
void StartXX()
{
...
EnumChildWindows(pro.MainWindowHandle, new EnumChildProc(EnumCP), 0);
...
}
bool EnumCP(int hwnd, IntPtr lParam)
{
string text = "";
string className = "";
int i = GetWindowText(new IntPtr(hwnd), out text, 100);
int n = GetClassName(new IntPtr(hwnd), out className, 255);
return true;
}
当执行到int n = GetClassName(new IntPtr(hwnd), out className, 255);这句的时候报异常了“未处理品AccessViolationException;尝试读取或写入受保护的内存。这通常指示其他内存已损坏。”
应该如何解决?
已经解决了,但是如何取消这个问题或者标记为已解决呢?