[ad_1]
I was trying to run a code that I found on this site, "Getting the File System Image and Deleted Data Recovery." But when I run the project, a cpp file called "RemovebleDeviceInfo.cpp" has an error: "no matching function for call to 'std::__cxx11::basic_string<wchar_t>::basic_string(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type*)'".
以下はコードです:
C++
<pre>std::wstring GetDevInterfaceVolume(PSP_DEVINFO_DATA pdevInfoData) { ULONG ulSize = 0; DEVINST childDevInst; bool isDisk = false; if ( NULL == pdevInfoData ) { throw std::runtime_error("Wrong PSP_DEVINFO_DATA parameter"); } DWORD res = CM_Get_Child_Ex(&childDevInst, pdevInfoData->DevInst, 0, NULL); isDisk = (CR_NO_SUCH_DEVNODE == res); if(isDisk) { childDevInst = pdevInfoData->DevInst; } else if ( CR_SUCCESS != res) { throw std::runtime_error("Can't get Child Device Instance"); } TCHAR bDeviceID[MAX_DEVICE_ID_LEN] = {0}; if ( CR_SUCCESS != CM_Get_Device_ID_Ex(childDevInst, bDeviceID, sizeof(bDeviceID)/sizeof(TCHAR), 0, NULL) ) { throw std::runtime_error("Can't get Device ID"); } LPGUID InterfaceClassGuid = isDisk ? (LPGUID)&DiskClassGuid : (LPGUID)&VolumeClassGuid; if ( CR_SUCCESS != CM_Get_Device_Interface_List_Size(&ulSize, InterfaceClassGuid, bDeviceID, 0) ) { throw std::runtime_error("Can't get Device Instance List Size"); } std::vector<TCHAR> sResult(ulSize, 0x00); if ( sResult.empty() ) { throw std::runtime_error("Device Interface Volume is empty"); } InterfaceClassGuid = isDisk ? (LPGUID)&GUID_DEVINTERFACE_DISK : (LPGUID)&GUID_DEVINTERFACE_VOLUME; if ( CR_SUCCESS != CM_Get_Device_Interface_List(InterfaceClassGuid, bDeviceID, &sResult.front(), ulSize, 0) ) { throw std::runtime_error("Can't get Device Instance List"); } sResult.resize(ulSize); if ( sResult.empty() ) { throw std::runtime_error("Device Interface Volume is empty"); } return std::wstring(&sResult.front()); }
エラーの原因は
return std::wstring(&sResult.front());
プロジェクトへのリンク: https://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=138888
私が試したこと:
I attempted to find the answer on the internet but was unsuccessful.
解決策 1
これをクイック アンサーの下に投稿しないでください。記事からコードを取得した場合、その記事の下部に[コメントまたは質問を追加]ボタンがあり、作成者に電子メールが送信されます。 その後、彼らはあなたが彼らと話したいという警告を受けます。
これをここに投稿することは、彼らが「立ち寄って」、それが彼らのためであることに気付くことに依存しています.
[ad_2]
コメント