VC程序设置桌面的分辨率(2)
}
bool SetSolution(const HWND hwndscroll,const HWND hwndtext,const char *so1,char *so2)
{
int n_con;
char c_str[21];
char *n_po1;
char *n_po2;
if(hwndscroll==NULL||hwndtext==NULL)
return false;
if(so1==NULL||so2==NULL)
return false;
n_con=0;
while(n_con<20)
{
PostMessage(hwndscroll,WM_KEYDOWN,VK_DOWN,0);
n_con++;
}
Sleep(1000);
GetWindowText(hwndtext,c_str,20);
n_po1=strstr(c_str,so1);
n_po2=strstr(c_str,so2);
n_con=0;
while(((!n_po1||!n_po2)||(n_po1>n_po2))&&n_con<20)
{
PostMessage(hwndscroll,WM_KEYDOWN,VK_UP,0);
Sleep(1000);
GetWindowText(hwndtext,c_str,20);
n_po1=strstr(c_str,so1);
n_po2=strstr(c_str,so2);
n_con++;
}
if(n_con==20)
return false;
return true;
}
bool GetOkWindow(const HWND hwnd,const PROCESS_INFORMATION pi,HWND &hwndok)
{
DWORD d_pid;
int n_con;
if(hwnd==NULL)
return false;
n_con=0;
while(n_con<20)
{
Sleep(1000);
for(hwndok=GetWindow(GetDesktopWindow(),GW_CHILD);
hwndok;
hwndok=GetWindow(hwndok,GW_HWNDNEXT))
{
::GetWindowThreadProcessId(hwndok,&d_pid);