|
Does GenerateConsoleCtrlEvent() help?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
UNfortunately no, because it (according to the docs) only allows 2 types of events to be sent, CTRL_C_EVENT, or CTRL_BREAK_EVENT.
|
|
|
|
|
According to MSDN (the august 2006 dvd-version, not the online msdn, as that only shows the 2 you mentioned), CTRL_SHUTDOWN_EVENT can also be sent.
So you could just try GenerateConsoleCtrlEvent with the other events too (defined in wincon.h):
#define CTRL_C_EVENT 0
#define CTRL_BREAK_EVENT 1
#define CTRL_CLOSE_EVENT 2
// 3 is reserved!
// 4 is reserved!
#define CTRL_LOGOFF_EVENT 5
#define CTRL_SHUTDOWN_EVENT 6
-- modified at 3:37 Thursday 22nd February, 2007
|
|
|
|
|
Jim Crafton wrote: ...it (according to the docs) only allows 2 types of events to be sent, CTRL_C_EVENT, or CTRL_BREAK_EVENT.
Why won't that work for you? If this console window is one you are creating via CreateProcess() , you could simply send it "exit\r\n" via its stdin handle.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The process is started (and controlled) by a service, so I don't think I can (or want to) create a console window can I?
|
|
|
|
|
Jim Crafton wrote: ...I don't think I can (or want to) create a console window can I?
Sorry, I read your "command line process" comment to mean a window was present.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am curious about a situation I have run into. I am hacking a program that was originally meant to read/write serially (serial port) into using UDP. I'm trying to preserve as much of the original code as possible for reasons that I won't bother you with here.
The situation is that a ReadCom() function is called with a specific number of bytes that the calling function wants. For example, when the buffer to be read from has 22 bytes in it, the ReadCom() may be called asking for only 16 bytes. Another ReadCom() will be called later asking for the remainder.
When I replace the serial port reads with a recvfrom(), it looks like the entire UDP message is gone after the first read even though I only asked for a partial number of bytes.
I have two people here telling me different things. One says this should not happen - it is a FIFO, another saying that any time a recvfrom call is made, the entire UDP packet is cleared.
Which is it? The behaviour seems to match with it being cleared but I would like to know what you think.
BTW - I have tried using the ioctl with FNIOREAD to see how many bytes are available and it does say that 0 are available on the second read.
|
|
|
|
|
The second person is right on - when dealing with UDP you will get the data you ask for and any remaining data in the datagram/message/packet is lost. That is the way things work with a "unreliable protocol" like UDP.
I would suggest using a larger buffer, copying all available data to that buffer, and you can then look at that buffer for additional data if required.
Note that if the data is serial, you likely want to get it in order. If you send multiple UDP packets, they may arrive out-of-order, or some may not arrive at all. You will want to use TCP sockets if that is going to be a problem.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thank you very much. I'm working on keeping my own copy of the data now.
I appreciate the help.
|
|
|
|
|
To add to James' excellent reply....this is from the docs:
"If the datagram or message is larger than the buffer specified, the buffer is filled with the
first part of the datagram, and recv generates the error WSAEMSGSIZE. For unreliable protocols
(for example, UDP) the excess data is lost;"
Better to recv the exact datagram size or more to make sure you get the etire datagram
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Mark Salsbery wrote: To add to James' excellent reply
'Danka!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: 'Danka!
de nada
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
hOw can i cOde this Output in C using fOr lOops..
ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
|
|
|
|
|
dO yOu have any trOuble with yOur 'O' key ???
for your problem, first give us what you already tried, and ask a specific question then about why you're stuck. we here do not do homework
|
|
|
|
|
He has got tic, if he wants to write the letter 'o' his left or right hand always "runs" to press the shift button. It's unstopable :]
|
|
|
|
|
nO its just ma style Ov typing...:p
|
|
|
|
|
bushxee wrote: nO its just ma style Ov typing...:p
but you're not alone, and this is is far from being a "H4x0r" site. so please comply, speak english, and type well (and no need to ask to explain your problem correctly and fully...)
|
|
|
|
|
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int a,b=72,in,out,d=71;
for(a=9;a>=1;a--)
{
for(int j=65;j<=b;j++)
{
printf("%c",j);
}
b--;
for(int i=d;i>=65;i--)
{
printf("%c",i);
}
printf(" ");
d--;
printf("\n");
}
getch();
}
dis iz ma code...
|
|
|
|
|
1) read the Posting guidelines[^]
2) do no type in SMS but in plain english
3) tell what's wrong then...
|
|
|
|
|
toxcct wrote: do no type in SMS but in plain english
i need the guide to SMS english
"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: i need the guide to SMS english
please noooo (or ask the mobile development forum )
|
|
|
|
|
I think it doesnt have error it needs to your work;) and when you want to show a code use of pre
|
|
|
|
|
bushxee wrote: dis iz ma code...
what do you want to do?
"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
|
|
|
|
|
bushxee wrote: printf("%c",j);
And yet another new developer starts learning bad habits... In this case, using a heavyweight solution (printf(...) ) when a lighter, faster one is available (putchar(...) ).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
bushxee wrote: dis iz ma code...
diz iz ma soltn: uz da debugga
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|