|
otrcomm wrote:
I really couldn't make it without all the folks at Code Project.
I agree: I need some help now and then myself. The world would be a worse place without the codeproject and all the good and smart people using it.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I'm writing an application that loads a DLL midway through execution (it's a wizard). When I debug my program and step through the lines of code which load the DLL, I get a null pointer back and my error handler catches it just fine. But that's not my issue--the issue is, when I run the exact SAME executable file but I don't do it in debug mode, the program experiences a runtime error, presumably from trying to get functions from an invalid HINSTANCE pointer with GetProcAddress, which I do right afterwards. How is it possible for the same code to experience different behavior? Has anyone else run into this? I also see runtime differences between the debug and release versions of my code. Any ideas?
Thanks alot,
augy
|
|
|
|
|
Microsoft would call this "behaviour by design".
The debug versions are much more error-tolerant than the release versions. The runtime error is caused by the invalid HINSTANCE variable (if LoadLibrary returns NULL). The debug version doesn't cause a runtime error, because, during the debug build phase, there is a compiler predefinition called _DEBUG. This predef causes the compiler to generate much heavier and more error-tolerant code, made especially for debug purposes. On the release versions, a _NDEBUG is specified.
The idea is that you create code, then do a debug build, then run/step through the code to see if it is working smoothly. Then you do a release build. It is supposed to work this way. Trying to alter this behaviour is the same thing as trying to reinvent the wheel.
The debug mode of Visual Studio, when ran with a debug build, is capable of cathing and handling numerous types of error that would quickly crash a release version. It is designed to help you predict errors and fix them beforehand when building your applications.
The reason why your error catcher doesn't handle "the NULL pointer" error in a release build is probably because you either have forgotten to use a try - catch block or then you are trying to check the error handler after the GetProcAddress is called. When HINSTANCE parameter is NULL, GetProcAddress will cause a runtime error. Check the HINSTANCE parameter instantly after you call LoadLibrary .
For more detailed error analysis, you should paste the library loading code here.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Interesting. I figured as much, but I didn't know that the debug version would change runtime behavior THAT much.
Anyways, I do check the HINSTANCE immediately afterwards for a NULL value, before any GetProcAddress() calls, hence my utter confoundment. After running it a few times, the problem has gone away (but without ANY change in the DLL loading code), and my simple check on the HINSTANCE ptr seems to catch it. Why or how this changed, I still haven't got a clue; I was using the debug version.
|
|
|
|
|
the_augy wrote:
How is it possible for the same code to experience different behavior? Has anyone else run into this?
All the time
I'm not sure, but I think one reason could be that a debug mode is much slower then the release.
There is however nothing you can do about it. Just try to do it in a different manner.
(PS: you can even get different errors when your breakpoint is set or not)
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I don't know the meaning of the following sentence:
the "WinMain" function is the begining of the Windows application ,it create the windows which receive the message
and enter the message circulation.
Does this function create the main window of the application?
|
|
|
|
|
WinMain() is the function that Windows calls when it starts your program. Typically, this is where you create the main window and implement a message loop so you can process messages.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
sunmozhou wrote:
the "WinMain" function is the begining of the Windows application ,it create the windows which receive the message
and enter the message circulation.
Does this function create the main window of the application?
Yeah if use CreateWindow() function to craete a window.
ShowWindow() to Make the Window Visible.
and GetMessage() and DispatchMessage() to handle messages.
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
How can I tell if a string is a file or a directory?
Can I do it without searching the string myself looking for a period?
Please no MFC!
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
One solution is GetFileAttributes().
Kuphryn
|
|
|
|
|
|
Use the CRT _stat function, see in MSDN, notice the
_stat::st_mode:
Bit mask for file-mode information. The _S_IFDIR bit is set if path specifies a directory; the _S_IFREG bit is set if path specifies an ordinary file or a device. User read/write bits are set according to the file's permission mode; user execute bits are set according to the filename extension.
|
|
|
|
|
Guys
I would really appreciate if somebody gives me any ideas for the following task:
I need to have a control on a dialog to insert text there that would be able to have an image at the beginning of every message and also would be able to associate a data with every message. Also, if a message is too long to fit the entire text within the control's borders, the text must be wrapped. I mean broken into lines.
ListBox came to my mind first. You can insert images and accociate a data with each item. But ListBox is not a multiline control. I found some projects on Codeguru and Codeproject for multiline listbox controls but they don't work as they are supposed to be.
I need an urgent advice.
Thanks a lot!
|
|
|
|
|
You could try an owner-draw list box or list view control...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I need a bidirectional map, and usign two maps seems a bit overkill.
Are there any other ways to do that? (more curious from a design point, what else could be done, but if someone knows a good refernece implementetion.. )
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
There is one in the STL section Bimap[^].
Come on Peter, I thought you would have found it yourself
If you vote me down, my score will only get lower
|
|
|
|
|
|
Why oh why does "[a-z]= " match "xy= "
(I expected it to match exactly one letter)
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
|
thanks - I'll try to read that tomorrow. It makes my head spuin reading it today (they say this is the effect of , but I seriously doubt that)
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
|
mate im with you. Bloody reg ex! Looks weird I would expect it to match "y="
I have found this book to be invaluable
Mastering Regular Expressions
By J Friedl
It explains all the minor subleties of each of the common implementations
Get the 2nd edition
|
|
|
|
|
What is the purpose of following code means why we used Select Object,pOldBitmap etc.?
bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_BOTTOM);
pOldBitmap = bitmapDC.SelectObject(&bitmap);
memDC.BitBlt(left,top,11,11,&bitmapDC,0,0,SRCCOPY);
bitmapDC.SelectObject(pOldBitmap); //line 1
bitmap.DeleteObject(); //line 2
pOldBitmap = NULL; //line 3
and wht does line1,line2,line3 (means last 3 lines)do?
|
|
|
|
|
ssingh725 wrote:
bitmapDC.SelectObject(pOldBitmap);
Maintains a valid state in the device context since the next line will free the resource handle that is currently selected into the device context
ssingh725 wrote:
bitmap.DeleteObject();
Frees the kernel resource allocated to the object
ssingh725 wrote:
pOldBitmap = NULL;
No purpose in the code that was posted. It may be relevant within the complete context of the posted code.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Please help me by telling how can i hide the tabs in a Tab controlsg?But pages should be displayed as i'm clicking on respective tabs whenever i click on a menu item or other buttons for each tab.
Kindly help me.
|
|
|
|