VB将程序本身复制到改用户的桌面上
如题
参考答案:'要生成EXE以后才可以自己复制自己,调试的时候会提示找不到文件
Option Explicit
Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, ppidl As Long) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath As String) As Long
Const DESKTOP = &H0&
Const MAX_LEN = 200
Private Sub Command1_Click()
Dim sTmp As String * MAX_LEN
Dim nLength As Long
Dim pidl As Long
SHGetSpecialFolderLocation 0, DESKTOP, pidl
SHGetPathFromIDList pidl, sTmp
FileCopy App.Path & "\" & App.EXEName & ".EXE", Left(sTmp, InStr(sTmp, Chr(0)) - 1) & "\" & App.EXEName & ".EXE"
End Sub