Click here to Skip to main content
15,896,269 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Displaying Symbol issue......... Pin
toxcct26-Jan-09 4:20
toxcct26-Jan-09 4:20 
JokeRe: Displaying Symbol issue......... Pin
CPallini26-Jan-09 6:48
mveCPallini26-Jan-09 6:48 
QuestionWorking with DB Pin
CodingLover25-Jan-09 18:33
CodingLover25-Jan-09 18:33 
QuestionRe: Working with DB Pin
David Crow26-Jan-09 2:56
David Crow26-Jan-09 2:56 
AnswerRe: Working with DB Pin
Jose David Pujo26-Jan-09 4:38
Jose David Pujo26-Jan-09 4:38 
QuestionAfxGetInstanceHandle Crash in MFC Extension dlls Pin
Neptunex25-Jan-09 17:55
Neptunex25-Jan-09 17:55 
AnswerRe: AfxGetInstanceHandle Crash in MFC Extension dlls Pin
Randor 25-Jan-09 18:23
professional Randor 25-Jan-09 18:23 
AnswerRe: AfxGetInstanceHandle Crash in MFC Extension dlls Pin
Neptunex26-Jan-09 0:53
Neptunex26-Jan-09 0:53 
First of all answers to above questions:

1) Refering to Memory Management section of Extension DLLs in MSDN:

MFCx0.dll and all extension DLLs loaded into a client application's address space use the same memory allocator, resource loading, and other MFC global states as if they were in the same application. This is significant because the non-MFC DLL libraries and the regular DLLs do the exact opposite and have each DLL allocating out of its own memory pool.

If an extension DLL allocates memory, that memory can freely intermix with any other application-allocated object. Also, if an application that dynamically links to MFC fails, the protection of the operating system maintains the integrity of any other MFC application sharing the DLL.

Similarly other global MFC states, like the current executable file to load resources from, are also shared between the client application and all MFC extension DLLs as well as MFCx0.dll itself.


So I expect to receive the address space of process executable.

I checked hInstance value in DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved), it was 0x10000000 but it was not equal to the value returned by AfxGetInstanceHandle in process executable which was 0x00400000, despite the fact that they should have been the same!

2) Yes it's been properly initialized using AfxInitExtensionModule in its DllMain

3) AfxGetInstanceHandle asserts in its ASSERT(afxCurrentInstanceHandle != NULL); line

And I cannot use the code that you've mentioned because AfxGetInstanceHandle is also called from functions within MFC that I have no control on such as CWnd::CreateEx that cause the assertion again.

I really have no idea why MFC might have not been properly initialized! Frown | :(

Thank you for your feedback Smile | :)
GeneralRe: AfxGetInstanceHandle Crash in MFC Extension dlls Pin
Randor 26-Jan-09 9:21
professional Randor 26-Jan-09 9:21 
GeneralRe: AfxGetInstanceHandle Crash in MFC Extension dlls Pin
Neptunex3-Mar-09 20:27
Neptunex3-Mar-09 20:27 
QuestionCommunication app. using dial-up modem times out Pin
Member 171596825-Jan-09 17:51
Member 171596825-Jan-09 17:51 
AnswerRe: Communication app. using dial-up modem times out Pin
Jonathan Davies25-Jan-09 23:51
Jonathan Davies25-Jan-09 23:51 
GeneralRe: Communication app. using dial-up modem times out Pin
Member 171596827-Jan-09 20:00
Member 171596827-Jan-09 20:00 
GeneralRe: Communication app. using dial-up modem times out Pin
Jonathan Davies27-Jan-09 21:27
Jonathan Davies27-Jan-09 21:27 
QuestionIs "Create window in Work thread" a bad design? Pin
fitatc25-Jan-09 15:16
fitatc25-Jan-09 15:16 
AnswerRe: Is "Create window in Work thread" a bad design? Pin
«_Superman_»25-Jan-09 16:20
professional«_Superman_»25-Jan-09 16:20 
AnswerRe: Is "Create window in Work thread" a bad design? Pin
Joshua Tully25-Jan-09 16:31
Joshua Tully25-Jan-09 16:31 
GeneralRe: Is "Create window in Work thread" a bad design? Pin
fitatc25-Jan-09 21:17
fitatc25-Jan-09 21:17 
QuestionNeed help to create GUI application form in C++ and create instalation program for it. Pin
hdavari25-Jan-09 3:11
hdavari25-Jan-09 3:11 
AnswerRe: Need help to create GUI application form in C++ and create instalation program for it. Pin
Maximilien25-Jan-09 4:01
Maximilien25-Jan-09 4:01 
QuestionRe: Need help to create GUI application form in C++ and create instalation program for it. Pin
David Crow26-Jan-09 3:00
David Crow26-Jan-09 3:00 
QuestionItems are not visible in a ListBox [modified] Pin
Elsie25-Jan-09 1:45
Elsie25-Jan-09 1:45 
AnswerRe: Items are not visible in a ListBox Pin
Hans Dietrich25-Jan-09 6:25
mentorHans Dietrich25-Jan-09 6:25 
GeneralRe: Items are not visible in a ListBox Pin
Elsie25-Jan-09 17:40
Elsie25-Jan-09 17:40 
QuestionHow to get message when tab is changed in one MDI multiple tab application Pin
fujoey24-Jan-09 22:52
fujoey24-Jan-09 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.