Winapi FindWindow Problem

closed account (DEhqDjzh)
1
2
3
4
5
6
7
8
9
10
11
      if (FindWindow(NULL, "Calculator") != NULL)
		{
			
			cout << "there is a calc" << endl;
			
		}
		if (FindWindow(NULL, "Calculator") == NULL)
		{
		cout << "there is a not calc" << endl;
			
		}


When i run this code even with calculator open it says there is no calculator
I am a beginner.

Last edited on
Works for me with Win 7 and VS 2017.
What do you use ?
Here's a code snippet that prints the Title of all Windows. Have a look if you can find your calculator there.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <Windows.h>
#include <stdio.h>
#include <string.h>

BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam)
{
  char buffer[256] = {0};
  ::GetWindowTextA(hwnd, buffer, sizeof(buffer));
  if(strlen(buffer) > 0)
    printf("%s\n", buffer);

  return TRUE;
}

int main()
{
  ::EnumWindows(EnumWindowsProc, 0);
}
closed account (DEhqDjzh)
thanks it worked !
Topic archived. No new replies allowed.