Exemple #1
0
/******************************************************************************
*   LoadTypeInfo -- Gets the type information of an object's interface from the
*   type library.  Returns S_OK if successful.
******************************************************************************/
STDMETHODIMP RTDServer::LoadTypeInfo(ITypeInfo** pptinfo, REFCLSID clsid,
                                     LCID lcid)
{
    HRESULT hr;
    LPTYPELIB ptlib = NULL;
    LPTYPEINFO ptinfo = NULL;
    *pptinfo = NULL;

    // First try to load the type info from a registered type library
    hr = LoadRegTypeLib(LIBID_RTDServerLib, 1, 0, lcid, &ptlib);
    if (FAILED(hr)) {
        //can't get the type information
        return hr;
    }

    // Get type information for interface of the object.
    hr = ptlib->GetTypeInfoOfGuid(clsid, &ptinfo);
    if (FAILED(hr))
    {
        ptlib->Release();
        return hr;
    }
    ptlib->Release();
    *pptinfo = ptinfo;
    return S_OK;
}
HRESULT CoFoldersMonitor::LoadTypeInfo(ITypeInfo **ppTypeInfo, const CLSID &libId,
									   const CLSID &iid, LCID lcid)
{
	HRESULT hr;
	LPTYPELIB ptlib = nullptr;
	LPTYPEINFO ptinfo = nullptr;

	*ppTypeInfo = nullptr;

	// Load type library.
	hr = ::LoadRegTypeLib(libId, g_majorVer, g_minorVer, lcid, &ptlib);
	if (FAILED(hr))
	{
		com::Trace(L"[%s] : LoadRegTypeLib failed ! (%d)", hr);
		return hr;
	}

	// Get the information for the interface of the object.
	hr = ptlib->GetTypeInfoOfGuid(iid, &ptinfo);
	if (FAILED(hr))
	{
		com::Trace(L"[%s] : GetTypeInfoOfGuid failed ! (%d)", hr);
		ptlib->Release();
		return hr;
	}

	ptlib->Release();
	*ppTypeInfo = ptinfo;

	return NOERROR;
}
Exemple #3
0
BOOL AFXAPI AfxOleRegisterTypeLib(HINSTANCE hInstance, REFGUID tlid,
	LPCTSTR pszFileName, LPCTSTR pszHelpDir)
{
	USES_CONVERSION;

	BOOL bSuccess = FALSE;
	CString strPathName;
	TCHAR *szPathName = strPathName.GetBuffer(_MAX_PATH);
	::GetModuleFileName(hInstance, szPathName, _MAX_PATH);
	strPathName.ReleaseBuffer();
	LPTYPELIB ptlib = NULL;

	// If a filename was specified, replace final component of path with it.
	if (pszFileName != NULL)
	{
		int iBackslash = strPathName.ReverseFind('\\');
		if (iBackslash != -1)
			strPathName = strPathName.Left(iBackslash+1);
		strPathName += pszFileName;
	}

	if (SUCCEEDED(LoadTypeLib(T2COLE(strPathName), &ptlib)))
	{
		ASSERT_POINTER(ptlib, ITypeLib);

		LPTLIBATTR pAttr;
		GUID tlidActual = GUID_NULL;

		if (SUCCEEDED(ptlib->GetLibAttr(&pAttr)))
		{
			ASSERT_POINTER(pAttr, TLIBATTR);
			tlidActual = pAttr->guid;
			ptlib->ReleaseTLibAttr(pAttr);
		}

		// Check that the guid of the loaded type library matches
		// the tlid parameter.
		ASSERT(IsEqualGUID(tlid, tlidActual));

		if (IsEqualGUID(tlid, tlidActual))
		{
			// Register the type library.
			if (SUCCEEDED(RegisterTypeLib(ptlib,
					T2OLE((LPTSTR)(LPCTSTR)strPathName), T2OLE((LPTSTR)pszHelpDir))))
				bSuccess = TRUE;
		}

		RELEASE(ptlib);
	}
	else
	{
		TRACE1("Warning: Could not load type library from %s\n", (LPCTSTR)strPathName);
	}

	return bSuccess;
}
Exemple #4
0
HRESULT CCmdTarget::GetTypeInfoOfGuid(LCID lcid, REFGUID guid,
	LPTYPEINFO* ppTypeInfo)
{
	USES_CONVERSION;

	AfxLockGlobals(CRIT_TYPELIBCACHE);

	HRESULT hr = TYPE_E_CANTLOADLIBRARY;
	CTypeLibCache* pTypeLibCache = GetTypeLibCache();
	LPTYPELIB pTypeLib = NULL;

	// If type info is already cached, just return it.
	if (pTypeLibCache->LookupTypeInfo(lcid, guid, ppTypeInfo))
	{
		hr = S_OK;
	}
	else
	{
		// If type library isn't already cached, try to locate it.
		if (!pTypeLibCache->Lookup(lcid, &pTypeLib))
		{
			// First, try getting the subclass to load the type library
			// (normally this goes through LoadRegTypeLib).

			if (FAILED(GetTypeLib(lcid, &pTypeLib)))
			{
				AFX_MANAGE_STATE(m_pModuleState);

				// If that failed, try loading the type library from our own
				// resources.

				TCHAR szPath[_MAX_PATH];
				GetModuleFileName(AfxGetInstanceHandle(), szPath, _MAX_PATH);

				if (FAILED(LoadTypeLib(T2COLE(szPath), &pTypeLib)))
					pTypeLib = NULL;
			}

			pTypeLibCache->Cache(lcid, pTypeLib);
		}

		// If we got a type library, extract the requested type info.
		if (pTypeLib != NULL)
		{
			hr = pTypeLib->GetTypeInfoOfGuid(guid, ppTypeInfo);
			pTypeLib->Release();
			pTypeLibCache->CacheTypeInfo(lcid, guid, *ppTypeInfo);
		}
	}

	AfxUnlockGlobals(CRIT_TYPELIBCACHE);

	return hr;
}
Exemple #5
0
// LIBID_OliverCom := IID for type library
HRESULT Sorter::loadITypeInfo()
{
	LPTYPELIB pTypeLib;

	HRESULT hr = LoadRegTypeLib( LIBID_ComSort, 1, 0, 0, &pTypeLib );

	if( SUCCEEDED(hr) )
	{
		hr = pTypeLib->GetTypeInfoOfGuid( IID_ISort, &pITypeInfo );
		if( SUCCEEDED(hr) )
		{
			pTypeLib->Release();
			pITypeInfo->AddRef();
		}
	}

	return hr;
}
Exemple #6
0
int PolylineTest::writePersistFile()
{
	ComPtr<IPolyline> pl;
	auto hr = CoCreateInstance(CLSID_PolylineObj, NULL, CLSCTX_INPROC_SERVER, IID_IPolyline, (void**)&pl);
	if (FAILED(hr)) {
		return -1;
	}
	LPTYPEINFO pTypeInfo = NULL;
	LPTYPELIB pTypelib = NULL;
	IRecordInfo* pRecInfo = NULL;
	hr = LoadRegTypeLib(LIBID_GraphicsLibrary, 1, 0, GetUserDefaultLCID(), &pTypelib);
	_ASSERT(SUCCEEDED(hr) && pTypelib);
	hr = pTypelib->GetTypeInfoOfGuid(__uuidof(PolyPoint), &pTypeInfo);
	_ASSERT(SUCCEEDED(hr) && pTypeInfo);
	hr = GetRecordInfoFromTypeInfo(pTypeInfo, &pRecInfo);
	_ASSERT(SUCCEEDED(hr) && pRecInfo);
	pTypeInfo->Release();
	pTypelib->Release();

	std::vector<POINT> points = { { 1, 2 }, { 100, 200 }, { 300, 400 } };
	auto psa = SafeArrayCreateVectorEx(VT_RECORD, 0, points.size(), pRecInfo);
	PolyPoint* pps;
	SafeArrayAccessData(psa, (void**)&pps);
	_ASSERT(psa);
	for (size_t i = 0; i < points.size(); ++i) {
		pps[i].x = points[i].x;
		pps[i].y = points[i].y;
	}
	pl->put_Points(psa);
	outputPoints(pl);

	ComPtr<IPersistFile> pf;
	pl->QueryInterface(IID_IPersistFile, (void**)&pf);
	pf->Save(kFileName, TRUE);
	pf->SaveCompleted(kFileName);
	return 0;
}
BOOL CSTEditorApp::InitInstance()
{
	HRESULT hr;
    COleMessageFilter *pFilter;
	USES_CONVERSION;

#ifdef STEDITOR_DEBUG   
    DebugBreak();
#endif

	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	hr = ::CoInitializeSecurity (NULL, -1, NULL, NULL,
	                             RPC_C_AUTHN_LEVEL_NONE, 
	                             RPC_C_IMP_LEVEL_IMPERSONATE, 
	                             NULL, EOAC_NONE, NULL);
	assert (SUCCEEDED (hr));    

    pFilter = AfxOleGetMessageFilter ();
    assert (pFilter);
    if (pFilter != NULL)
    {
        pFilter->EnableNotRespondingDialog (FALSE);
        pFilter->EnableBusyDialog (FALSE);
    };

    AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	_Module.Init (ObjectMap, m_hInstance);

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.

	SetRegistryKey (_T("Softing\\4CONTROLV2\\4CONTROL Engineering"));               // keywords are case insensitive
	
	// AUTOFMT 08.08.06 SIS >>
	InitRegistry();
	// AUTOFMT 08.08.06 SIS <<

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	m_pDocTemplate = new CMultiDocTemplate(
		IDR_STTYPE,
		RUNTIME_CLASS(CSTEditorDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CSTEditorView));
	m_pDocTemplate->SetServerInfo(
		IDR_STTYPE_SRVR_EMB, IDR_STTYPE_SRVR_IP,
		RUNTIME_CLASS(CInPlaceFrame));
	AddDocTemplate(m_pDocTemplate);

	// Connect the COleTemplateServer to the document template.
	//  The COleTemplateServer creates new documents on behalf
	//  of requesting OLE containers by using information
	//  specified in the document template.
	m_server.ConnectTemplate(clsid, m_pDocTemplate, FALSE);

	// Register all OLE server factories as running.  This enables the
	//  OLE libraries to create objects from other applications.
	COleTemplateServer::RegisterAll();
		// Note: MDI applications register all server objects without regard
		//  to the /Embedding or /Automation on the command line.

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

	// Parse command line for standard shell commands, DDE, file open
	CSTCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Check to see if launched as OLE server
	if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
	{
		// Application was run with /Embedding or /Automation.  Don't show the
		//  main window in this case.
		return TRUE;
	}

	// When a server application is launched stand-alone, it is a good idea
	//  to update the system registry in case it has been damaged.
	m_server.UpdateRegistry(OAT_DOC_OBJECT_SERVER);
	COleObjectFactory::UpdateRegistryAll();

	if (cmdInfo.m_bRegServer)
	{
		TCHAR szModule[_MAX_PATH+10];
		LPOLESTR pszModule;
		HRESULT hr;
		LPTYPELIB pTypeLib;
		USES_CONVERSION;

		::GetModuleFileName (m_hInstance, szModule, _MAX_PATH);
		pszModule = T2OLE (szModule);
		hr = LoadTypeLib (pszModule, &pTypeLib);
		if (SUCCEEDED (hr))
		{
			hr = RegisterTypeLib (pTypeLib, pszModule, NULL);
			pTypeLib->Release ();
		};

		return (FALSE);
	};

    // Prevents ProcessShellCommand from displaying
    // a message box when unregistering.
    if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
    {
        cmdInfo.m_bRunEmbedded = true;
    };

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}
HRESULT CoCOMServer::LoadTypeInfo(ITypeInfo ** pptinfo, const CLSID &libid, const CLSID &iid, LCID lcid)
{
   HRESULT hr;
   LPTYPELIB ptlib = NULL;
   LPTYPEINFO ptinfo = NULL;

   *pptinfo = NULL;
   
   // Load type library.
   hr = LoadRegTypeLib(libid, 1, 0, lcid, &ptlib);
   if (FAILED(hr))
   { // search for TypeLib in current dll
	  WCHAR buf[MAX_PATH * sizeof(WCHAR)]; // LoadTypeLibEx needs Unicode string
	  if (GetModuleFileNameW(g_hInstance, buf, _countof(buf)))
		  hr = LoadTypeLibEx(buf,REGKIND_NONE,&ptlib);
	  else // MemoryModule, search troug g_ListOfMemoryModules and use temp file to extract and load TypeLib file
	  {
		  HMEMORYMODULE hmodule = (HMEMORYMODULE)(g_hMemoryModule);
		  HMEMORYRSRC res = MemoryFindResource(hmodule,_T("TYPELIB"),MAKEINTRESOURCE(1));
		  if (!res)
			return TYPE_E_INVALIDSTATE;
		  DWORD resSize = MemorySizeOfResource(hmodule,res);
		  // Path to temp directory + our temporary file name
		  DWORD tempPathLength = GetTempPathW(MAX_PATH, buf);
		  wcscpy(buf + tempPathLength,L"AutoHotkey.MemoryModule.temp.tlb");
		  // Write manifest to temportary file
		  // Using FILE_ATTRIBUTE_TEMPORARY will avoid writing it to disk
		  // It will be deleted after LoadTypeLib has been called.
		  HANDLE hFile = CreateFileW(buf,GENERIC_WRITE,NULL,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_TEMPORARY,NULL);
		  if (hFile == INVALID_HANDLE_VALUE)
		  {
#if DEBUG_OUTPUT
			OutputDebugStringA("CreateFile failed.\n");
#endif
			return TYPE_E_CANTLOADLIBRARY; //failed to create file, continue and try loading without CreateActCtx
		  }
		  DWORD byteswritten = 0;
		  WriteFile(hFile,MemoryLoadResource(hmodule,res),resSize,&byteswritten,NULL);
		  CloseHandle(hFile);
		  if (byteswritten == 0)
		  {
#if DEBUG_OUTPUT
			  OutputDebugStringA("WriteFile failed.\n");
#endif
			  return TYPE_E_CANTLOADLIBRARY; //failed to write data, continue and try loading
		  }
                
		  hr = LoadTypeLibEx(buf,REGKIND_NONE,&ptlib);
		  // Open file and automatically delete on CloseHandle (FILE_FLAG_DELETE_ON_CLOSE)
		  hFile = CreateFileW(buf,GENERIC_WRITE,FILE_SHARE_DELETE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE,NULL);
		  CloseHandle(hFile);
	  }
	  if (FAILED(hr))
		  return hr;
   }
   // Get type information for interface of the object.
   hr = ptlib->GetTypeInfoOfGuid(iid, &ptinfo);
   if (FAILED(hr))
   {
      ptlib->Release();
      return hr;
   }
   ptlib->Release();
   *pptinfo = ptinfo;
   return NOERROR;
}
/*func*------------------------------------------------------------------------
  description:
  in :
  out:
-----------------------------------------------------------------------------*/
BOOL CGrEditorApp::InitInstance()
{
	HRESULT hr;
	HFONT hFont;
	LOGFONT logFont;
	CGdiObject *pGdiObject;
	USES_CONVERSION;

   // Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_GR_OLE_INIT_FAILED);
		return FALSE;
	}
	hr = ::CoInitializeSecurity (NULL, -1, NULL, NULL,
	                             RPC_C_AUTHN_LEVEL_NONE, 
	                             RPC_C_IMP_LEVEL_IMPERSONATE, 
	                             NULL, EOAC_NONE, NULL);
	assert (SUCCEEDED (hr));    

   // prevent the Server-Busy dialog
   COleMessageFilter *pFilter = AfxOleGetMessageFilter();
   assert (pFilter);
   if (pFilter != NULL)
   {
      pFilter->EnableNotRespondingDialog(FALSE);
      pFilter->EnableBusyDialog(FALSE);
   }

	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	_Module.Init (ObjectMap, m_hInstance);

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.

	SetRegistryKey (_T ("Softing\\4CONTROLV2\\4CONTROL Engineering"));

   int     iValue;
   CString strKey, strSec;
   strSec.LoadString(IDS_GR_REG_SECTION);

   strKey.LoadString(IDS_GR_REG_RUBBLINE);
	iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 0);
          WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue );   // set Line draw mode to rubberlines

   strKey.LoadString(IDS_GR_REG_RUBB_RECON);
	iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 1);
          WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue );   // set Line draw mode to rubberlines

   strKey.LoadString(IDS_GR_REG_ZOOMVALUE);
	iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 100);
          WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue );   // set zoom factor for 4gr

   // default sizes for element insertion
   strKey.LoadString(IDS_GR_REG_STEPSIZE);
	iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, (4<<16)+4); // <0: AutoSize:on; HiWord:X; LoWord:Y
          WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue );

    // ST actions we yes the STEditor settings ..
	WriteProfileInt    (_T ("ST"), _T ("Case"           ), 0                    );   // keywords are case insensitive
	WriteProfileInt    (_T ("ST"), _T ("Chroma"         ), 1                    );   // coloring enabled
	WriteProfileString (_T ("ST"), _T ("Background"     ), _T ("255,255,255"   ));   // background color white
	WriteProfileString (_T ("ST"), _T ("Default Text"   ), _T ("0,0,0"         ));   // text color black
	WriteProfileString (_T ("ST"), _T ("Quote"          ), _T ("128,128,128"   ));   // string color grey
	WriteProfileString (_T ("ST"), _T ("Comment"        ), _T ("0,128,0"       ));   // comment color red
	WriteProfileString (_T ("ST"), _T ("Comment Start 1"), _T ("(*"            ));   // comments start with (*
	WriteProfileString (_T ("ST"), _T ("Comment End 1"  ), _T ("*)"            ));   // comments end with *)
	WriteProfileInt    (_T ("ST"), _T ("Keep Tabs"      ), 0                    );   // tabs are not converted to spaces
	WriteProfileInt    (_T ("ST"), _T ("Show Tabs"      ), 0                    );   // tabs are not visualized
	WriteProfileInt    (_T ("ST"), _T ("Tab Size"       ), 4                    );   // tab is as wide as 4 spaces
	WriteProfileString (_T ("ST"), _T ("Keywords"       ), _T ("stkeywords.ini"));   //

	// sizeof (LOGFONT) gives you the maximum size of a LOGFONT structure.
	// CGdiObject::GetObject possibly returns less because the font name
	// at the end of the LOGFONT structure may not take the whole space
	// reserved for it.
	hFont = (HFONT)GetStockObject (ANSI_FIXED_FONT);
	pGdiObject = CGdiObject::FromHandle (hFont);
	if (pGdiObject != NULL && pGdiObject->GetObject (sizeof (LOGFONT), &logFont) != 0)
	{
		int iFontSize;
		CWindowDC dc (m_pMainWnd);

		WriteProfileString (_T ("ST"), _T ("Font Name"), A2T (logFont.lfFaceName));
		iFontSize = MulDiv (logFont.lfHeight, 72, dc.GetDeviceCaps (LOGPIXELSY));
		WriteProfileInt (_T ("ST"), _T ("Font Size"), iFontSize);
		WriteProfileInt (_T ("ST"), _T ("Font Weight"), logFont.lfWeight);
		WriteProfileInt (_T ("ST"), _T ("Font Italic"), logFont.lfItalic);
		WriteProfileInt (_T ("ST"), _T ("CharSet"), logFont.lfCharSet);
	};

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	m_pDocTemplate = new CMultiDocTemplate(
		IDR_GR_TYPE,
		RUNTIME_CLASS(CGrEditorDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CGrEditorView));
	m_pDocTemplate->SetServerInfo(
		IDR_GR_TYPE_SRVR_EMB, IDR_GR_TYPE_SRVR_IP,
		RUNTIME_CLASS(CInPlaceFrame));
	AddDocTemplate(m_pDocTemplate);

	// Connect the COleTemplateServer to the document template.
	//  The COleTemplateServer creates new documents on behalf
	//  of requesting OLE containers by using information
	//  specified in the document template.
	m_server.ConnectTemplate(clsid, m_pDocTemplate, FALSE);

	// Register all OLE server factories as running.  This enables the
	//  OLE libraries to create objects from other applications.
	COleTemplateServer::RegisterAll();
		// Note: MDI applications register all server objects without regard
		//  to the /Embedding or /Automation on the command line.

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_GR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

   // create a dummy image .. to solve the problem with DeleteTempMap in OnIdle
   m_pDummyImage = new CImageList();
   VERIFY (m_pDummyImage->Create (16, 15, TRUE, 0, 1));      
   CBitmap bm;
   bm.LoadBitmap (IDR_GR_MAINFRAME);
   m_pDummyImage->Add (&bm, RGB (192, 192, 192));

	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

	// Parse command line for standard shell commands, DDE, file open
	CSTCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Check to see if launched as OLE server
	if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
	{
		// Application was run with /Embedding or /Automation.  Don't show the
		//  main window in this case.
		return TRUE;
	}

	// When a server application is launched stand-alone, it is a good idea
	//  to update the system registry in case it has been damaged.
	m_server.UpdateRegistry(OAT_DOC_OBJECT_SERVER);
	COleObjectFactory::UpdateRegistryAll();

	if (cmdInfo.m_bRegServer)
	{
		TCHAR szModule[_MAX_PATH+10];
		LPOLESTR pszModule;
		HRESULT hr;
		LPTYPELIB pTypeLib;
		USES_CONVERSION;

		::GetModuleFileName (m_hInstance, szModule, _MAX_PATH);
		pszModule = T2OLE (szModule);
		hr = LoadTypeLib (pszModule, &pTypeLib);
		if (SUCCEEDED (hr))
		{
			hr = RegisterTypeLib (pTypeLib, pszModule, NULL);
			pTypeLib->Release ();
		};

		return (FALSE);
	};

   // Prevents ProcessShellCommand from displaying
   // a message box when unregistering.
   if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
   {
      cmdInfo.m_bRunEmbedded = true;
   };
	
   // Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}