![](/img/trans.png)
[英]Getting an unsupported media type error while having a json object posted and content-type set to application/json
[英]getting external media type
我想找到一種在Windows上使用C ++的簡單功能來檢測光盤驅動器中媒體類型(例如DVD + R,DVD-R,DVD-RW,CD + R等)的方法。
該功能不需要管理員權限。
編輯
我實現了以下代碼:
#include <windows.h>
#include <winioctl.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <imapi2.h>
#include <imapi2fs.h>
#include <imapi2error.h>
#include <imapi2fserror.h>
int main(int argc, char *argv[])
{
IDiscFormat2Data* discFormatData = NULL;
HRESULT hr;
CoInitialize ( NULL );
hr = CoCreateInstance( __uuidof(MsftDiscFormat2Data),
NULL,
CLSCTX_ALL,
__uuidof(IDiscFormat2Data),
(void**)&discFormatData);
if ( SUCCEEDED(hr) )
{
IMAPI_MEDIA_PHYSICAL_TYPE mediaType = IMAPI_MEDIA_TYPE_UNKNOWN;
hr = discFormatData->get_CurrentPhysicalMediaType(&mediaType);
if ( SUCCEEDED(hr) )
{
std::cout << "MediaPhysicalType: " << mediaType << std::endl;
}
else
{
std::stringstream str;
str << "get_CurrentPhysicalMediaType() failed with the error: 0x";
str << std::hex << hr << ".";
std::cout << str.str() << std::endl;
}
// Release the interface.
// Tell the COM object that we're done with it.
discFormatData->Release();
}
else
{
std::stringstream str;
str << "CoCreateInstance() failed with the error: 0x" << std::hex << hr;
std::cout << str.str() << std::endl;
}
cin.get();
return 0;
}
目前,我的問題是出現以下錯誤:E_IMAPI_RECORDER_REQUIRED,這表示“該請求需要選擇當前的光盤刻錄機”。
假設我至少有兩個光驅,我之間如何區別?
有任何想法嗎?
在Windows 2000及更高版本上,可以將IOCTL_CDROM_GET_CONFIGURATION
與SCSI_GET_CONFIGURATION_REQUEST_TYPE_CURRENT
標志一起使用,以查詢光學設備的當前配置文件,該信息將告訴您已插入哪種類型的光盤(CD,DVD + -R / W,HDDVD,BluRay等)。 (如果有)。 在早期版本上,您將必須手動將SCSI MMC命令直接直接發送到設備以查詢相同的信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.