RT

解决方案 »

  1.   

    使用toolhelp函数族
    先CreateToolhelp32Snapshot
    然后Process32First
    得到 PROCESSENTRY32 结构
      

  2.   

    TCHAR sFilename[MAX_PATH];GetModuleFileName(AfxGetInstanceHandle(), sFilename, MAX_PATH);sFilename中即是本进程的完整路径名称
      

  3.   

    const int MAX_SIZE = 100;extern HWND        g_hWndFind[MAX_SIZE];
    extern int         g_iWndIndex;>>>>>>>>>>>>>>>>>>>>>>>>>>
    HWND        g_hWndFind[MAX_SIZE];
    int         g_iWndIndex;>>>>>>>>>>>>>>>>>>>>>>>>>>>static BOOL WINAPI EnumWindowsProc(HWND hWnd, LPARAM lParam);>>>>>>>>>>>>>>>>>>>>>>>>>>
    BOOL CDlg::EnumWindowsProc(HWND hWnd, LPARAM lParam)
    {
    if(::GetWindowLong(hWnd,GWL_STYLE)& WS_VISIBLE)
    {
    g_hWndFind[g_iWndIndex] = hWnd;//record the HWND handle into array
    g_iWndIndex++;//count start
    }
    return TRUE;
    }>>>>>>>>>>>>>>>>>>>>>>>>>>>> m_strList.ResetContent();
    ::EnumWindows(CEmulateWindowDlg::EnumWindowsProc,NULL); HWND hProcess = NULL;
    TCHAR chClassName[MAX_PATH];

    for(int  i = 0; i < g_iWndIndex; i++)
    {
    TCHAR tcName[MAX_PATH];
    hProcess = g_hWndFind[i];
    ::GetWindowText(hProcess,tcName,MAX_PATH);
    m_strList.AddString(tcName);
    }
      

  4.   

    ZeroMemory(&g_hWndFind,sizeof(g_hWndFind));
    g_iWndIndex = 0;