|
// DVF.cpp : main source file for DVF.exe
//
#include "stdafx.h"
#include "resource.h"
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f DVFps.mk in the project directory.
#include "initguid.h"
#include "DVF.h"
#include "DVF_i.c"
#include "DVFView.h"
#include "aboutdlg.h"
#include "ChildFrm.h"
#include "MainFrm.h"
CServerAppModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
END_OBJECT_MAP()
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
CMessageLoop theLoop;
_Module.AddMessageLoop(&theLoop);
CMainFrame wndMain;
if(wndMain.CreateEx() == NULL)
{
ATLTRACE(_T("Main window creation failed!\n"));
return 0;
}
_Module.Lock();
wndMain.ShowWindow(nCmdShow);
int nRet = theLoop.Run();
_Module.RemoveMessageLoop();
return nRet;
}
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to
// make the EXE free threaded. This means that calls come in on a random RPC thread.
// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
ATLASSERT(SUCCEEDED(hRes));
// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
::DefWindowProc(NULL, 0, 0, 0L);
AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES); // add flags to support other controls
hRes = _Module.Init(ObjectMap, hInstance);
ATLASSERT(SUCCEEDED(hRes));
AtlAxWinInit();
// Parse command line, register or unregister or run the server
int nRet = 0;
TCHAR szTokens[] = _T("-/");
bool bRun = true;
bool bAutomation = false;
LPCTSTR lpszToken = _Module.FindOneOf(::GetCommandLine(), szTokens);
while(lpszToken != NULL)
{
if(lstrcmpi(lpszToken, _T("UnregServer")) == 0)
{
_Module.UpdateRegistryFromResource(IDR_DVF, FALSE);
nRet = _Module.UnregisterServer(TRUE);
bRun = false;
break;
}
else if(lstrcmpi(lpszToken, _T("RegServer")) == 0)
{
_Module.UpdateRegistryFromResource(IDR_DVF, TRUE);
nRet = _Module.RegisterServer(TRUE);
bRun = false;
break;
}
else if((lstrcmpi(lpszToken, _T("Automation")) == 0) ||
(lstrcmpi(lpszToken, _T("Embedding")) == 0))
{
bAutomation = true;
break;
}
lpszToken = _Module.FindOneOf(lpszToken, szTokens);
}
if(bRun)
{
_Module.StartMonitor();
hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
ATLASSERT(SUCCEEDED(hRes));
hRes = ::CoResumeClassObjects();
ATLASSERT(SUCCEEDED(hRes));
if(bAutomation)
{
CMessageLoop theLoop;
nRet = theLoop.Run();
}
else
{
nRet = Run(lpstrCmdLine, nCmdShow);
}
_Module.RevokeClassObjects();
::Sleep(_Module.m_dwPause);
}
_Module.Term();
::CoUninitialize();
return nRet;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Jozef Božek is currently a software engineer at bring-it-together s.r.o. in area of large scale infomation systems and mobile applications development.
He has been developing in C++ nearly full time since 2000, in Java since 2004 and in Objective-C since 2009. He is programming using Java EE SDK, iOS SDK, COM/DCOM, MFC, ATL, STL and so on