我在VB6.0中写了一段公共对话框的程式,可以显示打开文件的控件,但不能打开所选中的问件,请各位大师指点一下,好吗?
解决方案 »
- 冰天雪地寒风刺骨等待解决办法,VB6.0用组件连接点崩溃问题
- vb 如何读取MS word里的内容,并返回如内容所在页码等信息
- 高手请进,vb6.0企业版 打sp5补丁,每次关闭vb的时候都报错,如何解决
- mscomm中的疑难问题,大伙帮帮忙,搞了一天了,还没搞出来
- 寻求webbrowser打开PDF,DOC文档后关于界面属性的控制方法
- VB调用delphi生成的dll文件错误,大家帮忙啊
- 散分!!!请教,各位大侠。怎么用vb做一个button打开d盘的一个文件,并读取数据。散分
- 如何对别的机器上共享的access数据库进行访问?
- 求教程
- 请问谁有匈牙利作曲家 鲁兰斯*查理斯的作品"黑色星期天",我做梦都想听听!!!!
- Listview只有两列数据,如何将其存入二维数组。
- 奇怪的后缀名问题,请教大家这到底是肿么了
'文件对话框只能获得所选择文件的路径并不能打开文件。
'测试以下代码,它能打开windows能识别的文件。Option ExplicitPrivate 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 LongPrivate Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
FLAGS As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Sub Command1_Click()
Dim ofn As OPENFILENAME
Dim rtn As String
ofn.lStructSize = Len(ofn)
ofn.hwndOwner = Me.hwnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = "TEXT (*.TXT)" & Chr$(0) & "*.TXT" & Chr$(0)
ofn.lpstrFile = Space(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = App.Path
ofn.lpstrTitle = "打开文件"
ofn.FLAGS = 6148
rtn = GetOpenFileName(ofn)
If rtn >= 1 Then
ShellExecute Me.hwnd, "open", ofn.lpstrFileTitle, vbNullString, _
Left(ofn.lpstrFile, InStrRev(ofn.lpstrFile, "\") - 1), 1 End IfEnd Sub