0

I just want to know why this code is not working?

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

It always returns NULL for the hWnds....

Any idea how to fix this? Thank you :)

zia
  • 117
  • 3
  • 7

2 Answers2

4

Dont cast the string.

HWND hWnds = FindWindow(NULL,_T("Calculator"));
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
0

Make a folder named 'Calculator' and enter into it using Windows Explorer.

Now run your program - wrong window handle would be returned!

Using Spy++ on Windows 7, I found out class-name of Calculator window to be: CalcFrame.

Try using this:

HWND hWnds = FindWindow(_T("CalcFrame"), NULL);
Ajay
  • 18,086
  • 12
  • 59
  • 105