Originally posted by Josh Kasten
I made a program that uses a mouse hook and Mailslot to put the clicks in it but i don't think its reading the mailslot right. It looks as if it just goes in a loop. How to i get it to just stay at the begining of the mailslot and read and wright there? I add the source code so you can take a look at it and see whats wrong
Dont think of a mailslot as a file.....you dont need any form of file pointer...
From my code...
Code:
GetMailslotInfo(hMailslot,&dwMaxsize,&dwSize,
&dwCount,&dwTimeout);//See what is in the mailslot
if(dwSize==MAILSLOT_NO_MESSAGE){
Sleep(500);
continue;//If nothing, wait half second & retry
}
ReadFile(hMailslot,szReadBuff,dwSize,//read info
&dwRead,NULL);
szReadBuff[dwRead] = NULL;
You just call the GetMailSlotInfo() api, and if there is no message, you issue a continue statement to jump to the top of the loop....If there is a message, you call ReadFile().......this then takes the message and there's no need to mess with a pointer....
BTW..I used the Sleep() because I was in a seperate thread to do this, and the loop it existed in had no other purpose....you may wish to ommit this as you are in the message loop as it will not be good for the timeing of your prog