Salut à Tous.
Lorsque je transmet un pointeur sur string pour pFrom, ça marche
Lorsque je transmet une wString.c_srt() ça échoue, erreur 1400 "invalid handle"
Je suis perplexe, pTo accept la string.c_str(), et pas pFrom.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 /* //====================================================================== //Première méthode avec un wchar_t pour pFrom et un wstring pour pTo //Réussit //=================================================================== wchar_t lpFrom[24]=L"ressources\\biplan.cli\0\0"; shfos.pFrom=lpFrom; wstring sDest(L"test\\"); shfos.pTo=sDest.c_str(); shfos.fFlags=FOF_SILENT | FOF_NOCONFIRMATION; //copie des fichiers dans le répertoire int retShfo=SHFileOperation(&shfos); if(retShfo){ if(TEST){wcout<<"copyTemp: echec "<<sDestFiles.c_str()<<" "<<GetLastError()<<endl;}// }else{ if(TEST){wcout<<"copyTemp: succes "<<sDestFiles.c_str()<<" "<<GetLastError()<<endl;} } */ //================================================================== //Deuxième méthode avec un wstring pour pFrom et pTo //échoue GetLastError() renvoie 1400 invalid handle //================================================================== wstring sFrom(L"ressources\\biplan.cli\0\0"); shfos.pFrom=sFrom.c_str(); wstring sDest(L"test\\"); shfos.pTo=sDest.c_str(); shfos.fFlags=FOF_SILENT | FOF_NOCONFIRMATION; //copie des fichiers dans le répertoire int retShfo=SHFileOperation(&shfos); if(retShfo){ if(TEST){wcout<<"copyTemp: echec "<<sDestFiles.c_str()<<" "<<GetLastError()<<endl;} }else{ if(TEST){wcout<<"copyTemp: succes "<<sDestFiles.c_str()<<" "<<GetLastError()<<endl;} }
Je teste les deux méthodes séparément, et après avoir vidé le dossier de destination.
C'est gênant, car je voudrais vraiment utiliser une string pour constituer mes fichiers à copier.
Qui peut m'aider?
Merci à tous.
Alain
Partager