|
Here "data[]" is an array. so "data" itself an a address.
And instead of using "&Data[3]" use "Data[3]" in "memcpy" function
That is:
short i;
memcpy(Data[3],&i,2);
|
|
|
|
|
Wrong. The first argument to memcpy() needs to be an address, of which Data[3] is not.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I believe you should use a lower-case "D" in "Data". C is a case-sensitive language.
For example, use
memcpy(&i,&data[3],2);
instead of
memcpy(&i,&Data[3],2);
As others have noted, there could be other problems because you're reading from an array of unsigned chars into a short.
-- modified at 14:06 Wednesday 20th June, 2007
|
|
|
|
|
Erik Midtskogen wrote: I believe you should use a lower-case "D" in "Data".
Umm, the compiler would have told him this (i.e., syntax error).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I was assuming that he may have been getting a compiler error and not known why. Probably we should ask him what sort compiler message or other symptom of a problem he is seeing.
|
|
|
|
|
Hi all
In servise can I create new process?
( can I use CreateProcess(.....) function? )
|
|
|
|
|
As long as you don't tell anyone I'm sure you can get away with it. I promise I don't work the Process police, honest.
Why don't you try it and let me know?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Ok.
I have console an I whont to make service, sow I copy code from console to service. I test it and ewriting work ony problenm is wen I service try to create process.
<br />
char CmdLine[512];<br />
sprintf(CmdLine,"C:\\My program\\Program.exe"); <br />
<br />
if(CreateProcessA(NULL, CmdLine, NULL, NULL, FALSE, dwCreationFlags, NULL, NULL, &si, &pi) == 0)<br />
{<br />
MyLog("ERROR CANT START PROCESS"); <br />
}<br />
|
|
|
|
|
Ok I test and my service can't create process.
If you can help me.
how to Create Process from Service?
|
|
|
|
|
Hi,
Under which user account does your Service run. Services normally run under a system account which could be conflicting with the CreateProcess function.
Try to run the Service under a user account.
Or create new UserCredentials to start the process with.
codito ergo sum
|
|
|
|
|
|
Has si been initialized (properly)?
Why are you not calling GetLastError() to find out why CreateProcessA() failed?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Why are you not calling GetLastError() to find out why CreateProcessA() failed?
He's busy eating his Fish Filet
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Which is exactly what I had for lunch today. I don't get the joke, however.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: I don't get the joke, however.
Still?[^]
|
|
|
|
|
It's clear now. Thanks.
Reminds me of this joke:
A man boarded a bus and saw the back bench seat occupied by a group of schoolboys. He made his way to the back and heard one of the boys yell out "5" and the whole group laughed loudly. Another boy yelled out "23" and louder laughter ensued. This went on for sometime and the man out of curiosity asked one of the boys what was up. He said that they had numbered the jokes they knew and just called out the joke number instead of telling the whole joke.
The man thought he would give it a try and yelled "3" - no one laughed. He tried again "7" - silence. "Whats wrong?" he asked.
"C'mon man - that's no way to tell a joke." the boy replied.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
After the amusement, it always just makes me hungry!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I've got Cornish Mackerel on for tea if you're in the area
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
That sounds VERY tasty!
Sadly, I am NOT in the area
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi
I have a worker thread in my project and this thread is waiting the data which is coming from serial port.I want that when a certain data comes from the serial port I will change the keyboard focus from one edit box to another.This data which is coming from serial port will work like TAB button in our keyboards.I know that SetFocus() method is doing that job however when I want to do this in worker thread it is not working.Although I can do many things in worker threads like writing tha data to edit boxes,I can not change visually the keyboard focus from one edit box to another.Is there any body who have an idea about that problem?
Thanks all
|
|
|
|
|
If you're working in MFC then there is a simple rule.
Never do anything in a worker thread that touches the user interface directly in any way. Not even a message box. (Even if it seems to work most of the time)
If you want to change the UI from a worker thread then use PostMessage to tell your main thread to do it and then get the main thread to change the UI in the message handler. You can define your own mesages in the WM_USER + n range for these sort of things and add ON_MESSAGE entries to your message maps to route to your handler.
The reason for this overly strict sounding rule is that MFC blocks the main thread anyway when it does anything UI related even if you call the MFC functions from your worker thread. If the main thread is waiting for the worker to complete but the worker is waiting for MFC to grab the main thread to change the UI nothing will ever happen. This receipe for deadlocks should be avoided by all non masochists
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks for your help.
This solved the problem.
|
|
|
|
|
Matthew Faithfull wrote: You can define your own mesages in the WM_USER + n range for these sort of things
It's better to use WM_APP instead of WM_USER because some of the control classes use WM_USER to define their internal messages (like the TB_* messages). This isn't usually a problem since those messages tend to not be sent to "main window" message queues but it does happen. I speak from experience . Good practice is to use WM_APP instead and avoid the problem.
Judy
|
|
|
|
|
You ought to read this[^] in addition to what Matthew already stated.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|