1 2 //This code renames a directory. 3 4 #include <Shellapi.h> 5 String TForm1::ReNameDir(String sDir1, String sDir2){ 6 7 TSHFileOpStruct shellinfo; 8 9 shellinfo.hwnd=0; 10 shellinfo.wFunc=FO_RENAME; 11 shellinfo.pFrom = sDir1.c_str(); 12 shellinfo.pTo=sDir2.c_str(); 13 shellinfo.fFlags=FOF_FILESONLY || FOF_ALLOWUNDO || 14 FOF_SILENT || FOF_NOCONFIRMATION; 15 SHFileOperation(&shellinfo); 16 17 } 18 19 void __fastcall TForm1::Button1Click(TObject *Sender) 20 { 21 22 ReNameDir("c:\\Test1","C:\\Test2"); 23 24 }