打开进程总是失败?

C/C++ code
HWND hWnd=::FindWindow(NULL,L"计算器");
    if(!hWnd)
    {
        AfxMessageBox(L"获取窗口句柄失败");
        return;
    }
    DWORD dwProcessId=NULL;
    ::GetWindowThreadProcessId(hWnd,&dwProcessId);
    if(!dwProcessId)
    {
        AfxMessageBox(L"获取进程ID失败");
        return;
    }
    HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS,false,dwProcessId);
    if(!hProcess)
    {
        DWORD dwErro=GetLastError();
        //TRACE("错误代码%d",dwErro);
        CString strCode;
        strCode.Format(L"打开进程失败,错误代码:%d",dwErro);
        AfxMessageBox(strCode);
        return;
    }


编译环境是 VS2008 ,在VC6.0上面可以获得!~难道2008需要别的什么?
进程的句柄总是返回 0 !!错误代码 5,有试过Administrator权限了!

作者: MyLiveIsLost   发布时间: 2011-06-13

哪一步失败的?

从你的描述看应该是最后一步,错误提示什么?

作者: matrixcl   发布时间: 2011-06-14