EvilZone

Programming and Scripting => C - C++ => Topic started by: imation on January 10, 2012, 08:28:22 PM

Title: C - Get Window title - small code
Post by: imation on January 10, 2012, 08:28:22 PM
Code: [Select]
#include <stdio.h>
#include <string.h>
#include <windows.h>

char szCurTitle[1024],szLastTitle[1024];


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     char*    lpCmdLine,
                     int       nCmdShow)
{
                     
          // Get title of window
        HWND hWnd = GetForegroundWindow(); //get a handle on the current window
        GetWindowText (hWnd,szCurTitle,sizeof(szCurTitle));
          // Titles were different so update the log file and the last title
         printf("%s\n",szCurTitle);
       
       
  char* str2 = "Google";
  char* result = strstr(szCurTitle,str2);
  if( result == NULL ) printf( "Could not find '%s' in '%s'\n",str2,szCurTitle);
  else printf( "Found a substring: '%s'\n", result );
  return 0;
}