|
I am creating a SDI application using app-wizard with VS 2008. My problem is this application crashes in InitInstance() at ProcessShellCommand(). I must mention that I have added no code so far, so there can be no error from my part. I am guessing some configuration problem with my system.
Has anyone seen this behaviour?
Saurabh
|
|
|
|
|
yeah and the culprit was AfxOleInit(). It was a random problem and I was not able to reproduce it. May be two calls to initializing OLE libraries caused the problem. Call AfxOleInit/InitializeOle only once in your code.
the fruits of your success will be in direct ratio to the honesty and sincerity of your own efforts in keeping your own records, doing your own thinking and, reaching your own conclusions.
..surviving in autumn..in love with spring..
|
|
|
|
|
I am not initializing OLE as the code I am testing is generated by AppWizard and I haven't added anything yet. I did have one AfxOleInit in InitInstance and uncommenting it doesn't help.
Interesting thing is if I take the code to another machine, after building if works fine. So I am pretty sure that it a comfiguration problem rather than a coding bug. I would reinstall VS but I dont have time right now.
Saurabh
|
|
|
|
|
Hello everyone,
Suppose there are a couple of threads in an MTA, since a process could have only one MTA, I think,
1. Even if each threads calls CoInitializeEx or CoInitialize, only the first call allocates COM related resources, all subsequent calls does not allocate any resources?
2. Only the last call to CoUninitialize frees the COM resources in the MTA, and at that time, the MTA terminates?
Both are correct?
thanks in advance,
George
|
|
|
|
|
From the MSDN:
"Typically, the COM library is initialized on a thread only once. Subsequent calls to CoInitialize or CoInitializeEx on the same thread will succeed, as long as they do not attempt to change the concurrency model, but will return S_FALSE. To close the COM library gracefully, each successful call to CoInitialize or CoInitializeEx, including those that return S_FALSE, must be balanced by a corresponding call to CoUninitialize. However, the first thread in the application that calls CoInitialize(0) or CoInitializeEx(COINIT_APARTMENTTHREADED) must be the last thread to call CoUninitialize(). If the call sequence is not in this order, then subsequent calls to CoInitialize on the STA will fail and the application will not work."
|
|
|
|
|
Thanks Hamid,
I am thinking about there are two levels of COM related resources? Or just MTA level COM related resources?
1. MTA level (apartment level resource), allocated by the 1st thread of the
MTA which calls CoInitialize[Ex], freed by the last thread which calls
CoUninitialize of the MTA;
2. Thread level resource, allocated and freed each time a thread in the MTA
calls CoInitialize[Ex]/CoUninitialize.
regards,
George
|
|
|
|
|
Hello everyone,
Any tools I could use to monitor (x64 platform) the status of all threads inside a specific process?
For example, wait for a handle (convenient to analyze deadlock), sleep, running? Since my application deals with I/O heavily, it is good if the tool could monitor I/O thread's status -- e.g. sent request, waiting response or something?
thanks in advance,
George
|
|
|
|
|
if you really want to retrieve so much details about a process, i think there would be much more work you have to deal with. I know there are many ring0 level functions related to it, such as ZwQueryInformationProcess. You should master some tricks to use these functions. This function will be a clue to find other functions to cooperate with.
good luck
|
|
|
|
|
Thanks kcynic!
1.
"ring0 level" means?
2.
Are there any tools without writing buggy code from scratch?
I think my requirement is common and there should be some tools?
regards,
George
|
|
|
|
|
1. 'ring0 level' is kernel mode. Most of our program runs in user mode(ring3 level), and few codes run in kernel mode(ring0 level,such as driver). To know more details about them, u can google it.
2. I don't know if there is a tool what you refer to exsit or not.
I suggest you describe more details about your question and why you want to do, so that any others can help you.
|
|
|
|
|
Thanks kcynic,
You mean I need to hook into kernel in order to call ZwQueryInformationProcess?
regards,
George
|
|
|
|
|
yes, just one method.
I don't know if there is a easyier way to deal it.
|
|
|
|
|
Thanks kcynic,
I am using ProcessExplorer to see whether it could dig threads' information of a specific process.
regards,
George
|
|
|
|
|
If you want to best tools you must be write it and c++ has good functions for processes and threads for example QueryProcessCycleTime or GetThread*.
|
|
|
|
|
Thanks Hamid,
I think my requirement is common and I am quite surprised to see there is no such existing tools.
regards,
George
|
|
|
|
|
|
Thanks toxcct,
1.
I have tried and it looks good. I right client the running application, then select properties, then go to Threads Tab. Do you mean this solution?
2.
If yes, how to monitor the status of threads I mentioned from Threads Tab? I only a value called CSwitch Data changes and I can see thread ID/call stack.
regards,
George
|
|
|
|
|
No you can find tools for monitor processes and threads for example you can use of Perfomance on the windows and also you can see source code of it on the MSDN (I personaly use of my tool because I am assured to it however its not complete but I use of it for processes and handles of programs ).
|
|
|
|
|
Thanks Hamid,
I do not think it could monitor the status of threads. If I am wrong, please feel free to correct me and show me what are your steps to use Perfmon to monitor thread status?
regards,
George
|
|
|
|
|
No Performance was for example.
|
|
|
|
|
What is the name of the tool you are using, Hamid?
regards,
George
|
|
|
|
|
|
Cool, Hamid!
Could you share your tool here please? And write a tutorial?
I think it will attract interests from many people.
regards,
George
|
|
|
|
|
I said its not complete and also I used of some functions that are not be safe like wsprintf and other problem is that my english is not good so I dont think my article will be good.
|
|
|
|
|
Hi Hamid,
No one will be very critical here. Code is better than English for us.
BTW: why wsprintf is not safe?
regards,
George
|
|
|
|