|
Are you aware CopyTextList is called, but you supplied code for CopyTextFromList ?
Also you only need CoInitialize once. Do that in your start up routine (CWinApp::InitInstance if it's MFC)
|
|
|
|
|
It's unuseful to call CoInitialize each time you need to use some COM object; call CoInitialize only once somewhere in your startup code instead.
Be aware that each call to CoInitialize should be balanced with a call to CoUninitialize .
From the code snippet you posted, it seems that you wrote your application using MFC, then the best places where put the calls are inside CWinApp::InitInstance and CWinApp::ExitInstance .
|
|
|
|
|
Hi all.
My executable is suddenly disappearing after a number of hours running (variable). I have never seen this kind of behaviour before and I'm completely stumped.
What could cause my EXE to disappear discretely.
For info, I'm using XP 32 bit SP3. The app is a console app with a number of worker threads. There is no condition that would lead the program to exit cleanly (or at all for that matter).
Anyone seen anything similar?
Thanks.
|
|
|
|
|
one easy way to crash silently, even on a perfect system, is by creating a fatal condition that prohibits proper signaling; a recursion ending in a stack overflow would probably be one of those. I suggest you add some logging, and periodically log some major statistics such as working set, GDI object count, etc. Make sure to regularly close the log file, so it is available after the next crash!
|
|
|
|
|
Many thanks for that. It does look like a stack corruption, but I'm not sure why or how to check / fix.
I used application verifier which seems to be quite good. It told me:
"the stack was corrupted when asychronous I/O was pending"
Could this cause my silent crash?
I'll try and post the full xml log from appverifier a bit later.
|
|
|
|
|
maybe you are getting the next chunk of I/O data before you're finished dealing with the previous one, so your asynchronous handler (probably the receiver) is breaking in to itself sometimes (or even always). Check your code to see if that is possible, maybe add a nestinglevel counter, in pseudo-code:
int nestingLevel=0;
void myIOhandler(...) {
nestingLevel++;
if (nestingLevel>5) {
log("warning: myIOhandler is being reentered; nestingLevel="+nestingLevel);
}
...
nestingLevel--;
}
|
|
|
|
|
Thanks for that. I think it put me on the right track, although I was unable to check for the nesting because I didn't know where to put the increments / decrements.
I have a listening thread which listens for an RX event and reads (overlapped) the data.
Other threads can issue overlapped writes to the same port, whose access is protected with a critical section.
However, I suspect that my problem my come from the fact that I'm using the same event handle for all the instances of overlapped reads / writes.
I could be wrong about this, my understanding of overlapped I/O is limited :s
Does this make sense?
|
|
|
|
|
The problem seems to be resolved.
I am concluding that the multiple use of the same event handle in overlapped I/O caused stack corruption and the process would crash silently. A week of testing after correcting the overlapped I/O has shown that the application is now stable.
Thanks for all the help
|
|
|
|
|
i guess your threads are eating up the stack so it ends.
-> To DO: debug at most your thread terminations for leaking memory.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi All
I have download some example code from net.When i try to complie this code then i getting error this.
error PRJ0019: A tool returned an error code from "Performing Custom Build Step"
|
|
|
|
|
open up the project's properties, look at the custom build steps and see what it's trying to do.
|
|
|
|
|
There is normal setting
Performing Custom Build Step nothing special setting there.Please give me more tips.
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
I want to confine mouse movement. Let's say I want to confine mouse movement to x-direction (so only horizontal movement is possible) when pressing a certain button. This should work globally. What I mean with that is, that I want to use this in any windows program. Let's take MS Paint as an example: When my program runs and I press the certain button, the movement of the mouse should be restricted to horizontal movement. So when drawing a straight horizontal line should be the result.
My research so far led me to ClipCursor, but ClipCursor seems to only affect the mousecursor, not the raw data. So returning to the example of MS Paint the following happens:
The cursor moves on the horizontal line, but the mouse data received by paint is different: So if you move the mouse slightly in y-direction this still affects the line drawn, also the mouse cursor itself does not indicate that (stays on the straight line). So the result is not a straight line as expected.
Does anybody know how to solve that problem ? (as ClipCursor does not confine the raw data sent to an application, it seems to be the wrong routine for doing that)
Thanks in advance.
|
|
|
|
|
HHOOK WINAPI SetWindowsHookEx(
__in int idHook,
__in HOOKPROC lpfn,
__in HINSTANCE hMod,
__in DWORD dwThreadId
);
http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx[^]
and then look at: WH_MOUSE or WH_MOUSE_LL to get what you need. WH_MOUSE_LL gives a little bit more information, but may not be needed in your application.
|
|
|
|
|
Thanks for the answer. I could use one more hint. To modify the mouse data with let's say WH_MOUSE_LL I have to use my own custom CallBack function and modify the POINT pt of the MSLLHOOKSTRUCT pointed to by lParam, which has been passed to the CallBack function, right? Or did I get something wrong about how to restrict the movement correctly?
|
|
|
|
|
If i remember correctly yes that would be how you would restrict the movement.
|
|
|
|
|
Additionally to what elchupathingy said, you might also try to globally hook[^] GetCursorPos[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Selectively injecting a DLL and hooking the functions you need is IMO the better solution. More complicated than using SetWindowHookEx, but will not have the overhead and annoying problems that are associated with global hooks...IE getting the mouse stuck on your horizontal plane, which I think is not what is to happen.
|
|
|
|
|
Wouldn't he still need to use a hook to modify the mouse-input messages? I mean, the coords "encoded" in the message params probably come from somewhere else than GetCursorPos, do they not? Wouldn't btw selectively injecting the DLL instead of trying this globally with every process make it less "global"?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
He could hook the actual function it self by using a DLL, messy but could work well and to make this global you can keep an array of processes and check for new ones and inject into the new ones.
Or, looking back at what you have said another way to do it would be to use SetWindowHookEx and pass the thread ID of the process that is to be injected into. [^]
I just feel that this particular program could cause problems in other programs if it were a global hook, and that it only needs to be applied to specific processes rather than all running processes. From the example of the op with mspaint.
Also the call chain for GetCursorPos is:
GetCursorPos -> NtUserCallOneParam( DWORD dwParam, DWORD routine )
So, a hook on NtUserCallOneParam could be used to modify the mouse position that is returned.
|
|
|
|
|
Hi,
my application is a win32 appln. I have added try-catch loop. But its showing the following error.Please help me to resolve this error.
Code:
try
{
fn();
}
catch(CException exp)
{
exp->GetErrorMessage(lpszErr,sizeof(lpszErr),NULL);
wsprintf(lpszLogMsg,"%s\\%s",lpszErr,"fn");
WriteLog(0,lpszLogMsg);
return;
}
Error:
error C2061: syntax error : identifier 'CException'
error C2310: catch handlers must specify one type
error C2227: left of '->GetErrorMessage' must point to class/struct/union
error C2317: 'try' block starting on line '474' has no catch handlers
|
|
|
|
|
try
{
fn();
}
catch(Exception *exp)
{
exp->GetErrorMessage(lpszErr,sizeof(lpszErr),NULL);
wsprintf(lpszLogMsg,"%s\\%s",lpszErr,"fn");
WriteLog(0,lpszLogMsg);
return;
}
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
now the errors has gone.Can you please tell me how to get the error message.
ni CExeception we are having GetErrorMessage() fn. Similarly, what is the fn in exception class to get the error message?
|
|
|
|
|
Print this line to get the error message
exp->Message
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|