Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

regular mfc dll calling back to win32 console app

52 views
Skip to first unread message

sb

unread,
May 14, 2009, 5:40:49 PM5/14/09
to
i'm trying to devise a way to call a method of a class that was
instantiated from a console app from inside a regular mfc dll (using a
shared library).

with a non-mfc dll i can pass the 'this' pointer to the dll and then
call a "callback" method for the object from the dll. i would like
understand why this doesn't seem to work with a mfc dll? also, could
someone please suggest some alternative ways to accomplish calling
back into my console app from my mfc dll?

thank you

Doug Harrison [MVP]

unread,
May 14, 2009, 6:00:20 PM5/14/09
to

First, a DLL lives in the address space of the process that loads it, and
thus code in the DLL vs. the EXE is indistinguishable WRT accessing the
process's resources. The only thing somewhat special about an MFC "regular
DLL" is the need to use the AFX_MANAGE_STATE macro, but I don't know if
that applies in your case. If you can't figure it out, reply with more
details.

--
Doug Harrison
Visual C++ MVP

Scot T Brennecke

unread,
May 15, 2009, 4:27:56 AM5/15/09
to
Some important details to include in order for us to understand the problem you face:
* What does "doesn't seem to work" look like?
* Is your MFC DLL an "Extension DLL" or a "Regular DLL"?
* You don't pass things to and from DLLs; you pass them to and from functions that are exported from
DLLs. What have you specifically tried that isn't working?

"sb" <shaw...@gmail.com> wrote in message
news:2cf6b71b-584a-4b17...@s28g2000vbp.googlegroups.com...

SB

unread,
May 15, 2009, 9:57:12 AM5/15/09
to
On May 15, 4:27 am, "Scot T Brennecke" <Sc...@MVPs.spamhater.org>
wrote:

> Some important details to include in order for us to understand the problem you face:
> * What does "doesn't seem to work" look like?

yes, i should have mentioned that i was getting a linker error.

> * Is your MFC DLL an "Extension DLL" or a "Regular DLL"?

"regular mfc dll (using a shared library)"

> * You don't pass things to and from DLLs; you pass them to and from functions that are exported from DLLs.  

i'm passing the this pointer via an exported function in the mfc dll.

anyway, i figured out what the problem was...somehow when i created
the new mfc dll project i did not add the .cpp file with source code
for implementation of the object that i wanted to call methods on from
the mfc dll.

thanks for the help

Scot T Brennecke

unread,
May 16, 2009, 12:04:44 AM5/16/09
to
Oh, I did miss the "regular mfc dll" statement... sorry.

Glad you got it figured out!

"SB" <shaw...@gmail.com> wrote in message
news:44c90e0c-1841-41eb...@l28g2000vba.googlegroups.com...

Joseph M. Newcomer

unread,
May 17, 2009, 2:45:29 PM5/17/09
to
See below...

On Fri, 15 May 2009 06:57:12 -0700 (PDT), SB <shaw...@gmail.com> wrote:

>On May 15, 4:27�am, "Scot T Brennecke" <Sc...@MVPs.spamhater.org>
>wrote:
>> Some important details to include in order for us to understand the problem you face:
>> * What does "doesn't seem to work" look like?
>
>yes, i should have mentioned that i was getting a linker error.

****
Yes. It is REALLY IMPORTANT to explain the problem you are seeing! And not to put too
fine a point on it, I'll bet that linker message ACTUALLY HAS REAL TEXT THAT EXPLAINS WHAT
IT DISCOVERED TO BE THE ERROR! Is there some reason you can't be bothered to explain the
problem and give us the contents of that message? Are we supposed to use psychic
vibrations to figure out what you are talking about?
****


>
>> * Is your MFC DLL an "Extension DLL" or a "Regular DLL"?
>
>"regular mfc dll (using a shared library)"
>
>> * You don't pass things to and from DLLs; you pass them to and from functions that are exported from DLLs. �
>
>i'm passing the this pointer via an exported function in the mfc dll.

****
I'm sure there is ACTUAL CODE involved in doing this. And I'll bet that you could have
SHOWN us this code!

I have a program that doesn't work, also. Could you please tell me what is wrong?
****


>
>anyway, i figured out what the problem was...somehow when i created
>the new mfc dll project i did not add the .cpp file with source code
>for implementation of the object that i wanted to call methods on from
>the mfc dll.

*****
Which would have been obvious had you bothered to explain what was happening and supply
all necessary details.
joe
*****
>
>thanks for the help
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

0 new messages