Sup Guys,
I just need help breaking down and help me understand this code.
What this program does: Hides the window without a trace and shows the window when the user feels like it.(To put it simply).
I made a similar program like this before but it had lots of bugs(like it's crazy).
I was able to make my program hide it but I couldn't bring it back.
If you can explain it to me, I would really appreciate it.
Thanks,
MassCoder(1st Post)
I just need help breaking down and help me understand this code.
Code:
#include <iostream>
#include <windows.h>
char g_szWindowTitle[MAX_PATH];
BOOL CALLBACK EnumWindowsProc(HWND hWindow, LPARAM lParam)
{
if(hWindow != NULL)
{
if(lParam != NULL)
{
char szLocalTitle[MAX_PATH];
GetWindowTextA( hWindow, szLocalTitle, MAX_PATH );
if(strstr(szLocalTitle, (const char*)lParam ) != NULL )
{
if(GetWindowLong(hWindow, GWL_STYLE) & WS_VISIBLE)
ShowWindow( hWindow, SW_HIDE );
else
ShowWindow( hWindow, SW_SHOW );
}
}
}
return TRUE;
}
void Thread_Hide()
{
while(1)
{
if(GetStdHandle( STD_INPUT_HANDLE ) != INVALID_HANDLE_VALUE )
{
printf("\n Enter window title to hide: ");
fgets( g_szWindowTitle, MAX_PATH, stdin );
g_szWindowTitle[ strlen( g_szWindowTitle ) - 1] = '\0';
if(strstr(g_szWindowTitle, "current") != NULL)
GetWindowTextA(GetForegroundWindow(), g_szWindowTitle, MAX_PATH );
else if(!stricmp(g_szWindowTitle, "quit"))
ExitProcess( 0 );
EnumWindows( (WNDENUMPROC)&EnumWindowsProc, (LPARAM)g_szWindowTitle );
}
Sleep(50);
}
}
int main(int argc, char **argv)
{
WaitForSingleObject( CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)&Thread_Hide, 0, 0, 0), INFINITE);
return 0;
}
What this program does: Hides the window without a trace and shows the window when the user feels like it.(To put it simply).
I made a similar program like this before but it had lots of bugs(like it's crazy).
I was able to make my program hide it but I couldn't bring it back.
If you can explain it to me, I would really appreciate it.
Thanks,
MassCoder(1st Post)

