// FlNTsys.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Im_bas.h"
#include "MyFlTask.h"
#include "Registration.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

class CImBasDriver : public CWinApp
{
public:
	CImBasDriver();
	virtual BOOL InitInstance();

protected:
//	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CImBasDriver theApp;


//BEGIN_MESSAGE_MAP(CImBasDriver, CWinApp)
//	//{{AFX_MSG_MAP(CImBasDriver)
//	//}}AFX_MSG
//END_MESSAGE_MAP()

CImBasDriver::CImBasDriver()
{
}

BOOL CImBasDriver::InitInstance()
{

  CExecImageVersion MyVersion;


  //Settings will be stored in the registry
  SetRegistryKey( MyVersion.GetLegalTrademarks());

  return true;
}


/////////////////////////////////////////////////////////////////////////////
// The one and only FactoryLink object
MyFlTask TheFlTask( TASK_NAME, TASK_DESC);

//////////////////////////////////////////////////////////////////////
// int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
// 
// Main procedure for application
//////////////////////////////////////////////////////////////////////
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{

	int nRetCode = 0;


	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		return (nRetCode = -1);
	}

  theApp.InitInstance();

  //this is our FactoryLink body
	{

    //initialise the FactoryLink part of the task
    if (TheFlTask.Init() == GOOD)
    {

      //keep running untill we close down
      while (TheFlTask.Run( TheFlTask.GetRunMode()) == GOOD)
        ;

      //do our things to clean up
      TheFlTask.Exit();
    }
    else nRetCode = -1;
	}

  //end of application, tell OS how we did
	return nRetCode;
}


