help file closing when app closes in Vista

R

ray well

hi,

i have a app which has a help file, *.hlp, which the user can launch within
the program. i want the help file if it is open to close when the program
exists.

the way i did it till now is by running the following code when the program
closes

Dim proc, procs() As Process
procs = Process.GetProcessesByName("winhlp32")
For Each proc In procs
proc.Kill()
Next

i wasn't too haapy with this because it would close ALL open help files even
those not opened by my app. but i was in a rush when i developed this, i
didn't get any complaints, so i just let sleeping dogs lie.

my client just installed the app on a vista machine, and he gets errors from
this code when he closes the app. i tried removing the "proc.Kill()" line,
and he still gets the error. when i removed this whole bit of code the app
closes without complaining.(but the help file remains open) so apparently
vista doesn't like when u look at processes.

i don't have a vista machine.

how can i get the apps help file to close when the app exits on a vista
machine?

thanks for any help

ray
 
H

Herfried K. Wagner [MVP]

ray well said:
i have a app which has a help file, *.hlp, which the user can launch
within the program. i want the help file if it is open to close when the
program exists.

How are you showing the help file? Are you using the Win32 WinHelp API?
IIRC there was a flag that could be specified when opening the help file
which indicated that it should be closed automatically when the application
terminates.
 
R

ray well

How are you showing the help file? Are you using the Win32 WinHelp API?
IIRC there was a flag that could be specified when opening the help file
which indicated that it should be closed automatically when the application
terminates.

herfried,

thanks for your answer.

i used the Help class as in
Help.ShowHelp(Me, Application.StartupPath & "\MyApp.hlp")

i also sometimes just shelled out the help file.

how would i access the Win32 WinHelp API to launch it that way? would u have
a code snipet for this (which would also include that flag)? or know where i
can find an example?

i would appreciate that,. thanks,

ray
 
R

rowe_newsgroups

herfried,

thanks for your answer.

i used the Help class as in
Help.ShowHelp(Me, Application.StartupPath & "\MyApp.hlp")

i also sometimes just shelled out the help file.

how would i access the Win32 WinHelp API to launch it that way? would u have
a code snipet for this (which would also include that flag)? or know where i
can find an example?

i would appreciate that,. thanks,

ray

how would i access the Win32 WinHelp API to launch it that way? would u have
a code snipet for this (which would also include that flag)? or know where i
can find an example?

Here's the pinvoke.net page for WinHelp - though it's only in C#. Your
import statement for VB.Net should be:

<DllImport("user32.dll")> _
Public Shared Function WinHelp(ByVal hWndMain As IntPtr, ByVal
lpszHelp As String, ByVal uCommand As UInt32) As Boolean
End Function

http://pinvoke.net/default.aspx/user32/WinHelp.html

Thanks,

Seth Rowe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top