473,503 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SendMessage API with strings as parameters

I think the problem i'm having is a little bigger than this, but i hope the
answer to this question will send me down the right path.

I'm calling the SendMessage API function from C#. I've got it so i cna send
the messages fine normally using this declaration:

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern uint SendMessage(IntPtr hWnd, int Msg, IntPtr wParam,
IntPtr lParam);

but i have a call that i need to make now that actually uses the wParam
value. (i had just been passing IntPtr.Zero in all other working cases).

this function requires wParam to be a string that specifies what should go
on when that message is received.
I've been looking through all kinds of information and can't figure out what
i'm supposed to do. Marshaling seems like the right direction, but you can't
Marshal a string without knowing the length at compiletime right? (so you
can set the [MarshalAs(UnmanagedType.ByValTStr, SizeConst=90)] type of
attributes and all that?)

So what are my options here?

Thanks in advance,

-Tim
Nov 16 '05 #1
2 2267
Tim,
I've been looking through all kinds of information and can't figure out what
i'm supposed to do.


Add another overload where wParam is typed as string

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern uint SendMessage(IntPtr hWnd, int Msg, string
wParam, IntPtr lParam);

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
that doesn't work.
the string comes through on the other end as gibberish.
i reposted another thread about this on the 29th at 4:04pm if you want to
see more information...

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OV**************@TK2MSFTNGP15.phx.gbl...
Tim,
I've been looking through all kinds of information and can't figure out whati'm supposed to do.


Add another overload where wParam is typed as string

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern uint SendMessage(IntPtr hWnd, int Msg, string
wParam, IntPtr lParam);

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2144
by: Sn | last post by:
Does anyone know how to use the SendMessage() function to save a text file in UTF-8 format. what are the Msg, Wparam and the lParam parameters passed to the function?
2
11769
by: Erik | last post by:
I am having trouble getting this to work so hopefully someone can provide some insite. I have a structure that I store in a CopyDataStruct which is then send to another application via...
6
4162
by: Steve | last post by:
I am trying to use the SendMessage API function using EM_POSFROMCHAR to get the x,y location of the current character. I have declared the function and placed the call into my code. How do I...
4
2340
by: jbhan | last post by:
Hi, I am trying to find text in a window. I can get the handle to the window but when I try using SendMessage the return value is very large number. When I use Spy++ to see the return value it...
2
11513
by: James Burrow | last post by:
Hi, I am trying to write a 2 .net programs that can communicate via windows messages. I have achieved this but only just passing ints. When i try and pass a string, i get junk out. I guess this...
3
1524
by: Tim Mulholland | last post by:
I just realized i had been posting under a managed newsgroup account that had expired. hopefully this one works better and gets me a response from Microsoft.. I have an MFC app that i'm trying...
18
6535
by: Lars Netzel | last post by:
Hello! Thanx to this newgroup I have finally, with the help of you guys, gotten this to work halfway.. but the final action is still not working, clicking the "Button2" thru SendMessage(). ...
22
9187
by: SQACSharp | last post by:
I'm trying to get the control name of an editbox in another window. The following code set the value "MyPassword" in the password EditBox but it fail to return the control name of the EditBox. ...
14
12608
by: Kerem Gümrükcü | last post by:
Hi, i want to emulate a (synchronous) BroadCastSystemMessage with EnumWindows and SendMessage. I dont want to use the BroadcastSystemMessage because it needs the SE_TCB_NAME Privilege (you...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.