菜鸟级问题

mimile 2000-09-10 04:12:00
用shell语句只能执行exe文件,我想请问一下如何执行其他文件.就像在"我的电脑"里双击一样.用windows里的其它软件把文件打开,vb只起到一个调用的作用.
...全文
116 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
OLD_VB_FAN 2001-05-31
  • 打赏
  • 举报
回复
GZ
skt642 2001-05-31
  • 打赏
  • 举报
回复
80885关注!
prefix 2000-09-10
  • 打赏
  • 举报
回复
shell "start.exe d:\1.chm",这样更方便。可以是任一类型的。
xiali 2000-09-10
  • 打赏
  • 举报
回复
这有一个示例:
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 GetDesktopWindow Lib "user32" () As Long

Function StartDoc(DocName As String) As Long
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()

'change "Open" to "Explore" to bring up file explorer
'StartDoc返回数值31时,没有可打开的应用程序
StartDoc = ShellExecute(Scr_hDC, "Open", DocName, "", "", 1)

'ShellExecute:lpOperation有三个参数:"Open" ,"Explore","Print";
'当使用"Open"时,可对文件、程序等直接打开或运行;对文件夹,按"我的电脑"方式打开
'当使用"Explore"时,对文件,程序不起作用;对文件夹,按资源管理器方式打开.
'以下两行可以直接使资源管理器进入指定路径,并自动打开管理器
'DocName = "D:\Microsoft Office\Templates"
'StartDoc = ShellExecute(Scr_hDC, "Explore", DocName, "", "", 1)
End Function

'对话框按钮返回"DocName"调用字符串
Private Sub Command1_Click()
Dim r As Long
r = StartDoc(Trim(Text1.Text))
End Sub
dageming 2000-09-10
  • 打赏
  • 举报
回复
SHELL中加入打开该文件的关联文件就可以,如
Shell "hh " & App.Path & "\youfile.chm", vbNormalFocus
NiceFeather 2000-09-10
  • 打赏
  • 举报
回复
查一下ShellExecute这个API函数!试一下
Public 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

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧