[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using ActiveX Control in MFC DLL

Posted on 2001-07-11
5
Medium Priority
?
696 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Loops Section Overview

834 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