|
-
Jul 9th, 2001, 05:51 AM
#1
Thread Starter
Fanatic Member
unknown shell
Hi
i have made a help file for my program in html, so the file is an html file, the files will be inlcuded in my package for my program, but i don't know where the program will be installed to, so i don't think i can make a normal shell command, what i need is a command that will open this file (index.html) from the directory that the program is in when the button is pressed, if this makes any sense, please help, if it doesn't then i will try again 
thanks for any help
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Jul 9th, 2001, 05:59 AM
#2
Frenzied Member
App.Path will return the path the .EXE is in during runtime. So you can do something like
Shell "START "+App.Path+"\myhelp.html"
Last edited by Buzby; Jul 9th, 2001 at 06:05 AM.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Jul 9th, 2001, 06:00 AM
#3
-= B u g S l a y e r =-
Try using ShellExecute :
Code:
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Public Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
Dim l As Long
l = ShellExecute(Me.hwnd, "Open", App.Path & "\index.html", "", "C:\", SW_SHOWNORMAL)
End Sub
-
Jul 9th, 2001, 06:09 AM
#4
Thread Starter
Fanatic Member
cheers guys
Buzby - your just came up with file not found, not sure why because it was there.
Peet - cheers yours worked well, though i needed to make the declarations private
Thanks for your help guys
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Jul 9th, 2001, 06:40 AM
#5
-= B u g S l a y e r =-
The Shell function will only execute programs, while the ShellExecute function will launch a file with its default application.
-
Jul 9th, 2001, 06:47 AM
#6
Thread Starter
Fanatic Member
that would explain why i was having fun with the shell command,
thanks for your help again
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Jul 9th, 2001, 07:06 AM
#7
-= B u g S l a y e r =-
-
Jul 9th, 2001, 11:07 AM
#8
Member
Note that if a file is not found with ShellExecute, there is no way that I know of to detect that. It just executes ShellExecute, and nothing happens.
-
Jul 9th, 2001, 11:17 AM
#9
-= B u g S l a y e r =-
filburt1
you have to check the value returned when executing shellexecute ...
try this :
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Const SW_SHOWNORMAL = 1
Const SE_ERR_FNF = 2&
Const SE_ERR_PNF = 3&
Const SE_ERR_ACCESSDENIED = 5&
Const SE_ERR_OOM = 8&
Const SE_ERR_DLLNOTFOUND = 32&
Const SE_ERR_SHARE = 26&
Const SE_ERR_ASSOCINCOMPLETE = 27&
Const SE_ERR_DDETIMEOUT = 28&
Const SE_ERR_DDEFAIL = 29&
Const SE_ERR_DDEBUSY = 30&
Const SE_ERR_NOASSOC = 31&
Const ERROR_BAD_FORMAT = 11&
Private Sub Command1_Click()
Dim l As Long
Dim msg As String
l = ShellExecute(Me.hwnd, "Open", App.Path & "\index.html", "", "C:\", SW_SHOWNORMAL)
If l <= 32 Then
'There was an error
Select Case l
Case SE_ERR_FNF
msg = "File not found"
Case SE_ERR_PNF
msg = "Path not found"
Case SE_ERR_ACCESSDENIED
msg = "Access denied"
Case SE_ERR_OOM
msg = "Out of memory"
Case SE_ERR_DLLNOTFOUND
msg = "DLL not found"
Case SE_ERR_SHARE
msg = "A sharing violation occurred"
Case SE_ERR_ASSOCINCOMPLETE
msg = "Incomplete or invalid file association"
Case SE_ERR_DDETIMEOUT
msg = "DDE Time out"
Case SE_ERR_DDEFAIL
msg = "DDE transaction failed"
Case SE_ERR_DDEBUSY
msg = "DDE busy"
Case SE_ERR_NOASSOC
msg = "No association for file extension"
Case ERROR_BAD_FORMAT
msg = "Invalid EXE file or error in EXE image"
Case Else
msg = "Unknown error"
End Select
MsgBox msg
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|