This makes no sense. The code for getting the handle to notepad isUnder 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.As you can see, if notepad isn't open then Findwindow returns zeroVB Code:
'get handle to parent window hWndParent = FindWindow(vbNullString, ParentCaption) While hWndParent = 0 If MsgBox("Open Notepad", vbOKCancel) = vbCancel Then Exit Sub hWndParent = FindWindow(vbNullString, ParentCaption) Wend
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.




Reply With Quote