Solved

Using ActiveX Control in MFC DLL

Posted on 2001-07-11
5
690 Views
Last Modified: 2013-11-20
Hi,

I'm trying to create an MFC DLL that creates a dialog and has a Microsoft Web Browser control in it and use it in a straight-api style windows program. I know my activex stuff is correct because i tried creating a dialog-only mfc exe app with a web browser control in it, and it worked fine. i know my dll function is exported correctly because when the web browser control isn't in the dialog, it acts fine.  Its when i throw the activex control and dll into the mix together that things get nasty. The only thing that the debugger says is that CoCreateInstance has failed, and it asks me if i'm sure the control is registered properly and it lists the CLSID. Any help would be greatly appreciated. I'm new, so I only have 75pts, but you can answer this, they're yours.

-zack
0
Comment
Question by:zack_angelo
5 Comments
 

Author Comment

by:zack_angelo
ID: 6273515
hey guys, i just figured this out--when using activex in an MFC dll, you must call CoInitialize() for the DLL's thread. So...just throw a call to CoInitialize() in your DLL's InitInstance() event and you're all set, I hope this helps out anyone else that was having this problem. It seems that Microsoft has a habit of writing their "wizards" to do everything except a smidgen of a task for you to do...and of course that small task will make everything fall apart. <sigh>

-zack
0
 
LVL 4

Expert Comment

by:mandhjo
ID: 6273754
Don't forget to call CoUninitiliaze in the ExitInstance function.
0
 
LVL 2

Expert Comment

by:tdubroff
ID: 6274116
Yes, CoInitialize() must be called per thread!  In MFC though, I believe you can make a call to AfxOleInit() which does both the CoInitialize() and the CoUninitialize() for you.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490295
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ'd and pts refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 9537282
PAQed, with points refunded (75)

Computer101
E-E Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
has22 challenge 11 104
tripleUp challenge 7 86
Trying to run powershell  in a batch file. How do I do this? 8 105
How do I get Window Title of all opened process? 4 11
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question