mozart90 Posted June 2, 2006 Share Posted June 2, 2006 (edited) Hi I want so use the rename function in shell.dll. But the dll function returns an error: Can anyone help please? ;~ hwnd As Long'Handle of dialog box to display status info. ;~ wFunc As Long 'Operation to perform. ;~ pFrom As String'A string specifying one or more source file names. ;~ 'Multiple names must be null-separated. The list of names ;~ 'must be double null-terminated. ;~ pTo As String'Same as pFrom except for the destination. ;~ fFlags As Integer 'Flags that control the file operation - See Source Code. ;~ fAborted As Boolean'TRUE if an operation was aborted before it was completed. ;~ hNameMaps As Long'Only used with certain flags. ;~ sProgress As String $str = "int;int;char[11];char[12];int;int;int;char[1]" $a = DllStructCreate($str) if @error Then MsgBox(0,"","Error in DllStructCreate " & @error); exit endif DllStructSetData($a,2,4);4 means rename DllStructSetData($a,3,"c:\mytest"& chr(0) & chr(0)) DllStructSetData($a,4,"c:\mytest_new"& chr(0) & chr(0)) $aRet = DllCall("shell32.dll", "long", "SHFileOperationA", "str",$a) if @error then MsgBox(0,"err", @error) endif MsgBox(0,"Dll",$aRet[0]) the code runs without any errors - and doing anything... greetings mozart90 perhaps following information helps a little... Public Const FO_MOVE As Long = &H1 Public Const FO_COPY As Long = &H2 Public Const FO_DELETE As Long = &H3 Public Const FO_RENAME As Long = &H4 Public Const FOF_MULTIDESTFILES As Long = &H1 Public Const FOF_CONFIRMMOUSE As Long = &H2 Public Const FOF_SILENT As Long = &H4 Public Const FOF_RENAMEONCOLLISION As Long = &H8 Public Const FOF_NOCONFIRMATION As Long = &H10 Public Const FOF_WANTMAPPINGHANDLE As Long = &H20 Public Const FOF_CREATEPROGRESSDLG As Long = &H0 Public Const FOF_ALLOWUNDO As Long = &H40 Public Const FOF_FILESONLY As Long = &H80 Public Const FOF_SIMPLEPROGRESS As Long = &H100 Public Const FOF_NOCONFIRMMKDIR As Long = &H200 Private Declare Function SHFileOperationStr Lib "shell32.dll" Alias _ "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCTStr) As Long Edited June 2, 2006 by mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
mozart90 Posted June 2, 2006 Author Share Posted June 2, 2006 To start... a BOOL is an "int" in MS land. And your strings need to be dynamically lengthed and double NULL terminated... Read here...http://msdn.microsoft.com/library/default....ileopstruct.aspLar.thanks,I have changed both things ... but it is bit more complicate, I think. greetings mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
mozart90 Posted June 2, 2006 Author Share Posted June 2, 2006 AutoIt can rename a folder... DirMove(".\docs",".\schmocs") ... yes I know. But what happens when some files are in use? Autoit creates the new folder and moves files in it until it reaches an open file and is then exiting the move function.... thats a case I want to avoid perhaps you have any other suggestions greetings mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
mozart90 Posted June 2, 2006 Author Share Posted June 2, 2006 Have you tested this scenario? files being in use?LAr.Hi,yes I tested this case - on the disk remain 2 Folders the half the old and half the new one ...You can imagine that this move try is a problem renaming something on a server...greetings mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now