VB中如何打开电脑中任意一个应用程序
怎么在VB中实现打开电脑中安装的任意一个应用程序,要求在所有机子上都可以实现(类似于某些游戏辅助程序中点击按钮就可以启动该游戏)。用shell函数能否实现?是否需要搜索应...
怎么在VB中实现打开电脑中安装的任意一个应用程序,要求在所有机子上都可以实现(类似于某些游戏辅助程序中点击按钮就可以启动该游戏)。
用shell函数能否实现?是否需要搜索应用程序的安装路径?
请高手指点下,最好有详细注释,以供学习,谢谢! 展开
用shell函数能否实现?是否需要搜索应用程序的安装路径?
请高手指点下,最好有详细注释,以供学习,谢谢! 展开
3个回答
2013-12-20
展开全部
Private Sub Command1_Click()
Dim i As Integer
Dim buf As String
CommonDialog1.Filter = "可执行文件(*.exe)|*.exe|所有文件(*.*)|*.*"
CommonDialog1.Flags = cdlOFNOverwritePrompt
CommonDialog1.ShowOpen
If CommonDialog1.CancelError Then Exit Sub
If CommonDialog1.FileName = "" Then Exit Sub
Label1.Caption = CommonDialog1.FileName
Shell Label1.Caption, vbNormalFocus
End Sub
Dim i As Integer
Dim buf As String
CommonDialog1.Filter = "可执行文件(*.exe)|*.exe|所有文件(*.*)|*.*"
CommonDialog1.Flags = cdlOFNOverwritePrompt
CommonDialog1.ShowOpen
If CommonDialog1.CancelError Then Exit Sub
If CommonDialog1.FileName = "" Then Exit Sub
Label1.Caption = CommonDialog1.FileName
Shell Label1.Caption, vbNormalFocus
End Sub
2013-12-20
展开全部
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 Sub Command1_Click()
CommonDialog1.Filter = "可执行文件(*.exe)|*.exe|所有文件(*.*)|*.*"
CommonDialog1.Flags = cdlOFNOverwritePrompt
CommonDialog1.ShowOpen
If CommonDialog1.FileName = "" Then Exit Sub
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
ShellExecute Me.hwnd, "open", Text1.Text, "", "", SW_SHOW
End Sub
Private Sub Command1_Click()
CommonDialog1.Filter = "可执行文件(*.exe)|*.exe|所有文件(*.*)|*.*"
CommonDialog1.Flags = cdlOFNOverwritePrompt
CommonDialog1.ShowOpen
If CommonDialog1.FileName = "" Then Exit Sub
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
ShellExecute Me.hwnd, "open", Text1.Text, "", "", SW_SHOW
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-20
展开全部
这样就可以Private Sub Command1_Click()Shell "b.exe"End Sub给你个连接,学习下吧,呵呵 http://www.xuevb.net/modules/news/article.php?storyid=781
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询