|
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
|
|
|
|
|
hi,
i am working as a VC++ devloper.i want to write a method in the doc .which will call the method in the view.can i do like this?plz help me.
|
|
|
|
|
I can almost guarantee this is not how you want to organize this. What exactly are you trying to accomplish (that is, what is being done to the View that you think you want the Document to initiate it?)
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
|
|
|
|
|
ramanand_bulusu wrote: ant to write a method in the doc .which will call the method in the view.can i do like this?plz help me.
GetDocument api will work!
"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
|
|
|
|
|
ThatsAlok wrote: GetDocument api will work!
there is no such API called GetDocument.
I again confirmed it from MSDN for my surety.
It is a member function of CView class
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
Tanvon wrote: there is no such API called GetDocument.
I again confirmed it from MSDN for my surety.
It is a member function of CView class
Isn't i know that.... GetDocument itself imply that it will retrive the pointer to the document class associated with view... isn't are anybody using WIn32 to simulate DOC-View architecture....i believe no..
and tell me what is MFC?.. a thin wrapper over win32!.
here what actual coding of GetDocument gives
_AFXWIN_INLINE CDocument* CView::GetDocument() const
{ ASSERT(this != NULL); return m_pDocument; } Actually many people here doesn't think what is api and what is funtion....
like for Example if you use FindWindow() it is api... and CWnd::FindWindow() it is function..
but if you refer them ... you will use this api or that api... what is api at end a function which providing
application programming interface
"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
|
|
|
|