客户端接口程序//
::CoInitialize( NULL );
IUnknown* pUnk = NULL;
Iflash* pflashserver = NULL;
HRESULT hr;
_bstr_t file("白桦林.mp3");
try
{
hr = ::CoCreateInstance(
CLSID_flash,
NULL,
CLSCTX_INPROC_SERVER, // 以进程内组件 DLL 方式加载
IID_IUnknown, // 想取得 IUnknown 接口指针
(LPVOID *) &pUnk);
if( FAILED( hr ) ) throw( _T("没有注册") );
hr = pUnk->QueryInterface( // 从 IUnknown 得到其它接口指针
IID_Iflash, // 想取得 Iflash 接口指针
(void**)&pflashserver );
if( FAILED( hr ) ) throw( _T("没有接口") );
hr = pflashserver->play(file,(long)::AfxGetInstanceHandle(),(long)this->GetSafeHwnd()); // Iflash::play()
if( SUCCEEDED( hr ) )
{
AfxMessageBox("Play OK!");
}
}
catch( LPCTSTR lpErr )
{
AfxMessageBox( lpErr );
}
if(pUnk) pUnk->Release();
if(pflashserver) pflashserver->Release();
::CoUninitialize();
客户端接口程序//