尝试在WCHAR中传递文件路径,但它给了我WCHAR与const WCHAR不兼容,因此尝试了硬编码,但仍然出现异常
void Read_Title(WCHAR FilePath) {
//const WCHAR FILE_PATH = FilePath;
IPropertySetStorage *pPropSetStg = NULL;
IPropertyStorage *pPropStg = NULL;
PROPSPEC propspec;
PROPVARIANT propWrite;
PROPVARIANT propRead;
HRESULT hr = S_OK;
hr = StgOpenStorageEx(L"c:\\users\qs4vbn\desktop\siemens_training\project2\project2\main.cpp",
STGM_DIRECT | STGM_SHARE_EXCLUSIVE |
STGM_READWRITE,
STGFMT_ANY,
0,
NULL,
NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg));
if (FAILED(hr))
throw L"Failed StgOpenStorageEx";
}
答案 0 :(得分:0)
此函数中的路径仅包含带有双反斜杠的第一段。
hr = StgOpenStorageEx(L"c:\\users\qs4vbn\desktop\siemens_training\project2\project2\main.cpp",
STGM_DIRECT | STGM_SHARE_EXCLUSIVE |
STGM_READWRITE,
STGFMT_ANY,
0,
NULL,
NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg));
您是否一直尝试使用带有双反斜杠的路径
hr = StgOpenStorageEx(L"c:\\users\\qs4vbn\\desktop\\siemens_training\\project2\\project2\\main.cpp",
STGM_DIRECT | STGM_SHARE_EXCLUSIVE |
STGM_READWRITE,
STGFMT_ANY,
0,
NULL,
NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg));