Thứ Hai, 18 tháng 8, 2014

on Leave a Comment

Copy File im VB :

Có thể cho làm virus
- Ví dụ 1
Dim SourceFile, DestinationFile
SourceFile = "C:\test.EXE"
DestinationFile = "C:\windows\aaa.EXE"
Filecopy SourceFile,DestinationFile
- Ví dụ 2 ( search từ kazcode )
Declarations
Public Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Public Const FO_COPY = &H2
Public Const FOF_ALLOWUNDO = &H40
Code
Public Sub CopyFileWindowsWay(SourceFile As String, DestinationFile As String)
Dim lngReturn As Long
Dim typFileOperation As SHFILEOPSTRUCT
With typFileOperation
.hWnd = 0
.wFunc = FO_COPY
.pFrom = SourceFile & vbNullChar & vbNullChar 'source file
.pTo = DestinationFile & vbNullChar & vbNullChar 'destination file
.fFlags = FOF_ALLOWUNDO
End With
lngReturn = SHFileOperation(typFileOperation)
If lngReturn <> 0 Then 'Operation failed
MsgBox Err.LastDllError, vbCritical Or vbOKOnly
Else 'Aborted
If typFileOperation.fAnyOperationsAborted = True Then
MsgBox "Operation Failed", vbCritical Or vbOKOnly
End If
End If
End Sub

--------------
Bài viết của lieumang

0 nhận xét:

Đăng nhận xét