|
ptr_Electron wrote: WaitForSingleObject doesn't work for waiting till the completion of the Thread
Yes, it does.
If you get stuck inside the call to ::WaitForSingleObject() it is due to the fact that the thread you're waiting for has not finished yet.
The presence of a call to AfxGetApp() , even though it's currently out-commented, suggests that you're using the MFC framework. If you're creating a thread that is supposed to work with the MFC framework you have to use AfxBeginThread() . The fact that you're not using AfxBeginThread() to start your thread could be what's causing the thread to not finish.
I strongly advise you to read this excellent article[^] before you continue.
Run your app in debug mode and put a breakpoint inside the thread controlling function to see what prevents it from finishing.
Also get rid of this polling technique (DoEvents), it doesn't belong in an event driving OS environment like windows. You should stick to the ::WaitForSingleObject() concept.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I would like to know if it's possible in any way to hide a program exe from the process list....PLZ hele me
|
|
|
|
|
Why did you repost your question ? This is a forum, not a chat.
|
|
|
|
|
If you ask this question now and again your answer is same. 
|
|
|
|
|
writing virus !!1 hummmmm
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
Hi,
I have created a dll which exports a factory function that returns an object
of the type of the dll class:
class CMyDll
{
Z();
X();
Y();
}
extern "c"
{
__declspec(dllexport) CMyDll* Factory();
}
The program that utilize the dll loads the dll calls the factory function and get the dll object. from that object i call the dll functions.
MyApp()
{
hmodule = AfxLoadLibrary(MyDll.dll);
typedef CMyDll* (*FACTORY )(void);
FACTORY pFunc;
pFunc = (FACTORY)GetProcAddress(hmodule,"Factory");
CMyDll *dllObj = pFunc();
dllObj->X();
dllObj->Y();
dllObj->Z();
}
But there is a problem , the functions are not called right, if i call
functions X,Y and Z, it calls functions Z,Y and X in a certain order which i
couldn't specify.
If someone spotted the source of the error please let me know
Thanks
Simon
|
|
|
|
|
what about this :
pFunc = (FACTORY)GetProcAddress(hmodule,"<code>_Factory</code>");
BTW, your code is not very secure, as you don't test hmodule before using it...
|
|
|
|
|
Where is the rest of the Factory() function, could be an allocation error.
|
|
|
|
|
Hi all, thanks for your answers.
The problem was that i declared a function in the interface as an int, but the implementing class declared the same function with an enum.
So when calling the function from the dll (which was the implementing class) the function was not found and another function was called.
______________
|Interface |
|-x(int var);|
--------------
|
\/
______________
|dll class |
|-x(enum var)|
--------------

|
|
|
|
|
Hi...Iam running MFC application .it is possible .exe file cannot shown in process manager....plz help...
|
|
|
|
|
I am not sure anyone here or anywhere else will help you. Can you give a good reason to want to do this? The implications of such a request is for nefarious purposes only. Unless you have a really good reason to want to do this, please post it, and then you might get help.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
hi..because iam running NT service..For running NT service i called for this exe path..after that creating the service..after started the service.. when i started the service at that time one more exe is running in process manager...but i need only one ..
|
|
|
|
|
tns_ranjith wrote: but i need only one ..
Well, that has nothing to do with hiding it from the task manager. Take a look at this article[^] for instance.
Ans please, make an effort when you write because the only thing I understood from your post was that you want only one instance of your app, the rest was completely obscure to me.
|
|
|
|
|
IF you want tto hide your process of TaskManager or other programs my experience is no,you cant.
|
|
|
|
|
First, you cannot do something like that. Second, we do not support people to build applications of that kind.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Hi all,
I have this snippet:
TCHAR buff[1024] = {_T('\0')};
_tcscat(buff, _T("This is a test"));
UINT ii = 0;
ii = strlen(buff);
I get the error :
error C2664: 'strlen' : cannot convert parameter 1 from 'TCHAR [1024]' to 'const char *'
Now I am wondering why this compiles fine with the project i copied this snippet from.
If i use reinterpret cast the strlen only returns 1
Please advise
Thanks,
Jayjay
|
|
|
|
|
monsieur_jj wrote: ii = strlen(buff);
I guess in your project, UNICODE is defined and strlen() is not unicode compatible. Since your string is TCHAR array, you should use _tcslen() .
monsieur_jj wrote: Now I am wondering why this compiles fine with the project i copied this snippet from.
In that project UNICODE might not be defined.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
You have to use the unicode routine instead: _tcslen. I suggest this excelent article[^] if you want to understand things properly. It is a must read for each C++ developper.
|
|
|
|
|
How is it that you knew TCHAR required _T() and _tcscat() , but still tried to use strlen() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
For this, I had to click on the link "Good Question" !!! lol
|
|
|
|
|
I have a ListCtrl to display thumbnail image list, I want to change color of the border of selected item in this ListCtrl but I don't (with SetOutlineColor). Please help me
|
|
|
|
|
Did you try with NM_CUSTOMDRAW?
|
|
|
|
|
Hi all,
If the .chm file is open and appilaction is terminated than the .chm is not close.
Please anyone can tell me how can i close the .chm file when application is terminated.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Use the HtmlHelp function instead of ShellExecute, it takes care of that.
Really, I just checked in one of my apps that uses HtmlHelp function, and the help does in fact close when the app is terminated. I assume that you're using the code I posted?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Thanks.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|