/*
*********************************************************************
*
*	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 "resource.h"

#import "hello32.tlb" no_namespace

IDHelloPtr pHello ;

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


int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
	MSG msg ;   

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

/*
Create the driver object based on COM's smart pointer classes generated
by the #import directive.
*/


	HRESULT hr = pHello.CreateInstance (__uuidof(HelloApplication)) ;

	if (hr != S_OK)
	{
		char out [256] ;
		wsprintf (out, "Couldn't create object, hr == 0x%x", hr) ;
		MessageBox (NULL, out, "", 0) ;
	}

/*
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 msg.wParam;
}
