This isn't the exact code. It was just an example... It happens on a giving
If statement. The first code I had this problem with was similar to the
previous post... and dealt with managed code.
This is the function I'm having an issue with currently
Public Sub InstallHooks()
If hMouseHook = 0 Then
MouseHookProcedure = New Win32.HookProc(AddressOf MouseHookProc)
hMouseHook = Win32.SetWindowsHookEx( _
Win32.WH.WH_MOUSE_LL, _
MouseHookProcedure, _
Marshal.GetHINSTANCE(Reflection.Assembly.GetExecut ingAssembly().GetModules()(0)), _
0)
If hMouseHook = 0 Then 'SetWindowsHookEx failed
RemoveHooks()
Throw New Exception("SetWindowsHookEx failed.")
End If
End If
If hKeyboardHook = 0 Then ' install Keyboard hook
KeyboardHookProcedure = New Win32.HookProc(AddressOf
KeyboardHookProc)
hKeyboardHook = Win32.SetWindowsHookEx( _
Win32.WH.WH_KEYBOARD_LL, _
KeyboardHookProcedure, _
Marshal.GetHINSTANCE(Reflection.Assembly.GetExecut ingAssembly().GetModules()(0)), _
0)
If (hKeyboardHook = 0) Then 'SetWindowsHookEx failed
RemoveHooks()
Throw New Exception("SetWindowsHookEx failed.")
End If
End If
End Sub
even though hKeyboardHook is not 0 it executes Throw New
Exception("SetWindowsHookEx failed.") in the last if.
I can post the rest of the code if you want to try too reproduce the
behavior...
Thanks
"RobinS" wrote:
Doesn't do it under my version of VS2005. What else is in the routine
where you're running this?
Robin S.
-------------------------------------------------
"carbo" <ca***@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
I am getting odd behavior in my code, first I thought it was caused by
SP1
but now I have the same issue with a vanilla version of VS 2005. When
I
execute a function that contains an if statement. i.e.
Dim b As Boolean
Dim i As Integer = 0
If b then
i += 1 'point 1
msgbox(i.toString()) ' point 2
End If
the problem is even though the condition is false the code enters at
point
2... and the messagebox appears... What the hell is up with that? I've
look
up to see if there is anything online but can't find any answers.
Closing VS
2005 doesn't work... Rebooting doesn't work... Can anyone help!