|
Hello!
I'm currently trying to implement some data exchange using the WM_COPYDATA inter-process communication mechanism. Sending data from one application from one application to another works fine, but now they should communicate, i.e. the other application should answer the first application.
How can this be implemented? Just sending back data using WM_COPYDATA obviously cannot work: the first application sends data to the second window and blocks (SendMessage), the second one sends data to the first window and blocks, both block as the first window is also blocked. Unfortunately, PostMessage cannot be used with WM_COPYDATA, SendMessage must be used.
Best regards
Dominik
<hr><i><font face="arial" size="2"><code>_outp(0x64, 0xAD);</code>
<small>and</small>
<code>__asm mov al, 0xAD __asm out 0x64, al</code>
<small>do the same... but what do they do?? </small>
<small>(doesn't work on NT)</small></font></i>
|
|
|
|
|
Use SendMessageTimeout instead of SendMessage. Your app will not hang indefinitely if the other app does not respond. Also you could fire up a second thread to send the message from, that way only a subthread hangs not the entire app.
You may be right
I may be crazy
But it just may be a lunatic you’re looking for
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Hi I'm an intern currently attached to a programming company and I just need to know how to
1) Transmit "something" for 2250ms or Stop once I'm done transmitting all my messages. (I have a counter to know how many messages are in my queue)
I know it has something to do with threads and handles and waitforsingleobject but I can't seem to link them together. Please help.
Just a simple algorithm will do though a sample source code would really help. Thx alot
|
|
|
|
|
Your message is not very clear (you don't explain what needs to be sent and where...).
But ok, maybe you are just interested in the part with the Thread. In fact, yes you are right. The thing you have to to is start a thread (CreateThread for example), and to this thread you can pass the handle of the window which needs to receive messages from your thread (when the process is finished). In your thread, you make a loop to send all your messages and when it's done, you send a owner defined message to your window message queue. So, in your main window, you know that data has been sent.
The use of a separate thread is there to allow the UI not to 'freeze' when you send all your messages.
|
|
|
|
|
Oh very sorry bout that.
I'm actually making a simulator that will receive a stream of bytes from a user-defined port, I've already stripped the message, decoded it and also managed to send the appropriate reply (stream of bytes back) through a seperate user-defined port.
Now the problem is that I don't know how to send my byte array through the port within a time window of 2250ms (Maximum) or terminate the transmission if the message is all sent before the 2250ms. I thought this is similar to the token ring network but they don't send within time windows.
Thanks alot for replying Cedric.
p.s. After I create a thread I make a loop in the thread the same way I make loops in functions? I'm totally new to this thread stuff..
|
|
|
|
|
Yes, a thread is simply a function that will be called in parallel with the rest of your program. So that means that if you lock something in your main thread; your second thread will continue to run independantly.
So, in your thread, you'll need to receive data and store them somewhere accessible from the rest of your program. But warning ! You need to secure your data to avoid both thread trying to access it at the 'same time'. Take a look at CriticalSections[^] for example.
|
|
|
|
|
Hi,
Can anyone pls. explain what are the dis-advantages of connecting to ORacle through DSN rather than using Pro C.
I wish to learn Pro C to connect to Oracle from VC++ is there any article to go about from the start.
Thanks,
Arun.
|
|
|
|
|
arunperi wrote: ...what are the dis-advantages of connecting to ORacle through DSN rather than using Pro C.
You are comparing apples to oranges here. A DSN is language independent.
arunperi wrote: I wish to learn Pro C to connect to Oracle from VC++ is there any article to go about from the start.
As long as you are able to access the ODBC API, you're fine.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
My doubt is:
We have two methods through which anyone can connect to Oracle from VC++:
a)through DSN
b)using Pro C
which of these methods is better, obviously it must be through Pro C in such case, what are the advantages or dis-advantages of each.
Hope you have understood my doubt,
Thanks.
|
|
|
|
|
arunperi wrote: ...obviously it must be through Pro C...
Why would that be obvious? What metrics do you have?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
how can i get the Names of machines along with the IP address on a network ? it will be of a great help .
Thanks in advance
kss
|
|
|
|
|
use WNetOpenEnum,WNetEnumResource with the NETRESOURCE structure
Populate the functions and you will get the names of the machines
Pass the names of the machines as szHostName :
gethostname( szHostName, strlen( szHostName ) );
host = gethostbyname(strFullName);
ptr = (struct in_addr *) host->h_addr_list[0];
int a = ptr->S_un.S_un_b.s_b1;
int b = ptr->S_un.S_un_b.s_b2;
int c = ptr->S_un.S_un_b.s_b3;
int d = ptr->S_un.S_un_b.s_b4;
strTemp.Format("%s %d.%d.%d.%d",strFullName,a,b,c,d);
To get the IP Address of the machines in the network
Wishes.
Anshuman Dandekar
Dare to Dream,
Care to Achieve.............
|
|
|
|
|
Thanks Ansuman,
There is one more doubt
When i am trying to compile my application in MFC using WNet. it is throwing Unresolved External Symbols and the Mangled Function name
Why ? so
kss
|
|
|
|
|
Did you include the file mpr.lib
you can do this as follows
project>settings>links/object/library modules and add mpr.lib in that box
Wishes.
Anshuman Dandekar
Dare to Dream,
Care to Achieve.............
|
|
|
|
|
Yes i did not include the mpr.lib , Thanks again for this help. I will test it out.
kss
|
|
|
|
|
AnShUmAn_VCPP wrote: gethostname( szHostName, strlen( szHostName ) );
This retrieves the name of the local machine only.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
You probably didnt't pass the parameters properly.
This is the height of proper values being needed to be passed in the functions.
You didn't specify what value did you pass in this function ?.
once you pass resource_globalnet as the first parameter you can get all the machine names in the network.Resoucetype_any specifies that the resource could be anything like a printer etc.
WNetOpenEnum( RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, pnr, &hEnum );
WNetEnumResource( hEnum, &count, buf, &bufsize );
Vision is important and so is ATTITUDE.
Wishes.
Anshuman Dandekar
Dare to Dream,
Care to Achieve.............
-- modified at 22:33 Monday 20th February, 2006
|
|
|
|
|
AnShUmAn_VCPP wrote:
You probably didnt't pass the parameters properly.
Sure I did.
AnShUmAn_VCPP wrote: This is the height of proper values being needed to be passed in the functions.
Not sure what this says.
AnShUmAn_VCPP wrote: You didn't specify what value did you pass in this function ?.
Huh?
AnShUmAn_VCPP wrote: once you pass resource_globalnet as the first parameter...
gethostname() only takes two arguments, neither of which is RESOURCE_GLOBALNET .
Re-read this thread to see where you got confused.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
WNetOpenEnum( RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, pnr, &hEnum );
Pass Globalnet option in this function .See my previos post to this question
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
AnShUmAn_VCPP wrote: WNetOpenEnum( RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, pnr, &hEnum );
Pass Globalnet option in this function
I very well versed in its usage. Thanks.
AnShUmAn_VCPP wrote: See my previos post to this question
Your initial response to "fearless" is where things went awry. For some unknown reason, you suggested that gethostname() could be used "to get the Names of machines Running on a Network." I corrected you by saying that this function was only for retrieving the name of the local machine. Make sense now?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
I asked him to use WNet... Functions and populate them
I told him to pass the values to gethostbyname and change it to get the IP Address. Just check my first post to this question
Anyways its good to keep confusions away.
I will take it as a advise from you and try and make my posts more accurate
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
Ok Lets Please stop it here guys, I got the program running and its working fine.Thanks a lot to both of you.
kss
|
|
|
|
|
AnShUmAn_VCPP wrote: I told him to pass the values to gethostbyname and change it to get the IP Address. Just check my first post to this question
Perhaps you should check out that post. You suggested gethostname() , which I indicated was to get the name of the local machine only. See the difference?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
HI,
I have some value in string object like
CString str = "ABC"
I want to create an array with the name that is the value in the string object, in the current exapmle it is "ABC"
so it should be
CObArray ABC;
How can I do this? That define a name of an aray that is the value got from some where.
Thanks
Regards.
|
|
|
|
|
You can't.
The best solution would be to dynamically create the array and add it to a map using the name.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|