我使用SHFileOperation提示:实时错误453:
找不到dll的入口点,SHFileOperationA in shell32.dll是何原因代码如下
Option Explicit
Private Declare Function SHFileOperation Lib "shell32.dll" Alias " SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
        hWnd As Long
        wFunc As Long
        pFrom As String
        pTo As String
        fFlags As Integer
        fAnyOperationsAborted As Long
        hNameMappings As Long
        lpszProgressTitle As String '  only used if FOF_SIMPLEPROGRESS
End Type
Private Const FO_DELETE = &H3 
Private Const FOF_ALLOWUNDO = &H40 
Private Sub Command1_Click()    Dim SHFileOp As SHFILEOPSTRUCT
    CD1.Filter = "All Files (*.*)|*.*"
    CD1.ShowOpen
    With SHFileOp
        .wFunc = FO_DELETE
        .pFrom = CD1.FileName
        .fFlags = FOF_ALLOWUNDO 
    End With
    SHFileOperation SHFileOp
    End Sub

解决方案 »

  1.   

    'This program needs a Common Dialog Box, named CDBox.
    '  (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
    '   and select Microsoft Common Dialog control)
    Private Type SHFILEOPSTRUCT
        hWnd As Long
        wFunc As Long
        pFrom As String
        pTo As String
        fFlags As Integer
        fAborted As Boolean
        hNameMaps As Long
        sProgress As String
    End Type
    Private Const FO_DELETE = &H3
    Private Const FOF_ALLOWUNDO = &H40
    Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    Private Sub Form_Load()    Dim SHFileOp As SHFILEOPSTRUCT
        'Set the dialog's title
        CDBox.DialogTitle = "Select a file to delete ..."
        'Set the dialog's filter
        CDBox.Filter = "All Files (*.*)|*.*"
        'Show the 'Open File' dialog
        CDBox.ShowOpen
        With SHFileOp
            'Delete the file
            .wFunc = FO_DELETE
            'Select the file
            .pFrom = CDBox.FileName
            'Allow 'move to recycle bn'
            .fFlags = FOF_ALLOWUNDO
        End With
        'perform file operation
        SHFileOperation SHFileOp
        MsgBox "The file '" + CDBox.FileName + "' has been moved to your Recycling Bin !", vbInformation + vbOKOnly, App.Title
    End Sub
      

  2.   

    Private Declare Function SHFileOperation Lib "shell32.dll" Alias " SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    定义有问题
    SHFileOperationA前多了个空格