1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| BOOL ProcessCmdLine(LPSTR lpCmdLine, LPDWORD pdwRegisterCF,
LPDWORD pdwRegisterActiveObject, int nCmdShow)
{
LPCLASSFACTORY pcf = NULL;
HRESULT hr;
*pdwRegisterCF = 0;
*pdwRegisterActiveObject = 0;
// Expose class factory for application object if command line
// contains the /Automation switch.
if (_fstrstr(lpCmdLine, "-Automation") != NULL
|| _fstrstr(lpCmdLine, "/Automation") != NULL)
{
pcf = new CApplicationCF;
if (!pcf)
goto error;
pcf->AddRef();
hr = CoRegisterClassObject(CLSID_Lines, pcf,
CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE,
pdwRegisterCF);
if (hr != NOERROR)
goto error;
pcf->Release();
}
else // Show window if started as stand-alone.
g_pApplication->ShowWindow(nCmdShow );
// Register Lines Application object in the running object table
// (ROT). Use weak registration so that the ROT releases its reference
// when all external references are released.
RegisterActiveObject(g_pApplication, CLSID_Lines, ACTIVEOBJECT_WEAK,
pdwRegisterActiveObject);
return TRUE;
error:
if (pcf)
pcf->Release();
return FALSE;
} |