473,661 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the string passed by SendMessage?

1. I am using SendMessage (HWND_BROADCAST , WM_FONTCHANGE, 0,
(LPARAM)pFileNa me); in C++ side
2. In WndProc, I wanted to get the fileName from m.lparam, which is a
IntPtr. How can I convert it to a string in C#

Thanks.
Aug 15 '06 #1
2 2517
Gary,

You can pass this to the IntPtr to the static PtrToStringAnsi or
PtrToStringUni methods on the Marshal class depending on what version of
SendMessage was called (SendMessageA, or SendMessageW).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Gary" <Ga**@discussio ns.microsoft.co mwrote in message
news:87******** *************** ***********@mic rosoft.com...
1. I am using SendMessage (HWND_BROADCAST , WM_FONTCHANGE, 0,
(LPARAM)pFileNa me); in C++ side
2. In WndProc, I wanted to get the fileName from m.lparam, which is a
IntPtr. How can I convert it to a string in C#

Thanks.

Aug 15 '06 #2
Gary wrote:
1. I am using SendMessage (HWND_BROADCAST , WM_FONTCHANGE, 0,
(LPARAM)pFileNa me); in C++ side
2. In WndProc, I wanted to get the fileName from m.lparam, which is a
IntPtr. How can I convert it to a string in C#

Thanks.
I'm not sure that pointer is valid in other applications/processes
(other than one that call SendMessage). Check WM_COPYDATA if you need IPC.

Regards,
Goran
Aug 15 '06 #3

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

Similar topics

5
5852
by: Adam Clauss | last post by:
I am attempting to set the text on a richedit control in another application using EM_SETTEXTEX: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditmessages/em_settextex.asp I have the following: public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
0
1026
by: Tim Mulholland | last post by:
I asked this a few days ago and never got a response. Hopefully someone can help me now as i'm giving more information I have an MFC app that i'm trying to send messages to using the SendMessage API. Here is the signature and the first line of code for the function that receives this message in the MFC application: LRESULT CMainFrame::OnLoadVidAnaly( WPARAM wParam, LPARAM lParam )
10
5749
by: muntyanu | last post by:
Hi all, In C# system service I need to get some string from MFC mainframe window by SendMessage() API call. I managed to send message, but can not find the way to return string to C# app. Is that possible to receive string back in C# from return value, wparam or lparam? Please if someone did it post the example,
1
1683
by: Daniel Halan | last post by:
Hello, I want to send a SendMessage(hwnd,...) to an another application containing eighter a "String" or a PIDL... I know that the pointer lives in its own process so the other app will have problems reading it. How was it done to create the String / PIDL in a common memoryspace? What I want to do is: string szFolder = @"C:\temp\";
14
1830
by: Erik | last post by:
Hi, i'm trying to do this : #include <stdlib.h> #include <stdio.h> #define FILE "/tmp/myfile" #define USERS_LIST "/tmp/userslist" int main() { //open file
3
2661
by: growse | last post by:
Right, I've got a 2 c# programs here. Lets call them A and B. My aim is to send a simple string from B to A. A is always running. I've overridden the WndProc method to give me messages that are sent to it. B is a program that loads, sends a message and then quits. Let me give you the code to B (bits are missed out, but I've got the important stuff there): private const uint WM_USER_SENDTEXT = 0x8001;
4
2128
by: Abubakar | last post by:
Hi, My application has a lot of threads which at some point call SendMessage api passing it the handle of the gui window. The calls r a lot. My question is that should I call the SendMessage api by protecting it in a critical section, or the SendMessage api itself handles this kind of situation where a lot of threads in the same process r calling it. Regards,
2
12524
by: Mayur | last post by:
I tried followinf but working fine fo int but how to do it for string using user custome message in c# public static extern int FindWindow(string strClassName,string strWindowName);
14
12632
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 dont have this in normal). So i decided to use the EnumWindows with SendMessage. What i try here is to pass a WM_USER+1111 with LParam and WParam, pointing to strings. But when i try to get the strings at the other end with Marshal.PtrToStringAnsi,
0
8855
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7364
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5653
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.