HWND Focus=GetForegroundWindow();
char title[MAX_PATH]={0};
GetWindowText(Focus, title, sizeof(title));
if (strcmp(title,"")==0) //与if(strlen(title)==0)相比哪一句的效率高些?好像是strcmp
{
printf("空");
}
CloseHandle(Focus); //这一句需要么,应该不需要?应该不可能关得掉的
char title[MAX_PATH]={0};
GetWindowText(Focus, title, sizeof(title));
if (strcmp(title,"")==0) //与if(strlen(title)==0)相比哪一句的效率高些?好像是strcmp
{
printf("空");
}
CloseHandle(Focus); //这一句需要么,应该不需要?应该不可能关得掉的
解决方案 »
- 连接超时的问题(难道我的机子 牛了, 从来没有链接超时的这个问题)
- Tab Control 控件显示不出插入的对话框
- textbox通过模糊查询 直接控制listctrl的显示 VC++
- 为什么我的工程选择了Win32 Debug模式却总是自动变成Win32 Release模式,搞的不能跟踪看执行情况。
- wdm过虑驱动
- CArray(type, type)和CArray(type, type&)有何区别??(解决马上给分)
- 求高手解答MFC appwizard 和 win32 console application的区别
- vc经典的源码网站是那个,我忘了,麻烦请告知!谢了
- MFC用FindWindow返回值一直是NULL
- 有关VC使用ADO的问题!
- 十六进制转十进制(只有这么多分了,肯定结贴)
- 手机版视频监控系统设计方案可行性分析
看MSDN:The CloseHandle function closes handles to the following objects:Access token
Communications device
Console input
Console screen buffer
Event
File
File mapping
Job
Mailslot
Memory resource notification
Mutex
Named pipe
Pipe
Process
Semaphore
Socket
Thread
Waitable timer
{
printf kong
}
用 title[0]=0;更高效。
然后就是如jennyvenus在二楼的代码或者:
if(!title[0])呵呵
HWND Focus=GetForegroundWindow();
char title[MAX_PATH];
*title=0;if( !GetWindowText(Focus, title, sizeof(title)) )
{
printf("空");
}