Sign in to follow this  
Followers 0

Dll call fails ... whats wrong?

4 posts in this topic

#1 ·  Posted (edited)


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);

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)


the code runs without any errors - and doing anything... :D

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 by mozart90

Share this post

Link to post
Share on other sites

AutoIt can rename a folder...


... 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

Share this post

Link to post
Share on other sites

Have you tested this scenario? files being in use?



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

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0