/*
*********************************************************************
*
*	The Essence of OLE
*
*	Source code sample
*
*	Copyright (c) 1996, Rolling Thunder Computing, Ipswich MA
*
*	e-mail: essence@rollthunder.com
*	CompuServe: 73540,3430
*	Web: http://www.rollthunder.com
*
*	File Name: WINMAIN.CPP
*
*	Purpose: Entry point for Hello Automation controller app
*
*********************************************************************
*/

#include <windows.h>
#include "hellodrv.h"
#include "resource.h"


HINSTANCE hInstance ;

extern BOOL CALLBACK HelloDlgProc (HWND, UINT, WPARAM, LPARAM) ;

/*
Driver object for Hello automation server.
*/

CHelloDriver chd ;

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
	hInstance = hInst ;

/*
Initialize OLE libraries.
*/
    
	OleInitialize (NULL) ;

		
/*
Call driver object's Create( ) method, which calls CoCreateInstace,
thereby waking up the server and creating the automation object.
If this method fails, app terminates. Failure is usually caused by
the registry entries pointing to the wrong places. Check the
file HELLO.REG in the parent directory to make sure its entries
are correct.
*/
	
	if (chd.Create(lpCmdLine) == FALSE)
	{
		MessageBox (NULL, TEXT("Can't hook up hellodrv"), TEXT("Error"), 0) ;
		return -1 ;
	}
	
/*
Pop up dialog box giving user interface to automation object. This 
function returns when the user clicks "OK".
*/

	DialogBox (hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC) HelloDlgProc) ;

/*
Shut down OLE libraries and exit.
*/
    
	OleUninitialize ( ) ;

    return 0 ;
}
