Click here to Skip to main content
15,886,802 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Custom C++ Runtime Pin
Hamid_RT7-Apr-08 2:30
Hamid_RT7-Apr-08 2:30 
GeneralRegisterWindowClass and resources from a DLL Pin
Moak29-Mar-08 13:19
Moak29-Mar-08 13:19 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Mark Salsbery29-Mar-08 14:57
Mark Salsbery29-Mar-08 14:57 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Moak29-Mar-08 15:20
Moak29-Mar-08 15:20 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Mark Salsbery29-Mar-08 16:01
Mark Salsbery29-Mar-08 16:01 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Moak30-Mar-08 0:02
Moak30-Mar-08 0:02 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Moak29-Mar-08 15:47
Moak29-Mar-08 15:47 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Randor 29-Mar-08 19:21
professional Randor 29-Mar-08 19:21 
Hei Moak,

Yes, you have made the correct fix. Now let me explain why. I will try to be very detailed so forgive me if I walk at too low of a level.

You see... at the very root it all has to do with Protected Mode[^] and how the operating system handles virtual addresses. When you load a resource, naturally the operating system needs to know where this resource is located in memory before you can use it. Normally if the resource is located in the executable you can simply pass AfxGetInstanceHandle() and at the lower levels the translation lookaside buffer[^] looks for the location for your processes virtual address. If there is a TLB-miss then it would have to access the page table to find this physical memory offset.

Essentially what I am saying is that AfxGetInstanceHandle() is nothing more than the module base address. These addresses are used for finding the resource.

You can see this by doing the following experiment:

#define MyGetInstanceHandle((HINSTANCE)&__ImageBase)


You can do something similar inside the DLL to see that all your actually passing is the module base address:

__inline HINSTANCE MyGetResourceHandle(LPCTSTR lpModuleName)
{
	HINSTANCE h;
	GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, lpModuleName, &h);
	return h;
}


Best Wishes,
-David Delaune
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Moak30-Mar-08 0:07
Moak30-Mar-08 0:07 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Mark Salsbery30-Mar-08 6:51
Mark Salsbery30-Mar-08 6:51 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Randor 30-Mar-08 11:09
professional Randor 30-Mar-08 11:09 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Mark Salsbery30-Mar-08 11:23
Mark Salsbery30-Mar-08 11:23 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Randor 30-Mar-08 11:47
professional Randor 30-Mar-08 11:47 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Mark Salsbery30-Mar-08 11:56
Mark Salsbery30-Mar-08 11:56 
Questionprint .BMP file to printer ... how ? Pin
Member 435006729-Mar-08 11:38
Member 435006729-Mar-08 11:38 
AnswerRe: print .BMP file to printer ... how ? Pin
Member 435006729-Mar-08 14:02
Member 435006729-Mar-08 14:02 
GeneralRe: print .BMP file to printer ... how ? Pin
Mark Salsbery29-Mar-08 14:24
Mark Salsbery29-Mar-08 14:24 
AnswerRe: print .BMP file to printer ... how ? Pin
Hamid_RT7-Apr-08 2:29
Hamid_RT7-Apr-08 2:29 
QuestionUsing winsock, how can I tell if a system is listening for a connection on a port before I call connect? Pin
TragicComic29-Mar-08 10:39
TragicComic29-Mar-08 10:39 
AnswerRe: Using winsock, how can I tell if a system is listening for a connection on a port before I call connect? Pin
Moak29-Mar-08 13:29
Moak29-Mar-08 13:29 
GeneralReuse projects created in Visual Studio 6 in Visual C++ 2008 Express Edition issue Pin
gedinfo29-Mar-08 8:47
gedinfo29-Mar-08 8:47 
GeneralRe: Reuse projects created in Visual Studio 6 in Visual C++ 2008 Express Edition issue Pin
Randor 29-Mar-08 10:07
professional Randor 29-Mar-08 10:07 
Generalprecompiled header file Pin
George_George29-Mar-08 4:55
George_George29-Mar-08 4:55 
GeneralRe: precompiled header file Pin
Mark Salsbery29-Mar-08 7:24
Mark Salsbery29-Mar-08 7:24 
GeneralRe: precompiled header file Pin
George_George29-Mar-08 22:47
George_George29-Mar-08 22:47 

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.