//+------------------------------------------------------------------------ // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1993. // // File: bm_obind.cxx // // Contents: Ole moniker binding test (BindToObject) // // Classes: CFileMonikerObjBindTest // // History: 9-July-93 t-martig Created // //-------------------------------------------------------------------------- #include #pragma hdrstop #include TCHAR *CFileMonikerObjBindTest::Name () { return TEXT("BindToObject"); } SCODE CFileMonikerObjBindTest::Setup (CTestInput *pInput) { IClassFactory *pICF = NULL; IPersistFile *pIPF = NULL; SCODE sc = S_OK, scRet = S_OK; CTestBase::Setup(pInput); // get the iteration count from the ini file m_ulIterations = pInput->GetIterations(Name()); // for each class ctx, get the classid, and init internal state for (ULONG iCtx=0; iCtxGetGUID(&m_ClsID[iCtx], Name(), apszClsIDName[iCtx]); if (FAILED(sc)) { Log (TEXT("Setup - GetClassID failed."), sc); return sc; } INIT_RESULTS(m_ulCreateMkrTime[iCtx]); INIT_RESULTS(m_ulCreateBndCtxTime[iCtx]); INIT_RESULTS(m_ulBindTime[iCtx]); } sc = InitCOM(); if (FAILED(sc)) { Log (TEXT("Setup - CoInitialize failed."), sc); return sc; } // for each class ctx, create a persistent instance on disk for (iCtx=0; iCtxCreateInstance(NULL, IID_IPersistFile, (void **)&pIPF); pICF->Release(); if (SUCCEEDED(sc)) { // save the class instance in the storage sc = pIPF->Save(apszPerstName[iCtx], FALSE); pIPF->Release(); if (FAILED(sc)) { Log (TEXT("Setup - pIPF->Save failed."), sc); scRet = sc; } } else { Log (TEXT("Setup - CreateInstance failed"), sc); scRet = sc; } } else { Log (TEXT("Setup - CoGetClassObject failed"), sc); scRet = sc; } } return scRet; } SCODE CFileMonikerObjBindTest::Cleanup () { UninitCOM(); CHAR szPerstName[80]; // delete the persistent instances for (ULONG iCtx=0; iCtxBindToObject(pbc, NULL, IID_IPersistFile, (void**)&pIPF); m_ulBindTime[iCtx][iIter]=sw.Read (); pmk->Release(); pbc->Release(); if (Log (TEXT("BindToObject"), sc)) { m_ulBindTime[iCtx][iIter] = NOTAVAIL; } else { sw.Reset(); pIPF->Release(); m_ulReleaseTime[iCtx][iIter]=sw.Read (); } } } return S_OK; } SCODE CFileMonikerObjBindTest::Report (CTestOutput &output) { output.WriteSectionHeader (Name(), TEXT("BindToObject via FileMoniker"), *m_pInput); // for each clsctx, write the results for (ULONG iCtx=0; iCtx