Feedback

VB - Datei mittels Windows Dialog verschieben

Veröffentlicht von am 03.06.2006
(3 Bewertungen)
Datei mittels Windows Dialog verschieben
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer

Private Structure SHFILEOPSTRUCT
    Dim hwnd As Integer
    Dim wFunc As Integer
    Dim pFrom As String
    Dim pTo As String
    Dim fFlags As Short
    Dim fAnyOperationsAborted As Boolean
    Dim hNameMappings As Integer
    Dim lpszProgressTitle As String
End Structure

Const FO_MOVE As Short = &H1S

Public Function ShellMove(ByVal strSource As String, ByVal strTarget As String, ByVal Handle As Long) As Boolean
    Dim SFO As New SHFILEOPSTRUCT

    If Right(strSource, 1) = "\" Then strSource = Mid(strSource, 1, Len(strSource) - 1)
    ShellMove = True
    With SFO
        .hwnd = Handle
        .wFunc = FO_MOVE
        .pFrom = strSource & Chr(0) & Chr(0)
        .pTo = strTarget & Chr(0) & Chr(0)
    End With

    Call SHFileOperation(SFO)
    If SFO.fAnyOperationsAborted Then ShellMove = False
End Function
Abgelegt unter Shell, Datei, Veschieben.

Kommentare zum Snippet

 

Logge dich ein, um hier zu kommentieren!