Basically: I would like a sendmessage and sendmessagetimeout API for VB.NET that others have used and know works.
I need an API for sendmessage and sendmessagetimeout for my VB .net application. I have searched quite a bit, and everything I find doesn't seem to work: either the message just doesnt seem to be sent, or the message appears to be sent with the msg parameter always 0, and the wparam setting as what I enter for the msg setting. Pinvoke's also always seems to throw an AccessViolationException for I have no idea what reason. I tried playing around with maybe just where I put the variable, but unsurprisingly, there is not a simple logical switch of the variables.
I have tried pinvoke's:
<DllImport("user32.dll", SetLastError:=True)> _
Public Shared Function SendMessageTimeout(ByVal windowHandle As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr, ByVal flags As SendMessageTimeoutFlags, ByVal timeout As Integer, ByRef result As IntPtr) As IntPtr
End Function
and allapi's:
Declare Function SendMessageTimeout Lib "user32" Alias "SendMessageTimeoutA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As String, ByVal fuFlags As Long, ByVal uTimeout As Long, lpdwResult As Long) As Long
among others, and they just dont seem to work.
So I would like to know of whatever APIS for sendmessage and/or sendmessagetimeout you know of that work! If there just aren't correct APIs for VB.net for these functions, what alternative functions that I could use to accomplish the same task as those 2?
Thank you in advance for any information you have :)
EDIT:
alternatively I may be sending the message incorrectly, so just to make sure that shouldn't be the issue:
I want to send WM_WININICHANGE, so I am using:
- hwnd = HWND_BROADCAST = 0xffff = 65535
- msg = WM_WININICHANGE = 0x001A = 26
- wparam and lparam of 0
but I have tried with other values for wparam and lparam with no difference usually. when trying sendmessagetimeout, I also use:
- flags = SMTO_ABORTIFHUNG = 2
- timeout = 1000 = 1 second
- then 0 for result.