COM调用出错!!
void CENCControlDlg::OnButton1()
{
// TODO: Add your control notification handler code here
//Declare variables.
// Declare variables.
HRESULT hr;
IWMEncoder* pEncoder;
IWMEncStatistics* pStats;
IDispatch* pDispIndex;
IWMEncIndexerStats* pIndexStats;
long lFileCount, lPercent;
CComBSTR bstrFileName;
// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.
hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWMEncoder,
(void**) &pEncoder);
// Retrieve a pointer to an IWMEncAttributes interface.
hr = pEncoder->get_Statistics(&pStats);
// Retrieve an IDispatch pointer to IWMEncIndexerStats interface.
hr = pStats->get_IndexerStats(&pDispIndex);
// Call QueryInterface() to retrieve a pointer to the
// IWMEncIndexerStats interface.
hr = pDispIndex->QueryInterface(IID_IWMEncIndexerStats,
(void**) &pIndexStats);//这时出错了内存错误!
// Retrieve information about the indexing process.
hr = pIndexStats->get_FileCount(&lFileCount);
hr = pIndexStats->get_FileName(0, &bstrFileName);
hr = pIndexStats->get_PercentComplete(&lPercent);
}
请问我应如何修改,它是SDK上照搬下来的都有内存访问出错问题, 是不是MICROSOFT bug??
UP有分!!