|
priyank_ldce wrote: I post this string using WPARAM parameter of postmessage() function...
What does this look like?
priyank_ldce wrote: ...but on the receiver side I get nothing.
How are you handling the message?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Since you posted no code, I'm guessing here ...
But it sounds like you are using a CString object and passing it to PostMessage:
{
CString strMyData = "Junk";
PostMessage(SomeHwnd, SomeMsg, (LPARAM)(LPCTSTR)strMyData, 0);
}
This won't work since when the CString goes out of scope, it is cleaned up. Thus, when your window gets the message, the pointer to the memory is no longer valid for that string.
Is there some reason you are using PostMessage instead of SendMessage? If you are able to switch (generally, PostMessage is used in applications that need to be redesigned/refactored), the code will work, so long as you make a copy of the LPCTSTR in the handler receiving the message.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
priyank_ldce wrote: Here my string is of type LPCSTR without null-termination.
How do you know its length then?
|
|
|
|
|
you can try AddAtom()
just a suggession, because I have used it in a my project where I was failing in my all trys, about passing a string at just my application window creation time.
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
Tanvon wrote: AddAtom
it has text limit of 255 only... i don't believe this will help + as the guy want that string is not null terminated!.. so AddAtom Api(not function ) will work in his case!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
if u are sending the string to a window in another process, this should not work since independent processes have independent memory spaces - no shared memory segments..
if u r sending it to the same process, make sure it doesnt go out of scope.
Mohamad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
If you like a simple IPC via messaging, use WM_COPYDATA message. You could send data with this message to another window. This article shows how.
Best,
Jun
|
|
|
|
|
Jun Du wrote: If you like a simple IPC via messaging, use WM_COPYDATA message. You could send data with this message to another window. This article shows how.
good example.. but you can still send it by GlobalAlloc!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Absolutely. I thought he was looking for some simple data exchange via messages.
Best,
Jun
|
|
|
|
|
Thanks for your reply.
Now I am using WM_COPYDATA to send string to my other application. I also want to send 2 integer values with this string. So, I made a structure of 1 string and 2 integers. But on the other side I am able to get 2 integer values but not string. I get blank string on that side. Here I am sending my code.
Sender application
struct MYDATASTRUCT
{
LPCSTR myString;
int myX;
int myY;
};
MYDATASTRUCT myStringData;
myStringData.myX = X;
myStringData.myY = Y;
myStringData.myString = lpString;
COPYDATASTRUCT myData;
myData.dwData = 0;
myData.cbData = sizeof(myStringData);
myData.lpData = &myStringData;
::SendMessage(g_mainHwnd,WM_COPYDATA,NULL,(LPARAM)&myData);
Receiver application
PCOPYDATASTRUCT myData = (PCOPYDATASTRUCT)lParam;
MYDATASTRUCT* myStringData = (MYDATASTRUCT*)myData->lpData;
int X = myStringData->myX;
int Y = myStringData->myY;
LPCSTR lpString = myStringData->myString;
Now when I am sending this string directly without structure and integer value I am able to get that string on receiver application.
Can anyone find what is the problem with structure code?
Thanks,
Priyank
|
|
|
|
|
Actually I made an API Hook DLL to hook any application for ExtTextOut() winapi. Now when my DLL get this api call I need to process string in my other application. But I am not able to send or post this string to my application. Any suggestion how can I get this string in my application?
Thanks,
Priyank
|
|
|
|
|
I have seen in a couple of places a mention by Microsoft that WMI Performance counters are only a Windows 2K technology. Is this really true? If it is, what are we supposed to use going forward?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
I have a few singleton classes which I would like to be truely single. i.e. I only want one instance between processes, users and sessions. I have found many articles on multithreaded singletons, but this does not address the memory scope problem. I could use a mutex to check for another instance, but what is the best way to share an instance?
|
|
|
|
|
There could be various solutions to this problem.
Preferrably using mutex's .
something like
HANDLE hMutex;
hMutex = CreateMutex(
NULL, // no security attributes
FALSE, // initially not owned
"SomeUniqueName"); // name of mutex
If this exists already return from the application.
Another option would be to use a shared variable and check for its value. Increment it each time an instance is created. If the value is greater than one you can just return from the second instance.
The third option would be to use the FindWindow function. You would get the handle to the window if it's already running.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Sorry if I didn't make it clear in my post. I am not talking about a single instance of an application, but infact a single instance of a class which is to be shared amongst multiple instances of an application.
|
|
|
|
|
waldermort wrote:
Sorry if I didn't make it clear in my post. I am not talking about a single instance of an application, but infact a single instance of a class which is to be shared amongst multiple instances of an application.
look for com classes!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Thankyou, that has put me back on the right track
|
|
|
|
|
this is definitely a Copy/Paste of your previous answer... you didn't read the question
|
|
|
|
|
You need some form of inter-process communications for that solution. There are numerous techniques for that so currently your question is way to broad.
"I've found that the shortcomings of human nature have little to do with nationality." Christopher Duncan in the Lounge
led mike
|
|
|
|
|
Hi WalderMort !
Your question is very interesting. I have the same problem with my application.
One of the possible solution is to define class as global, and then to use directive "extern" to get access to his members from any other part of your application.
I am using this method, and it work just fine.
|
|
|
|
|
Lambry wrote: One of the possible solution is to define class as global, and then to use directive "extern" to get access to his members from any other part of your application.
you can't share data between two exe.. using that method!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Well ... Alok Gupta, may be I understand question of WalderMort in deferent way, but tell me where in the sentences of that post is talking about different *.exe's ?
|
|
|
|
|
|
Thank You Alok Gupta !
In this case I only can tell:
- How to help to person (like WalderMort) that even cant ask a question in a right way? I am sorry that I lost my time, for nothing. And in addition your time Alok, and lot of space here in Code project.
|
|
|
|
|
Lambry wrote: How to help to person (like WalderMort) that even cant ask a question in a right way?
actually.. here knowledge of langauge is problem... actualy people sometime fails to express there problem.. that doesn't mean they are good programmer.. you don't need to be sorry.. actually i posted after reading evrybody comments.. there fore.. might be i commented over your statement.. anyways i am sorry.. if i am rude!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|