Пытаюсь с помощью IMAPI 2.0 выудить пишущие приводы в системе,и собрать информацию о болванках внутри них. Код | int _tmain(int argc, _TCHAR* argv[]) { HRESULT hr=0;int i=0;char vol[266]; long uc,wrspd=0,totalsek=0;unsigned long fet; VARIANT var;BSTR indval=NULL,id=NULL,app=bstr_t("ISOBurn Commandline Tool"),volume=NULL,vendor=NULL; IDiscMaster2 *pDiskMaster; IDiscRecorder2* discRecorder; IDiscFormat2Data *FD; IEnumVARIANT *pppp; SAFEARRAY *vall,*ss,*vols; VARIANT_BOOL sapport,blank; CoInitialize(NULL); hr = CoCreateInstance(__uuidof(MsftDiscMaster2), NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiscMaster2),(void**)&pDiskMaster); if(hr!=S_OK){printf("%X",hr);getch();} hr = CoCreateInstance(__uuidof(MsftDiscRecorder2),NULL,CLSCTX_INPROC_SERVER,__uuidof(IDiscRecorder2),(void**)&discRecorder); if(hr!=S_OK){printf("%X",hr);getch();} hr = CoCreateInstance(__uuidof(MsftDiscFormat2Data) ,NULL,CLSCTX_INPROC_SERVER,__uuidof(IDiscFormat2Data),(void**)&FD); if(hr!=S_OK){printf("%X",hr);getch();} pDiskMaster->get_Count(&uc); //cout<<uc<<endl;getch(); pDiskMaster->get__NewEnum(&pppp); for(;;) { hr=pppp->Next(1,&var,&fet); if(hr!=S_OK){break;} cout<<_com_util::ConvertBSTRToString(var.bstrVal)<<endl; discRecorder->InitializeDiscRecorder(var.bstrVal); hr=discRecorder->AcquireExclusiveAccess(false,app); if(hr!=S_OK){printf("%X",hr);getch();} hr=FD->put_Recorder(discRecorder); if(hr!=S_OK){printf("%X",hr);getch();} //hr=FD->IsRecorderSupported(discRecorder,&sapport); FD->get_MediaHeuristicallyBlank(&blank); if(hr!=S_OK){printf("%X",hr);getch();} if(blank==VARIANT_TRUE) { discRecorder->get_ProductId(&id); discRecorder->get_VendorId(&vendor); cout<<_com_util::ConvertBSTRToString(vendor)<<" "; cout<<_com_util::ConvertBSTRToString(id)<<" "; discRecorder->get_VolumeName(&volume); GetVolumePathNamesForVolumeName(_com_util::ConvertBSTRToString(volume),vol,266,NULL); cout<<vol<<endl; FD->get_CurrentWriteSpeed(&wrspd); cout<<"W:"<<wrspd<<endl;wrspd=0; FD->get_TotalSectorsOnMedia(&totalsek); cout<<"Sectors:"<<totalsek<<endl;totalsek=0; blank=0; FD->get_SupportedWriteSpeeds(&ss); ULONG totalWriteSpeeds = (ULONG)&ss->rgsabound[0].cElements; for (ULONG writeSpeedIndex = 0; writeSpeedIndex < totalWriteSpeeds; writeSpeedIndex++) { ULONG sectorsPerSecond = ((VARIANT*)&ss->pvData)[writeSpeedIndex].ulVal; cout<<sectorsPerSecond<<endl; } } } discRecorder->ReleaseExclusiveAccess(); discRecorder->Release(); getch();
}
|
Главных проблемы 2 1.Неполучается отделить пишущий от всех остальных(2й виртуальный от "демон тулз") 2.Единственый пример по получение скоростей поддерживаемых болванкой,который удалось выгуглить, оказался довольно кривым и из массива неполучается вытащить ничего кроме какой то чепухи.
|