Click here to Skip to main content
15,902,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSHBrowseForFolder Pin
Rage13-Nov-05 23:37
professionalRage13-Nov-05 23:37 
AnswerRe: SHBrowseForFolder Pin
*Dreamz14-Nov-05 0:08
*Dreamz14-Nov-05 0:08 
AnswerRe: SHBrowseForFolder Pin
David Crow14-Nov-05 2:40
David Crow14-Nov-05 2:40 
AnswerA long standing favorite... Pin
jhwurmbach14-Nov-05 3:06
jhwurmbach14-Nov-05 3:06 
QuestionDraw arc algorithm Pin
gandalf198313-Nov-05 23:21
gandalf198313-Nov-05 23:21 
AnswerRe: Draw arc algorithm Pin
Rajesh R Subramanian13-Nov-05 23:30
professionalRajesh R Subramanian13-Nov-05 23:30 
Questioncaveats when exporting classes from a dll? Pin
WernerP13-Nov-05 22:48
WernerP13-Nov-05 22:48 
AnswerRe: caveats when exporting classes from a dll? Pin
Steen Krogsgaard14-Nov-05 2:24
Steen Krogsgaard14-Nov-05 2:24 
First, I'm no expert on this, so I may be wrong.

As I understand it you have three questions:
1: Why does your vtable still works although the functions in the dll have changed base adresses?
2: When are vtables generated?
3: How are dlls linked to the main app?

1: (actually ties in with two and three, but here goes) The vtable is populated at compile time. The main app calls the virtual function through the vtable, but reads the vtabel at runtime, not compile time. That's why it will work as long as the entries in the vtable doesn't change position. For instance, it's important that the adress of CYourClass::Foo is always the second entry in the vtable, but it's not important (at compile time) what the actual value of the second entry is.

2: at compile time.

3: When the app is started the dlls that it depends on are loaded (in theory, at least), and the entries into the dll are read from the export table. This is dynamic linking, where the function calls are resolved at runtime. Even though your statically link to your dll Windows will still dynamically link the dll - all the LoadLibrary and GetProcAddress calls are just done behind the scenes. So, as long as the app can find the right entries in the table the dll will work.

Why it doesn't work with function pointers is a little more unclear to me, but that will of course depend on how you construct and use the pointers.




Cheers
Steen.

"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
GeneralRe: caveats when exporting classes from a dll? Pin
WernerP14-Nov-05 5:59
WernerP14-Nov-05 5:59 
GeneralRe: caveats when exporting classes from a dll? Pin
Steen Krogsgaard14-Nov-05 23:23
Steen Krogsgaard14-Nov-05 23:23 
AnswerRe: caveats when exporting classes from a dll? Pin
cmk14-Nov-05 12:56
cmk14-Nov-05 12:56 
GeneralRe: caveats when exporting classes from a dll? Pin
WernerP15-Nov-05 0:18
WernerP15-Nov-05 0:18 
GeneralRe: caveats when exporting classes from a dll? Pin
cmk15-Nov-05 0:47
cmk15-Nov-05 0:47 
QuestionWindow caption at center Pin
pc_dev13-Nov-05 22:44
pc_dev13-Nov-05 22:44 
AnswerRe: Window caption at center Pin
Roger Allen14-Nov-05 0:43
Roger Allen14-Nov-05 0:43 
GeneralRe: Window caption at center Pin
vikas amin14-Nov-05 1:28
vikas amin14-Nov-05 1:28 
AnswerRe: Window caption at center Pin
ThatsAlok14-Nov-05 1:12
ThatsAlok14-Nov-05 1:12 
AnswerRe: Window caption at center Pin
Arman S.14-Nov-05 1:12
Arman S.14-Nov-05 1:12 
QuestionDestination path ICopyHook Pin
ragavan13-Nov-05 22:17
ragavan13-Nov-05 22:17 
QuestionCButton SetFocus Pin
AORD13-Nov-05 21:00
AORD13-Nov-05 21:00 
AnswerRe: CButton SetFocus Pin
toxcct13-Nov-05 21:38
toxcct13-Nov-05 21:38 
GeneralRe: CButton SetFocus Pin
AORD14-Nov-05 18:23
AORD14-Nov-05 18:23 
GeneralRe: CButton SetFocus Pin
toxcct14-Nov-05 21:19
toxcct14-Nov-05 21:19 
AnswerRe: CButton SetFocus Pin
Rajesh R Subramanian13-Nov-05 23:20
professionalRajesh R Subramanian13-Nov-05 23:20 
GeneralRe: CButton SetFocus Pin
Mircea Puiu14-Nov-05 5:45
Mircea Puiu14-Nov-05 5:45 

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.