2011-07-21 28 views
0

我只是想知道爲什麼這段代碼不工作?FindWindow不工作?

HWND hWnds = FindWindow(NULL,(LPCTSTR)"Calculator"); 

它總是返回NULL的hWnds ....

任何想法如何解決這一問題?謝謝:)

+1

不要施放,使用L 「計算器」。 –

回答

4

不要投下字符串。

HWND hWnds = FindWindow(NULL,_T("Calculator")); 
+0

我已經試過上面的代碼,我想知道爲什麼我一直得到這個錯誤? 1> c:\ users \ owner \ documents \ visual studio 2008 \ projects \ invoke \ invoke \ invoke.cpp(59):error C3861:'_T':找不到標識符 – zia

+0

頂部有'#include ' ? –

+0

是的,我確實.....?我想知道我錯過了什麼? – zia

0

製作一個名爲'計算器'的文件夾並使用Windows資源管理器進入它。

現在運行你的程序 - 錯誤的窗口句柄將被返回!

在Windows 7使用間諜++,我發現類名計算器窗口是:CalcFrame

嘗試使用這樣的:

HWND hWnds = FindWindow(_T("CalcFrame"), NULL);