none
how to use PX_Blob in activex for powerpoint2007 add-in RRS feed

  • 问题

  • how to use PX_Blob in activex for ppt add-in purpose:just like shockwave.ocx 's EmbedMovie=TRUE的功能
    my code is here,but it does't work corectly,can any one help me?

    void CBrowserResOcxCtrl::DoPropExchange(CPropExchange* pPX) { ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor)); COleControl::DoPropExchange(pPX); PX_Resource(pPX); } void CBrowserResOcxCtrl::PX_Resource(CPropExchange* pPX) { ////////////////////////////////////////////////////////////////////////// if (pPX->GetVersion() == (DWORD)MAKELONG(_wVerMinor, _wVerMajor)) { if(!pPX->IsLoading()) { _variant_t vContent; m_CreateHtml.CreateVariantFromFile(&vContent,....); BYTE by[4]; DWORD dw = vContent.parray->rgsabound->cElements; WORD h,l; h = HIWORD(dw); l = LOWORD(dw); by[0] = LOBYTE(l); by[1] = HIBYTE(l); by[2] = LOBYTE(h); by[3] = HIBYTE(h); //////////////////////////////////////////////////////////////////////// m_hRes = GlobalAlloc(GPTR, dw+4); if(m_hRes != NULL) { BYTE* pMem = (BYTE*)GlobalLock(m_hRes); if(pMem!=NULL) { ///*(DWORD*)pMem = dw; pMem[0] = by[0]; pMem[1] = by[1]; pMem[2] = by[2]; pMem[3] = by[3]; BYTE* pTemp = NULL; SafeArrayAccessData(vContent.parray, (void **)&pTemp); for (int n=0;n<dwLen;n++) { BYTE by; by = pTemp[n]; pMem[n+4]=pTemp[n]; } BOOL f = PX_Blob(pPX, _T("BlobRes"),m_hRes); SafeArrayUnaccessData(vContent.parray); GlobalUnlock(m_hRes); m_hRes = NULL; } else { HGLOBAL hTmp = NULL; BOOL b = PX_Blob(pPX, _T("BlobRes"), hTmp); } GlobalFree(m_hRes); m_hRes = NULL; } else BOOL b = PX_Blob(pPX, _T("BlobRes"), m_hRes); } else { BOOL b = PX_Blob(pPX, _T("BlobRes"), m_hRes); if(m_hRes!=NULL) { BYTE* pMem = (BYTE*)GlobalLock(m_hRes); DWORD dwLen = GlobalSize(m_hRes); _variant_t vContent; HRESULT hr; long lngOffset = 4; UCHAR chData; SAFEARRAY FAR *psa = NULL; SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = dwLen-sizeof(DWORD); psa = SafeArrayCreate(VT_UI1,1,rgsabound); while(lngOffset < dwLen-4) { chData = (UCHAR)(pMem[lngOffset]); hr = SafeArrayPutElement(psa, &lngOffset, &chData); if(FAILED(hr)) { printf("错误"); } lngOffset++; } vContent.vt = VT_ARRAY|VT_UI1; vContent.parray = psa; m_CreateHtml.CreateFileFromVariant(vContent,....); GlobalUnlock(m_hRes); } GlobalFree(m_hRes); m_hRes = NULL;   } }   }

    //------------------------------------

    when insert
    First-chance exception at 0x7571c6e3 in POWERPNT.EXE: 0x000006BA: RPC 服务器不可用。.
    when save file
    First-chance exception at 0x7571c6e3 in POWERPNT.EXE: 0xE0000002: 0xe0000002.

    2013年7月5日 0:53