2012-07-31 49 views
0

我需要知道应用程序是否正在运行其启动画面。我可以在任务栏和应用程序的标题中看到。但FindWindow不会返回有效的句柄。但是,只要应用程序在真实窗口中打开(非闪屏/带边框),FindWindow工作并返回一个有效的句柄,窗口具有完全相同的名称。FindWindow无法在启动画面上工作

我正在使用NULL ptr作为API的第一个参数。有没有其他的方法来检查一个流程/应用程序是否已经打开了他的splashscreen?这并不意味着检查流程本身,因为在启动屏幕之前需要几秒钟。

回答

0

考虑使用EnumWindows的函数,并且得到属于指定的进程

void FindProcessWindows() 
{ 
    DWORD pid; 
    /* .. */ 
    /* Get target process id */ 
    /* .. */ 
    EnumWindows(&EnumWindows, pid); 
} 

BOOL CALLBACK EnumWindows(HWND hWnd, LPARAM lParam) 
{ 
    DWORD pid; 

    if((GetWindowLong(hWnd, GWL_STYLE) & WS_VISIBLE)) 
    { 
     GetWindowThreadProcessId(hWnd, &pid); 
     if(pid == lParam) 
     { 
      /* You've found a window that belongs to the specified process */ 
     } 
    } 
} 
所有窗口