Under Windows 95, 98, and ME, if Notepad is not already open when the "Set Hook" button is pressed in the HookDemo2 executable, Notepad tends to produce a fault.
This makes no sense. The code for getting the handle to notepad is
VB Code:
  1. 'get handle to parent window
  2.   hWndParent = FindWindow(vbNullString, ParentCaption)
  3.   While hWndParent = 0
  4.     If MsgBox("Open Notepad", vbOKCancel) = vbCancel Then Exit Sub
  5.     hWndParent = FindWindow(vbNullString, ParentCaption)
  6.   Wend
As you can see, if notepad isn't open then Findwindow returns zero
Then a message box appears,
if the user presses OK, then findwindow is called again.
There is no difference between the first call to findwindow and the second.