www.pudn.com > Process_Mo18292312142004.rar > Main.cpp


 
/******************************************************* 
 
   This file is part of Process Monitor. 
	 
   Copyright (c) 2004 by Michel van Kerkhof, ( michel000@planet.nl  http://home.wxs.nl/~wijk0550/ )            
   For more information consult the Readme file.        
                                                                                                                                                                    
   This program is free software; you can redistribute it      
   and/or modify it under the terms of the GNU          
   General Public License as published by the Free      
   Software Foundation; either version 2 of the         
   License, or (at your option) any later version.      
                                                        
   This program is distributed in the hope that it will        
   be useful, but WITHOUT ANY WARRANTY; without         
   even the implied warranty of  MERCHANTABILITY        
   or FITNESS FOR A PARTICULAR PURPOSE.  See the        
   GNU General Public License for more details.         
                                                        
   You should have received a copy of the GNU           
   General Public License along with this program;  
   if not, write to: 
   the Free Software Foundation, Inc.,         
   59 Temple Place,                                     
   Suite 330, Boston,                                   
   MA  02111-1307  USA                                  
                                                        
******************************************************* 
 
   If you like my work and you have a job for me please contact me at: michel000@planet.nl 
   
*******************************************************/ 
 
 
#include "includes.h" 
 
CWindow CWnd; 
extern NTAPIS NtApi; 
 
extern const char szWindowClass[] = "Process Monitor"; 
char szOSVersion[200]; 
 
 
 
BOOL CALLBACK AboutWndDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) 
{ 
    switch(Msg) 
    { 
	case WM_INITDIALOG: 
		break; 
	case WM_COMMAND: 
		if (LOWORD(wParam) == IDCANCEL) EndDialog(hWnd, IDOK); 
		break; 
	case WM_CLOSE: 
		EndDialog(hWnd, IDCANCEL); 
		break; 
	default: 
		return false; 
    } 
    return true; 
} 
 
 
 
int APIENTRY WinMain(HINSTANCE hInstance, 
                     HINSTANCE hPrevInstance, 
                     LPSTR     lpCmdLine, 
                     int       nCmdShow) 
{ 
	//set priority 
	SetPriorityClass(GetCurrentProcess(),PRIORITY_FOR_THIS_PROCESS); 
 
	//see if we are already running 
	HWND hWnd=FindWindow(szWindowClass,NULL); 
	if (hWnd) { 
		//if we are activate window and exit 
		ShowWindow(hWnd,SW_RESTORE); 
		SetForegroundWindow(hWnd); 
		return 0; 
	} 
 
	InitCommonControls(); 
 
	SetPrivileges(); 
 
	//get windows version 
	OSVERSIONINFO VerInfo; 
	VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 
	GetVersionEx(&VerInfo); 
	char *pOs; 
 
	if (VerInfo.dwMajorVersion == 4) { 
		if (VerInfo.dwMinorVersion == 0) { 
			if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) pOs = "95"; 
			if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) pOs = "NT"; 
		} 
		else if (VerInfo.dwMinorVersion == 10) pOs = "98"; 
		else if (VerInfo.dwMinorVersion == 90) pOs = "ME"; 
 
	} 
	else if (VerInfo.dwMajorVersion == 5) { 
		if (VerInfo.dwMinorVersion == 0) pOs = "2000"; 
		else if (VerInfo.dwMinorVersion == 1) pOs = "XP"; 
	} 
 
	if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && VerInfo.szCSDVersion[0] != 0) { 
		sprintf(szOSVersion, "Win %s (%s) (%i.%i, build %i)", pOs, VerInfo.szCSDVersion,VerInfo.dwMajorVersion, VerInfo.dwMinorVersion, VerInfo.dwBuildNumber); 
	} 
	else { 
		sprintf(szOSVersion, "Win %s (%i.%i, build %i)", pOs,VerInfo.dwMajorVersion, VerInfo.dwMinorVersion, VerInfo.dwBuildNumber); 
	} 
 
	//only for win NT 
	if (VerInfo.dwPlatformId != VER_PLATFORM_WIN32_NT) { 
		ShowError(NULL,"Can not run this programm on: %s",szOSVersion); 
		ExitProcess(-1); 
	} 
	 
	memset((void *)&NtApi,0,sizeof(NTAPIS)); 
 
	LoadApis(); 
 
	//create the main window 
	CWnd.CreateMainWindow(hInstance);	 
	 
	MSG Msg; 
 
	while(GetMessage(&Msg, NULL, 0, 0) > 0) 
	{ 
		TranslateMessage(&Msg); 
		DispatchMessage(&Msg); 
	} 
	 
	return 0; 
}