Beispiel #1
0
int PASCAL far WinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPSTR pszCommandLine,
                       int nCmdShow)
{
   int nResult = 0;

   // Establish our global environment.

   m_hInstance = hInstance;

   // Compute our working variables.

   if (SetWorkingVariables(pszCommandLine))
   {
      nResult = RunInstall(Is32BitEnvironment(), pszCommandLine);
   }
   return nResult;
}
Beispiel #2
0
int PASCAL far WinMain(HINSTANCE hInstance,
							  HINSTANCE hPrevInstance,
							  LPSTR lpCmdLine,
							  int nCmdShow)
{
	REGRESULT Result = REGRESULT_Error;
	
/*
// Establish our global environment.
*/

	m_hInstance = hInstance;

/*
// Compute our working variables.
*/

	SetWorkingVariables();

/*
// See if a previous instance is running.
// We use this generic method since hPrevInstance is unusable under 32 bits.
// We need the window anyway, so we just do it.
//
// If we find a window and it has a last active popup, we use it.
// If there is no window, then we just proceed on, being the first.
// If there is a window, but it has no last active popup, then the previous
// instance has spawned its MSFREE component and is waiting. We pass control
// down again to allow the code to bring THAT window to the front.
*/

	HWND hPrevWnd;

	if ((hPrevWnd = FindWindow("MSREGR", m_szWindowTitle)) != NULL)
	{
		HWND hWndLastActive = GetLastActivePopup(hPrevWnd);

		if ((hWndLastActive != NULL) && (hWndLastActive != hPrevWnd))
		{
			if (IsIconic(hPrevWnd))
			{
				ShowWindow(hPrevWnd, SW_SHOWNORMAL);
			}
			else
			{
#ifdef WIN32
				SetForegroundWindow(hPrevWnd);
#endif
				BringWindowToTop(hPrevWnd);
#ifdef WIN32
				SetForegroundWindow(hWndLastActive);
#endif
				BringWindowToTop(hWndLastActive);
			}
			return 0;
		}
	}

/*
// Give ourselves a window so we can show an icon.
*/

	if (hPrevInstance == NULL)
	{
		WNDCLASS wc;
		wc.style = CS_HREDRAW | CS_VREDRAW;
		wc.lpfnWndProc = DefWindowProc;
		wc.cbClsExtra = 0;
		wc.cbWndExtra = 0;
		wc.hInstance = m_hInstance;
		wc.hIcon = LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_MSRUN));
		wc.hCursor = NULL;
		wc.hbrBackground = NULL;
		wc.lpszMenuName = NULL;
		wc.lpszClassName = "MSREGR";
		
		RegisterClass(&wc);
	}

	HWND hWnd = NULL;
	
	hWnd = CreateWindow(
		"MSREGR",
		m_szWindowTitle,
		WS_OVERLAPPED,
		0,
		0,
		GetSystemMetrics(SM_CXSCREEN),
		GetSystemMetrics(SM_CYSCREEN),
		HWND_DESKTOP,
		NULL,
		m_hInstance,
		NULL);
		
/*
// Load the library.
*/

	char cbLibraryName[_MAX_PATH];

	lstrcpy(cbLibraryName, m_szWorkingDirectory);
#ifdef WIN32
	lstrcat(cbLibraryName, "MSREG32.DLL");
#else
	lstrcat(cbLibraryName, "MSREG16.DLL");
#endif

	UINT wOldSem = SetErrorMode(SEM_NOOPENFILEERRORBOX);
	HINSTANCE hLibrary = LoadLibrary(cbLibraryName);
	SetErrorMode(wOldSem);

#ifndef WIN32
	if ((UINT)hLibrary < (UINT)HINSTANCE_ERROR)
	{
		hLibrary = NULL;
	}
#endif

	if (hLibrary != NULL)
	{
	/*
	// Get the entry point.
	*/

#ifdef WIN32
		FN_REGSENDCOMMAND pRegSendCommand = (FN_REGSENDCOMMAND)GetProcAddress(hLibrary, "RegSendCommand");
#else
		FN_REGSENDCOMMAND pRegSendCommand = (FN_REGSENDCOMMAND)GetProcAddress(hLibrary, "REGSENDCOMMAND");
#endif

		if (pRegSendCommand != NULL)
		{
			Result = pRegSendCommand(hWnd, REGCOMMAND_Register " /C /A", 0, NULL);
		}

		FreeLibrary(hLibrary);
	}

   if (hWnd != NULL)
   {
		DestroyWindow(hWnd);
	}

	return (int)Result;
}