Click here to Skip to main content
15,913,090 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralScrollbar resets to zero Pin
Gammill20-Jul-04 15:41
Gammill20-Jul-04 15:41 
GeneralRe: Scrollbar resets to zero Pin
Johan Rosengren21-Jul-04 0:27
Johan Rosengren21-Jul-04 0:27 
Generalneed help in linking two pages Pin
Member 118298220-Jul-04 15:40
Member 118298220-Jul-04 15:40 
GeneralRe: need help in linking two pages Pin
Johan Rosengren21-Jul-04 0:40
Johan Rosengren21-Jul-04 0:40 
Generalchat window BG Pin
ANDYFA20-Jul-04 14:19
ANDYFA20-Jul-04 14:19 
GeneralRe: chat window BG Pin
Antti Keskinen20-Jul-04 23:07
Antti Keskinen20-Jul-04 23:07 
GeneralDlls, callbacks and function pointers Pin
Irenepower20-Jul-04 10:51
Irenepower20-Jul-04 10:51 
GeneralRe: Dlls, callbacks and function pointers Pin
Antti Keskinen20-Jul-04 11:43
Antti Keskinen20-Jul-04 11:43 
My first question would be, what is the error during execution ? A run-time error ? An exception ? An access violation ?

Finding out the error type is integral to determining what the cause of the error is. I believe it to be an access violation, though. As a suggestion, you should try defining the function pointer as a standard pointer-to-function type. You shouldn't encapsulate it into a struct (what is the reason behind this, by the way ?)

Another working way could be to call GetModuleHandle on the main application. This returns a handle to the executable used to start the process. In english, it is the starting address of your main application. Now, if you pass this module handle into the DLL, you can use GetProcAddress inside the DLL code to query for the address of the function in the main module. This is something of a reverse-usage of the most common case: querying for a function address inside a DLL. Instead, we query for a function address inside the main application.

The returned value can then be used to invoke the function in the main application module. Using GetProcAddress ensures that the memory location pointed to by the returned pointer is ensured to contain information of to what module's memory area it points to. This may not be the case if you just pass the pointer using address-of operator.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Dlls, callbacks and function pointers Pin
Member 124998021-Jul-04 3:37
Member 124998021-Jul-04 3:37 
GeneralRe: Dlls, callbacks and function pointers Pin
Antti Keskinen21-Jul-04 3:54
Antti Keskinen21-Jul-04 3:54 
GeneralRe: Dlls, callbacks and function pointers Pin
Member 124998021-Jul-04 4:59
Member 124998021-Jul-04 4:59 
GeneralRe: Dlls, callbacks and function pointers Pin
Antti Keskinen21-Jul-04 7:21
Antti Keskinen21-Jul-04 7:21 
GeneralRe: Dlls, callbacks and function pointers Pin
Antti Keskinen21-Jul-04 8:21
Antti Keskinen21-Jul-04 8:21 
GeneralRe: Dlls, callbacks and function pointers Pin
Member 124998021-Jul-04 10:11
Member 124998021-Jul-04 10:11 
GeneralRe: Dlls, callbacks and function pointers Pin
-Irenepower22-Jul-04 2:41
suss-Irenepower22-Jul-04 2:41 
GeneralCopyFile Error on XP Pin
Timothy Grabrian20-Jul-04 10:15
professionalTimothy Grabrian20-Jul-04 10:15 
GeneralRe: CopyFile Error on XP Pin
gamitech20-Jul-04 11:13
gamitech20-Jul-04 11:13 
GeneralRe: CopyFile Error on XP Pin
P-Rex20-Jul-04 20:15
P-Rex20-Jul-04 20:15 
GeneralRe: CopyFile Error on XP Pin
Timothy Grabrian21-Jul-04 11:15
professionalTimothy Grabrian21-Jul-04 11:15 
GeneralI need Help on Database Programming!!! Pin
Member 123981320-Jul-04 10:03
Member 123981320-Jul-04 10:03 
GeneralRe: I need Help on Database Programming!!! Pin
David Crow20-Jul-04 10:33
David Crow20-Jul-04 10:33 
GeneralCreating ActiveX control (variable types) Pin
BlackDice20-Jul-04 9:26
BlackDice20-Jul-04 9:26 
Generalwindow message Pin
Anonymous20-Jul-04 9:10
Anonymous20-Jul-04 9:10 
GeneralRe: window message Pin
Alexander Wiseman20-Jul-04 9:21
Alexander Wiseman20-Jul-04 9:21 
GeneralRe: window message Pin
Anonymous20-Jul-04 9:35
Anonymous20-Jul-04 9:35 

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.