Jump to content

_WinAPI_ShellFileOperation(,,,,,$sTitle)


Go to solution Solved by argumentum,

Recommended Posts

_WinAPI_ShellFileOperation ( $sFrom, $sTo, $iFunc, $iFlags [, $sTitle = '' [, $hParent = 0]] ) uses $tagSHFILEOPSTRUCT = 'hwnd hWnd;uint Func;ptr From;ptr To;dword Flags;int fAnyOperationsAborted;ptr hNameMappings;ptr ProgressTitle'  but there's no pointer just DllStructSetData($tSHFILEOPSTRUCT, 'ProgressTitle', $sTitle) and should be something like DllStructSetData($tSHFILEOPSTRUCT, 'ProgressTitle', DllStructGetPtr($tTitle)) because that is what the tag calls for.

The title part is not working in Win10 or XP ( hence this post ) and I don't know how to fix it, other than the hint that it calls for a ptr and not a string. Help :baby:

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Not sure if title is deprecated in Win10, does this do anything with the dialog title under XP?

#include <WinAPIShellEx.au3>

$s_File_In = @ScriptDir & "\large_test_file_in.mp4"
$s_File_Out = @ScriptDir & "\out.mp4"

_WinAPI_ShellFileOperation_Ex($s_File_In, $s_File_Out, $FO_COPY, $FOF_SIMPLEPROGRESS, "Test")


Func _WinAPI_ShellFileOperation_Ex($sFrom, $sTo, $iFunc, $iFlags, $sTitle = '', $hParent = 0)
    Local $iData
    If Not IsArray($sFrom) Then
        $iData = $sFrom
        Dim $sFrom[1] = [$iData]
    EndIf
    Local $tFrom = _WinAPI_ArrayToStruct($sFrom)
    If @error Then Return SetError(@error + 20, @extended, 0)

    If Not IsArray($sTo) Then
        $iData = $sTo
        Dim $sTo[1] = [$iData]
    EndIf
    Local $tTo = _WinAPI_ArrayToStruct($sTo)
    If @error Then Return SetError(@error + 30, @extended, 0)

    Local $tTtitle
    If $sTitle Then
        If Not IsArray($sTitle) Then
            $iData = $sTitle
            Dim $sTitle[1] = [$iData]
        EndIf
        $tTtitle = _WinAPI_ArrayToStruct($sTitle)
        If @error Then Return SetError(@error + 40, @extended, 0)
    EndIf

    Local $tSHFILEOPSTRUCT = DllStructCreate($tagSHFILEOPSTRUCT)
    DllStructSetData($tSHFILEOPSTRUCT, 'hWnd', $hParent)
    DllStructSetData($tSHFILEOPSTRUCT, 'Func', $iFunc)
    DllStructSetData($tSHFILEOPSTRUCT, 'From', DllStructGetPtr($tFrom))
    DllStructSetData($tSHFILEOPSTRUCT, 'To', DllStructGetPtr($tTo))
    DllStructSetData($tSHFILEOPSTRUCT, 'Flags', $iFlags)

    If IsArray($sTitle) Then DllStructSetData($tSHFILEOPSTRUCT, 'ProgressTitle', DllStructGetPtr($tTtitle))

    Local $aCall = DllCall('shell32.dll', 'int', 'SHFileOperationW', 'struct*', $tSHFILEOPSTRUCT)
    If @error Then Return SetError(@error, @extended, 0)
    If $aCall[0] Then Return SetError(10, $aCall[0], 0)

    Return $tSHFILEOPSTRUCT
EndFunc   ;==>_WinAPI_ShellFileOperation_Ex

 

Edit: Found a remark, that FOF_SIMPLEPROGRESS shows a dialog without file locations, But under Win10 I see a dialog with locations, so maybe the whole SIMPLEPROGRESS dialog concept has been dropped (since Vista)?

Edited by KaFu
Link to comment
Share on other sites

from https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shfileopstructa
lpszProgressTitle
Type: PCTSTR
A pointer to the title of a progress dialog box. This is a null-terminated string. This member is used only if fFlags includes the FOF_SIMPLEPROGRESS flag.

So it needs a ptr to a string/pcstr ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Hello. Pointer to CWSTR. 

So struct of wchar then get ptr of struct wchar.

Saludos

 

Link to comment
Share on other sites

29 minutes ago, Danyfirex said:

So struct of wchar then get ptr of struct wchar

could you say that in code ? ( as to create the wchar that I can call with DllStructGetPtr() )
I don't know how to do that basic thing :(

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

example()

Func example()

    Local $tTitleBuffer = DllStructCreate("wchar title[256];")

    ;Populate title buffer
    $tTitleBuffer.title = "This is a title"

    ;Display title & pointer to title
    ConsoleWrite("Title         = " & $tTitleBuffer.title & @CRLF)
    ConsoleWrite("Title Pointer = " & DllStructGetPtr($tTitleBuffer) & @CRLF)

EndFunc

Console output:

Title         = This is a title
Title Pointer = 0x00000000005D8070

 

Link to comment
Share on other sites

I've tried both of these:

;~  Local $pTitle, $tTitle = DllStructCreate("wchar ProgressTitle[" & StringLen($sTitle) + 2 & "]")
;~  DllStructSetData($tTitle, "ProgressTitle", $sTitle)
;~  $pTitle = DllStructGetPtr($tTitle)

    Local $pTitle, $tTitle = DllStructCreate("wchar ProgressTitle[256];")
    $tTitle.ProgressTitle = "This is a title"
    $pTitle = DllStructGetPtr($tTitle)

and no dice. This code is been around since forever and the title aspect never worked ( or shown any visual difference ).
I just now discovered it an I'm like, is this function never been debugged or is it that it just plain don't work ( by way of M$ bug/idea never implemented/depreciated/etc.) 

Edited by argumentum
oops

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Interesting. I think It does not work. at least in Windows 10 I don't get title changed. 

 

Saludos

Link to comment
Share on other sites

  • Solution
18 minutes ago, Danyfirex said:

Interesting. I think It does not work

reading on the net, it seems that is code from Win 3.1, with it's long pointer to a 16 bit failed/dropped Unicode implementation and, long story short, it's a mess.
Tried on WinXP because win32 is Win2000 onwards ( I guess ), so if it works on XP, it did work at some point in time.
Is likely that either A, it was never used and miscoded or B, does not matter as it would not work as advertised in any case.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...