#include "stdafx.h"
#include "windows.h"

#include "CommonSetup.h"


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,                
                     int       nCmdShow)

{
	int bIsNeedReboot;
    HINSTANCE hDll;
    proc *Action;

	hDll=LoadLibrary("Setup.dll");
	if(hDll == NULL)
	{
		MessageBox( NULL, "Can not find setup.dll", "Infomation", MB_OK | MB_ICONWARNING );
		return 0 ;
	}

	Action=(proc *)GetProcAddress(hDll,"Action");
	if (Action == NULL)
	{
		if (hDll)
			FreeLibrary(hDll) ;
		MessageBox( NULL, "Can't get function address", "Infomation", MB_OK | MB_ICONWARNING );
		return 0 ;
	}

	if((*Action)("/ishaveinst/B5DD8C72-B63B-4ee1-A023-FD13A8FE8F42_Rockey200051221"))
	   {
		MessageBox( NULL, "Begin to uninstall", "Infomation", MB_OK | MB_ICONWARNING );
		bIsNeedReboot=(*Action)("/uninstall/B5DD8C72-B63B-4ee1-A023-FD13A8FE8F42_Rockey200051221");
		if(bIsNeedReboot==0)  
			MessageBox( NULL, "Uninstall Successed,you needn't restart your computer!", "Infomation", MB_OK | MB_ICONWARNING );
		else
			MessageBox( NULL, "Uninstall Successed,you need restart your computer!", "Infomation", MB_OK | MB_ICONWARNING );
	}
	else
	   {
		MessageBox( NULL, "Begin to install", "Infomation", MB_OK | MB_ICONWARNING );

		bIsNeedReboot=(*Action)("/install/2/B5DD8C72-B63B-4ee1-A023-FD13A8FE8F42_Rockey200051221");
		if(bIsNeedReboot==0)
			MessageBox( NULL, "Install Successed,you needn't restart your computer!", "Infomation", MB_OK | MB_ICONWARNING );
		
		else
			MessageBox( NULL, "Install Successed,you need restart your computer!", "Infomation", MB_OK | MB_ICONWARNING );		
	}

	if (hDll)
		FreeLibrary(hDll) ;

    return 0;             
}






