thanks33 | Bonjour, je me trouve confronté a une erreur de compilation bizarre.
Voici le code utilisé:
Code :
- #include <windows.h>
- #include <string>
- #include <iostream>
- void WatchDirectory(LPTSTR lpDir);
- int main()
- {
- TCHAR Directory[MAX_PATH];
- GetCurrentDirectory(MAX_PATH,Directory);
- WatchDirectory(Directory);
- return 0;
- }
- struct ScopedLockHandle
- {
- ScopedLockHandle(HANDLE h_)
- :m_handle(h_)
- {}
- ~ScopedLockHandle()
- {CloseHandle(m_handle);}
- private:
- HANDLE m_handle;
- };
- void WatchDirectory(LPTSTR lpDir)
- {
- HANDLE hDir = CreateFile(
- lpDir,
- FILE_LIST_DIRECTORY,
- FILE_SHARE_READ|FILE_SHARE_DELETE|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- NULL
- );
- if(hDir){
- ScopedLockHandle scoped(hDir);
- const unsigned nbr_item=1024;
- FILE_NOTIFY_INFORMATION Buffer[nbr_item];
- DWORD BytesReturned;
- while( ReadDirectoryChangesW(
- hDir,
- &Buffer,
- sizeof(Buffer),
- TRUE, /* monitoring option */
- FILE_NOTIFY_CHANGE_SECURITY|
- FILE_NOTIFY_CHANGE_CREATION|
- FILE_NOTIFY_CHANGE_LAST_ACCESS|
- FILE_NOTIFY_CHANGE_LAST_WRITE|
- FILE_NOTIFY_CHANGE_SIZE|
- FILE_NOTIFY_CHANGE_ATTRIBUTES|
- FILE_NOTIFY_CHANGE_DIR_NAME|
- FILE_NOTIFY_CHANGE_FILE_NAME, /* filter conditions */
- &BytesReturned, /* bytes returned */
- NULL, /* overlapped buffer */
- NULL))
- {
- FILE_NOTIFY_INFORMATION *p_cur = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(&Buffer[0]);
- do{
- switch(p_cur->Action)
- {
- case FILE_ACTION_ADDED:
- std::wcout<<L"File added : "<<std::wstring(p_cur->FileName,p_cur->FileNameLength/sizeof(p_cur->FileName[0]))<<std::endl;
- break;
- case FILE_ACTION_REMOVED:
- std::wcout<<L"File removed : "<<std::wstring(p_cur->FileName,p_cur->FileNameLength/sizeof(p_cur->FileName[0]))<<std::endl;
- break;
- case FILE_ACTION_MODIFIED :
- std::wcout<<L"File modified : "<<std::wstring(p_cur->FileName,p_cur->FileNameLength/sizeof(p_cur->FileName[0]))<<std::endl;
- break;
- case FILE_ACTION_RENAMED_OLD_NAME :
- std::wcout<<L"File renamed old name : "<<std::wstring(p_cur->FileName,p_cur->FileNameLength/sizeof(p_cur->FileName[0]))<<std::endl;
- break;
- case FILE_ACTION_RENAMED_NEW_NAME :
- std::wcout<<L"File rename new name : "<<std::wstring(p_cur->FileName,p_cur->FileNameLength/sizeof(p_cur->FileName[0]))<<std::endl;
- break;
- default:
- std::wcout<<L"File unknown : "<<std::wstring(p_cur->FileName,p_cur->FileNameLength/sizeof(p_cur->FileName[0]))<<std::endl;
- break;
- }
- p_cur = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(reinterpret_cast<unsigned char*>(p_cur) + p_cur->NextEntryOffset);
- }while(p_cur->NextEntryOffset>0);
- }
- }
- }
|
et l'erreur de compilation est la suivante:
Code :
- error: `wcout' is not a member of `std'|
|
Quand j'enléve les std:: voici erreur :
Code :
- error: `wcout' was not declared in this scope
|
j'ai essayé beaucoup de chose rien a marché.
J'espère que vous pourrez m'aider.
Cordialement Message édité par thanks33 le 24-06-2009 à 09:08:02
|