|
Michael Dunn wrote:
Work, yes. Stable, mostly. VC 6 crashes about once a day on my XP box at work, which is a shame because I've never had VC crash on non-XP. Thus I blame XP
Under my XP Pro, VS6 Std worked fine with SP4, and started to crash almost daily after applying SP5 to it. Either is it XP or VS, we can then blame... MS.
And also the just-in-time debugging feature fails to work when moved from 2000 to XP! If I run a program outside the debugger and it crashes, pressing Cancel doesn't get me into the code.
Merry XMas,
Bartosz Bien
|
|
|
|
|
My program used gdiplus.dll.i make another dll file name TransToGif.dll to Translate BMP to Gif which using gdiplus.dll.it run very very in my computer which install VS.net in it. and i want make it run in another computer.the computer only install Windows XP.i copyed Gdiplus.dll,TransToGif.dll into windows\system32 and windows\system and program directory. but when i run the program it told me that can't find TransToGif.dll.i kown that it acturlly can't find gdiplus.dll or the gdiplus.dll is not worked.but i don't kown how to make it work.i kown that gdiplus use COM to work.but what COM should i registe first. can anybody help me? thank you!
|
|
|
|
|
I need to load a image file from command line.And I do in this way,
<<in app="">>
cmdInfo.m_nShellCommand = CCommandLineInfo::FileOpen;
<<in doc="">>
OnFileOpen()
{
.....
}
But when this image is invalid image, I have to exit the program.In this Doc class, if I use exit(0) it will cause memroy leak.
How to avoid memory leak when I exit in this occasion?
Thx ahead.
|
|
|
|
|
Use PostQuitMessage(exit_code); .
Software Zen: delete this;
|
|
|
|
|
I have tried the PostQuitMessage() before. But it can not terminate the program immidiately from the OnFileOpen().After sending this message, it will go on to do following steps until main program deals with this message.
|
|
|
|
|
Someone asked me the other day "what if the thread dies unexpectedly?" And I don't mean exits normally but just somehow dies. Is that possible?
I can't remember ever seeing code that checked a thread for abnoral termination.
I know a thread can hang. What's the best way to detect if a thread has hung?
Todd Smith
|
|
|
|
|
I'm not an expert, but one can check the thread handle to see if the thread is valid or not.
I suppose that if correctly coded, the thread shouldn't hang but rather exit it's loop. There should be no reason that the thread would just die or hang other than a code bug. Usually the OS would not start the thread if there were not enough resources available.
The way I've kept an eye on the threads was by posting thread messages from the worker to the main thread that reflect thread status, or utilize some type of watchdog that keeps an eye on the thread. If something doesn't happen (or the thread's task isn't completed within X timeout), the watchdog kills the thread or posts a message to the main thread. I have yet to see a thread hang or die for no reason, but if it did and coding was correct, I suspect that the entire system would be hung too. Well, as was stated before, I'm not an expert.
Regards,
Paul...
|
|
|
|
|
A thread can end in three ways, a) it returns from its thread function (or main/WinMain if it's the primary thread in the process), b) it generates an unhandled exception (GPF, C++ exception), or c) some other thread kills it. b and c count as "unexpected", but the answer is "not much". Exceptions can be handled and dealt with, but there is no way to prevent some other app from calling TerminateThread() .
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
What's the typical technique of determining if a thread gets killed or hangs?
My main application launches a thread and then waits for a message to be posted from the thread. If a message never gets posted then the main application pretty much gets stuck waiting. What should my main process do to see if the thread is still alive?
Can a main process catch an exception thrown by a child thread?
Todd Smith
|
|
|
|
|
Todd Smith wrote:
What's the typical technique of determining if a thread gets killed or hangs?
DWORD dw;
dw = WaitForSingleObject ( thread_handle, 0 );
if ( WAIT_TIMEOUT == dw )
else if ( WAIT_OBJECT_0 == dw )
Can a main process catch an exception thrown by a child thread?
No, an exception can only be caught by the thread that generated it (the compiler goes up the stack looking for catch or __except handlers), so another thread can't handle it.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Actually, there is a fourth way (even that technically, from the kernels POV it might be your "c").
I don't know if it has been fixed in NT5 or NT5.1 (not using Windows anymore for real server tasks), but in NT4 it was not unheard of by us doing heavy server development that some idiot forgotten to release a resource. From what we understood (not having access to the OS src has obviously been a problem in tracking such bugs), when some handle table got full (apparently "someone" decided to put hard-coded handle-table-sizes into even NT4) the thread, and actually the whole process, just vanished from the face of the earth. No log message, no error handling code run, no nothing. It just vanished.
|
|
|
|
|
Hi,
I have two different questions:
1.) Does a message handler for ON_MESSAGE() need to be defined as afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam); or as afx_msg void OnMyMessage(WPARAM wParam, LPARAM lParam); ?
I am confused, because I (accidently) used the "void" version and never got any compiler or runtime error in the past.
2.) What is IMPLEMENT_DYNAMIC() macro used for? Well, take my appology that I don't know MFC very well and from MSDN I don't get any newbie description what is it for. For me even more intersting: when would I need to use this macro and what does it give me?
Thanks and hohoho, Moak
PS: If you wonder how both question are related... they are not. I'm currently playing with multiple inheritance and MFC. I derived a dialog from CDialog + a (non-CObject) class and got strange compiler errors.
|
|
|
|
|
1. You should definately be declaring that the function returns an LRESULT.
afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam);
You may think it's not a big deal because it never crashed, but it's not safe (or predictable) to specify the incorrect return type on the function, especially if Windows wants to use the value returned from the function to decide what to do. In the case that you specify a "void" return type, the EAX register, which holds the return value, will have undefined data in it.
2. IMPLEMENT_DYNAMIC, in conjunction with DECLARE_DYNAMIC let's you determine the type of CObject derived objects at runtime. So, you can do something like this:
class CBaseClass : public CObject
{
DECLARE_DYNAMIC(CBaseClass)
};
IMPLEMENT_DYNAMIC(CBaseClass,CObject)
class CDerivedClass : public CBaseClass
{
DECLARE_DYNAMIC(CDerivedClass)
};
IMPLEMENT_DYNAMIC(CDerivedClass,CBaseClass)
CBaseClass * pBaseClass = new CDerivedClass;
if( pBaseClass->IsKindOf( RUNTIME_CLASS( CDerivedClass ) ) )
{
CDerivedClass * pDerivedClass = static_cast<CDerivedClass*>(pBaseClass);
}
else
{
}
It's basically just a runtime time system that MFC uses, and you can use also. Beware that the IsKindOf function shouldn't be used in high performance situations, because it can be quite slow to lookup the type of the class. Also, it's only necessary to do this kind of thing in rare circumstances, or serialization.
Sorry if I haven't explained it well.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
thx Chris, it helps a lot!
I wonder why I never got any warning when using a message handler returning void . Good that it's fixed now.
|
|
|
|
|
How could i create a window without title bar that floats over parent dialog but does not take away parents focus when clicked,
ie. functions similar to floating CToolbar, but without buttons, title bar and
accepts CDialog as a parent ?
Which class can be used to achive this, CMiniDockFrameWnd ?
|
|
|
|
|
afaik toolbars are similar to modeless dialogs so u could do it that way depending on what u exactly wanted
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
No, modeless dialog can only float above parent dialog if set wndTopMost.
Modeless CDialog also takes away parents focus, CToolbar doesn't.
|
|
|
|
|
I've got two questions:
1. How do I retrieve the hard disk's serial number from w/in c++? I need to store the SN in a CString object.
2. How do I create/destroy a directory on the fly? I have a CFile object that should create a file and directory. The statement CMyFile("c:\\myfolder\\file.txt",CFile::modeWrite | CFile::modeCreate) will not work if the directory does not already exist. The same goes for CMyFile.Destroy("c:\\myfolder\\file.t").
Thank you all and have a great Xmas,
Ralf
ralf.riedel@usm.edu
|
|
|
|
|
RalfPeter wrote:
How do I retrieve the hard disk's serial number from w/in c++? I need to store the SN in a CString object.
GetVolumeInformation
RalfPeter wrote:
How do I create/destroy a directory on the fly? I have a CFile object that should create a file and directory. The statement CMyFile("c:\\myfolder\\file.txt",CFile::modeWrite | CFile::modeCreate) will not work if the directory does not already exist. The same goes for CMyFile.Destroy("c:\\myfolder\\file.t").
You cannot do that in one step. Create the directory first and then create the file
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
RalfPeter wrote:
1. How do I retrieve the hard disk's serial number from w/in c++?
Too bad, you weren't here yesterday. There was an article all about this. But I think it has been pulled.
Nish has provided you with what you are seeking, though.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|
|
RalfPeter wrote:
1. How do I retrieve the hard disk's serial number from w/in c++?
Read up on SPTI (SCSI Pass-through Interface - and don't be fooled by the SCSI part, even IDE drivers nowadays are SCSI miniport drivers) and check your vendors drive-specific documentation.
|
|
|
|
|
I want to learn codeing some device drivers.Can someone guide me to some sample code or article?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
dnload the ddk from microsoft and squizz thru the examples
then post here and im sure u will get answers to specific questions
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
Thanks luraren,Sorry ,Maybe this is dumb question,what is DDK?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
its a device driver developer kit (hmmmm should that be dddk?)
its like an sdk but for device drivers ... its a weird world in there trust me ... like nish says get a good book and look at the examples from the ddk
i dont have a link but its on ms somewhere
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|