PDA

View Full Version : تابع SHFileOperation



majjjj
چهارشنبه 21 آذر 1386, 10:17 صبح
Private Declare Function SHFileOperation Lib "shell32.dll" Alias " SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

ایا این تابع در کتابخانه shell32 وجود دارد اگه جواب مثبته چرا برنامه من اونو نمیشناسه




Private Const FO_COPY = &H2
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 Declare Function SHFileOperation Lib "shell32.dll" Alias " SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Sub Command1_Click()
Dim ret_val As Long
Dim sh_op As SHFILEOPSTRUCT
With sh_op
.hwnd = 0
.wFunc = FO_COPY
.pFrom = Text1.Text
.pTo = Text2.Text
End With
ret_val = SHFileOperation(sh_op)
End Sub
Private Sub Form_Load()
Command1.Caption = "ersal"
End Sub

حامد مصافی
چهارشنبه 21 آذر 1386, 12:56 عصر
اگر دقیقاً از کد مندرج استفاده می کنید اشتباه تایپی دارید.
فاصله قبل از نام تابع.



Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

majjjj
چهارشنبه 21 آذر 1386, 13:16 عصر
اگر دقیقاً از کد مندرج استفاده می کنید اشتباه تایپی دارید.
فاصله قبل از نام تابع.



Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
با سلام
متجه نشدم دقیقا کجای برنامه رو گفتین

حامد مصافی
چهارشنبه 21 آذر 1386, 13:20 عصر
یک Common Dialog با نام CDBox روی فرم بگذارید و کد زیر رو اجرا کنید.


'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()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
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

majjjj
پنج شنبه 22 آذر 1386, 12:45 عصر
متشکر مشکل حل شد اما نمیدونم چرا با وجود اینکه با api viewer اون کد رو بوجود اوردم چنین اشتباهی گرفت شما دلیل این رو میدونید؟؟