//+------------------------------------------------------------------------ // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1993. // // File: bm_marsh.cxx // // Contents: Mashalling test // // Classes: COleMarshalTest // // History: 29-July-93 t-martig Created // //-------------------------------------------------------------------------- #include #pragma hdrstop #include #include #include #include // funciton prototype DWORD _stdcall FnThread2(void *param); ULARGE_INTEGER ulSeekStart[REPS]; // stream starts LARGE_INTEGER libMove[REPS]; const IID *iid2[] = {&IID_IUnknown, &IID_IUnknown, &IID_IAdviseSink, &IID_IAdviseSink, &IID_IDataObject, &IID_IDataObject, &IID_IOleObject, &IID_IOleObject, &IID_IOleClientSite, &IID_IOleClientSite, &IID_IParseDisplayName, &IID_IParseDisplayName, &IID_IPersistStorage, &IID_IPersistStorage, &IID_IPersistFile, &IID_IPersistFile, &IID_IStorage, &IID_IStorage, &IID_IOleContainer, &IID_IOleContainer, &IID_IOleItemContainer, &IID_IOleItemContainer, &IID_IOleInPlaceSite, &IID_IOleInPlaceActiveObject, &IID_IOleInPlaceObject, &IID_IOleInPlaceUIWindow, &IID_IOleInPlaceFrame, &IID_IOleWindow}; TCHAR *COleMarshalTest2::Name () { return TEXT("Marshalling2"); } SCODE COleMarshalTest2::Setup (CTestInput *pInput) { SCODE sc; m_hThrd = NULL; m_dwTID1 = GetCurrentThreadId(); for (ULONG i=0; iGetIterations(Name()); // set NULL in case of error for (i=0; iGetClassID(&m_ClsID, Name()); // Get class activation context from .ini file m_dwClsCtx = pInput->GetClassCtx(Name()); for (i=0; iWrite(&dwTemp, sizeof(DWORD), NULL); } } m_hThrd = CreateThread(NULL, 0, FnThread2, (void *)this, 0, &m_dwTID2); if (m_hThrd == NULL) { Log (TEXT("Setup - CreateThread failed"), sc); } Sleep(50); // let the other thread initialize return S_OK; } SCODE COleMarshalTest2::Cleanup () { // release objects for (ULONG i=0; iRelease(); } for (i=0; iRelease(); } UninitCOM(); // close all the handles CloseHandle(m_hThrd); return S_OK; } DWORD _stdcall FnThread2(void *param) { COleMarshalTest2 *pMrshlTst = (COleMarshalTest2 *)param; return pMrshlTst->Run2(); } SCODE COleMarshalTest2::Run () { CStopWatch sw; LPVOID FAR pv[REPS]; for (ULONG iIter=0; iIterSeek(libMove[i], STREAM_SEEK_CUR, &ulSeekStart[i]); // marshal the interface into the stream sw.Reset(); sc[i] = CoMarshalInterface(m_pStm[i], *iid2[i], m_punk[iIter], 0, 0, MSHLFLAGS_NORMAL); m_ulMarshalTime[i][iIter] = sw.Read (); Log (TEXT("CoMarshalInterface"), sc[i]); if (FAILED(sc[i])) { m_ulMarshalTime[i][iIter] = NOTAVAIL; } } // reset the stream ptrs for (i=0; iSeek(libMove[i], STREAM_SEEK_SET, &ulSeekStart[i]); } // kick the other thread alive PostThreadMessage(m_dwTID2, WM_QUIT, NULL, NULL); // enter modal loop to dispatch ORPC messages MSG msg; while (GetMessage(&msg, NULL, WM_NULL, WM_NULL)) { DispatchMessage(&msg); } // reset the stream ptrs for (i=0; iSeek(libMove[i], STREAM_SEEK_SET, &ulSeekStart[i]); } Sleep(100); // unmarshal the interface ptrs for (i=0; iRelease (); m_ulReleaseTime2[i][iIter] = sw.Read (); Log (TEXT("Release"), sc[i]); } else { m_ulReleaseTime2[i][iIter] = NOTAVAIL; m_ulUnmarshalTime2[i][iIter] = NOTAVAIL; } } // reset the stream ptrs for (i=0; iSeek(libMove[i], STREAM_SEEK_SET, &ulSeekStart[i]); } } return S_OK; } SCODE COleMarshalTest2::Run2 () { SCODE sc = InitCOM(); if (FAILED(sc)) { Log (TEXT("Thread2 - CoInitialize failed."), sc); return sc; } CStopWatch sw; LPVOID FAR pv[REPS]; for (ULONG iIter=0; iIterSeek(libMove[i], STREAM_SEEK_SET, &ulSeekStart[i]); } Sleep(100); // remarshal the interface proxies for (i=0; iRelease (); m_ulReleaseTime[i][iIter] = sw.Read (); Log (TEXT("Release"), sc[i]); } else { m_ulReleaseTime[i][iIter] = NOTAVAIL; m_ulUnmarshalTime[i][iIter] = NOTAVAIL; } } // signal the other thread it is OK to go. PostThreadMessage(m_dwTID1, WM_QUIT, NULL, NULL); } UninitCOM(); return S_OK; } SCODE COleMarshalTest2::Report (CTestOutput &output) { output.WriteSectionHeader (Name(), TEXT("Interface Marshalling2"), *m_pInput); for (ULONG iCtx=0; iCtx<1; iCtx++) { output.WriteString (TEXT("\n")); output.WriteClassID (&m_ClsID); output.WriteString (apszClsCtx[0]); output.WriteString (TEXT("\n")); for (ULONG i=0; i