Need help understanding this Code.

Discussion in 'Programming General' started by MassCoder, Dec 31, 2009.

Need help understanding this Code.
  1. Unread #1 - Dec 31, 2009 at 6:59 PM
  2. MassCoder
    Joined:
    Dec 31, 2009
    Posts:
    1
    Referrals:
    0
    Sythe Gold:
    0

    MassCoder Newcomer

    Need help understanding this Code.

    Sup Guys,
    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)
     
  3. Unread #2 - Jan 8, 2010 at 9:13 PM
  4. super_
    Joined:
    Dec 20, 2008
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0

    super_ Member

    Need help understanding this Code.

    shitty window hider
     
  5. Unread #3 - Mar 14, 2010 at 3:39 PM
  6. YumYumBR
    Joined:
    Jan 16, 2010
    Posts:
    376
    Referrals:
    0
    Sythe Gold:
    0

    YumYumBR Forum Addict
    Banned

    Need help understanding this Code.

    is it a corrupt script by any chance?
     
< Coding issue | I need java help please >

Users viewing this thread
1 guest


 
 
Adblock breaks this site