Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

#import  in VC6

Posted on 1999-07-16
9
Medium Priority
?
618 Views
Last Modified: 2013-12-03
I've got a COM object (for Goldmine) that I need to add to my project. I ran regsvr32 on the objects DLL and put it's other DLL in my system folder. Then I added this code to my project:

// Import the type library
 
#import "k:\gmobject\gmobject.dll" no_namespace

// Create a smart pointer to the ISQL interface
 
ISQLPtr pSQL;
 
// Create an instance of the object
 
hr=pSQL.CreateInstance(__uuidof(ISQL));
 
At this point it compiles and I can see all the members through VC's IntelliSense. When the application is executed however I get an error returned from CreateInstance:

hr = 80040154h (REGDB_E_CLASSNOTREG: Class not registered)

Goldmine of course has no information on how to use their object so if anyone has had more experience with usiong the #import directive in VC6 to load objects I'd love to hear some suggestions. I've only used it to with ADO at this point and that works.
0
Comment
Question by:forloop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1403108
You might also want to confirm that you've called OleInitialize() prior to creating the instance of the COM object.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1403109
thui - this would result in CO_E_NOTINITIALIZED rather than REGDB_E_CLASSNOTREG ...
0
 

Author Comment

by:forloop
ID: 1403110
I've got that covered. (See jkr's remarks)
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

by:forloop
ID: 1403111
So... I'm guessing everything looks fine, because I'm getting no feedback.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1403112
At least for me, it does ;-)

You might want to provide a 'traditional' CLSID in the 'CreateInstance()' call rather than using __uuidof()
0
 

Author Comment

by:forloop
ID: 1403113
Yeah, I've tried that too... Gives the same result. The object seems to work fine from VB. The #import directive is the only way to use a COM object in VC6 when all you have is the DLL right?
0
 
LVL 1

Accepted Solution

by:
hasmet earned 280 total points
ID: 1403114
I hope I am not too late but your answer is :
hr=pSQL.CreateInstance(__uuidof(SQL));

use your class ID not your interface ID so
ISQL is your interface and most likly SQL is your class.

SO look at your tlh file and find exact name of your class
next to coclass decleration.

0
 

Author Comment

by:forloop
ID: 1403115
Thanks!
0
 
LVL 86

Expert Comment

by:jkr
ID: 1403116
Hmm - didn't I also suggest to use the CLSID? ;-)
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 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