|
'ВАРИАНТ1
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)
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()
startdoc = ShellExecute(Scr_hDC, "Open", DocName, "", "C:\",
1)
End Function
Private Sub Command1_Click()
Dim r As Long
'укажите путь к вашему файлу
r = startdoc("D:\garbage\garik.xls")
End Sub
'ВАРИАНТ2
Предположим, у вас есть файл в формате htm. Вам
необходимо открыть его в программе по умолчанию
(у большинства это ИнтернетЭксплорер). Данный код
запустит Эксплорер и откроет в своем окне
указанный вами htm-файл.
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
Const SW_SHOWMAXIMIZED = 3
'использование
ShellExecute 0, "open", "D:\Basic\htm\api01.htm", "",
"", SW_SHOWMAXIMIZED
'или
'ShellExecute 0, "open", "api01.htm", "", "",
SW_SHOWMAXIMIZED
|
|