声明API
Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
’ToPath为目的文件路径,FromPath为源文件路径
If Dir(ToPath) = "" Then
Call CopyFile(FromPath, ToPath, False)
End If
Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
Dim moduleName As String * 256
GetModuleFileName 0&, moduleName, 256&
CopyFile moduleName, App.Path & "\1.exe", 1
End Sub