i am using SendMessage to send a message with a LPTSTR in WPARAM from a dll to my vb.net form and i get it by overriding WndProc but the problem is when using Marshal.PtrToStringAuto on the WPARAM it doesn't work, the strange thing is that if i monitor WM_SETTEXT of the form and use PtrToStringAuto to get the string from LPARAM it works, i guess mine doesn't work that's because the dll is loaded by other application.
C++ DLL Proc
LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam)
{
VB.NET Code
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Try
Select Case m.Msg
Case MyMsgs.WM_SETTEXT
'i successfully get the pointer but can't get the text
Me.Text = System.Runtime.InteropServices.Marshal.PtrToStringAuto(m.WParam)
Catch ex As Exception
Debug.WriteLine("Error Messages : " & ex.Message )
Finally
MyBase.WndProc(m)
End Try
End Sub
HanneSThEGreaT
May 28th, 2009, 08:10 AM
We'll need much more information, like :
How did you implement this API function ¿
How is it called ¿
What do you want to do precisely in your program ¿
PS, please don't type in bold format, it's quite straineous on the eyes
komalo
May 29th, 2009, 07:28 AM
We'll need much more information, like :
How did you implement this API function ¿
How is it called ¿
What do you want to do precisely in your program ¿
PS, please don't type in bold format, it's quite straineous on the eyes
it is not an api , my program has a global hook proc , i moniter WM_SETTEXT messages and send the LPSTR to my program through SendMessage to my Form, the hook proc works fine because i moniter other messages, and i receive the pointer successfully the problem that when using that IntPtr (the pointer) in Marshal.PtrToStringAuto i don't get the string, i even tried to send a normal message with my string to the form but i couldn't get the string
PS, sorry for the bold font i modified the post it now
HanneSThEGreaT
May 29th, 2009, 07:55 AM
SendMessage is an API, so it is an API.
How did you implement this ¿
Show us some code please, otherwise we'll sit here guessing until eternity.
If we don't know how you have sent the message through the SendMessage API, we cannot know the format of the sent message, as well what you want to do with it.
komalo
May 29th, 2009, 08:04 AM
SendMessage is an API, so it is an API.
How did you implement this ¿
Show us some code please, otherwise we'll sit here guessing until eternity.
If we don't know how you have sent the message through the SendMessage API, we cannot know the format of the sent message, as well what you want to do with it.
I know that it is an API , i was talking in general i don't implement any thing , BUT I USE SendMessage IN THE C++ HOOK DLL NOT VB.NET
C++ DLL Proc
LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam)
{
VB.NET Code
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Try
Select Case m.Msg
Case MyMsgs.WM_SETTEXT
'i successfully get the pointer but can't get the text
Me.Text = System.Runtime.InteropServices.Marshal.PtrToStringAuto(m.WParam)
Catch ex As Exception
Debug.WriteLine("Error Messages : " & ex.Message )
Finally
MyBase.WndProc(m)
End Try
End Sub
HanneSThEGreaT
May 29th, 2009, 08:59 AM
I know that it is an API , Right, now we all know it is an API. I'm not here to argue, I just want the members to understand the situation.
i was talking in general i don't implement any thing , BUT I USE SendMessage IN THE C++ HOOK DLL NOT VB.NET
C++ DLL Proc
LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if( (lParam!=NULL) && (nCode == HC_ACTION))
{
CWPSTRUCT *CwpStruct = (CWPSTRUCT *) lParam;
switch(CwpStruct->message)
{
case WM_SETTEXT:
SendMessageTimeout(hWnd,WM_USER + 2,WPARAM(CwpStruct->lParam),LPARAM(CwpStruct->hwnd),SMTO_ABORTIFHUNG,100,0);
break;
}
}
return CallNextHookEx(hHook,nCode,wParam,lParam);
}
If this was included in the first post, we wouldn't even hav had an argument. Now we all know what the situation is, now we can help, agree ¿
I'll play with this at home tonight
komalo
May 31st, 2009, 07:38 AM
Right, now we all know it is an API. I'm not here to argue, I just want the members to understand the situation.
If this was included in the first post, we wouldn't even hav had an argument. Now we all know what the situation is, now we can help, agree ¿
I'll play with this at home tonight
yes i know, i was bad in explaining it, any way i add the code to the main post
thanks in advance
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.