0
我想將strFileNotifyInfo [1] .FileName(Wchar_t)轉換爲字符串,以便我可以看到文件路徑。但我不能讓它工作。Wchar_t to string轉換
這裏是我的代碼:
while(TRUE)
{
if(ReadDirectoryChangesW(hDir, (LPVOID)&strFileNotifyInfo, sizeof(strFileNotifyInfo), FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE || FILE_NOTIFY_CHANGE_CREATION, &dwBytesReturned, NULL, NULL) == 0)
{
cout << "Reading Directory Change" << endl;
}
else
{
cout << ("File Modified: ") << strFileNotifyInfo[1].FileName << endl;
cout << ("Loop: ") << nCounter++ << endl;
}
}
我懷疑這是'wchar_t'。你的意思是'wchar_t *'? – 2013-02-10 16:46:03
嘗試WideCharToMultiByte API http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130%28v=vs.85%29.aspx – Nika 2013-02-10 16:51:49
對不起,我的壞,它是一個Wchar_t *。 – user1812707 2013-02-10 17:09:12