您的位置:首页 > 编程语言 > VB

按键(vb)启动指定目录的程序以及获取当前应用路径

2013-11-14 20:55 537 查看
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private 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 Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Sub openApp(path)
Dim P, I, DirPath, ExeName
P = Split(path, "\")
For I = 0 To UBound(P) - 1
DirPath = DirPath & P(I) & "\"
Next
ExeName = P(UBound(P))
ShellExecute GetDesktopWindow, "open", ExeName, vbNullString, DirPath, 5
End Sub

Function appPath()
str = string(1024, 0)
GetModuleFileName 0, str, len(str)
appPath = Replace(str, split(str, "\")(ubound(split(str, "\"))), "")
End Function


上面分别是启动指定目录下的应用程序以及查找应用程序所在的当前路径~~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐