用vb制作的程序如何获取自己的安装路径?

2024年11月29日 21:21
有2个网友回答
网友(1):

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Dim WSH As Object, QQPath As String
Set WSH = CreateObject("Wscript.Shell")
QQPath = WSH.RegRead("HKLM\SOFTWARE\Tencent\PlatForm_Type_List\1\TypePath")
Set WSH = Nothing
ShellExecute 0&, "open", QQPath, vbNullString, vbNullString, 0&
End Sub

Private Sub Form_Load()
Command1.Caption = "QQ"
End Sub

网友(2):

print app.path
即可得到程序运行路径