Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 646809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:39:12+00:00 2026-05-13T21:39:12+00:00

I wish to use a COM dll in my C++ library. The way I

  • 0

I wish to use a COM dll in my C++ library.
The way I figured going about it, is to #import the dll’s .tlb file, which I did :

#import "mycom.tlb" no_namespace

The problem is , I don’t quite know where to place this declaration. should it be inside the H file or the CPP file? or maybe the stdafx.h file?
I tried placing it in the .cpp file , just for testing.

in the H file I have this member declared :

ILogicSecuredPtr m_pbLogic;

(where ILogicSecured is the interface I want to work with in my COM dll)

Then I added this in the constructor to instantiate the interface :

CoInitialize(NULL);
m_pbLogic(__uuidof(LogicSecured)); 

(where LogicSecured is the name of the object that implements the interface)

In the destructor I added :

CoUninitialize();

This won’t compile however, no matter where I try to place the #import declaration.
it just doesn’t recognize the ILogicSecured object.
I get this error in the H file :

Error   2   error C2146: syntax error : missing ';' before identifier 'm_pbLogic'

I should also mention that when I F12 (in Visual Studio) on the ILogicSecuredPtr declaration, it takes me to the tlh file just fine. So I know it recognizes it.

What am I doing wrong here?

Thanks alot.
Roey

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:39:12+00:00Added an answer on May 13, 2026 at 9:39 pm

    The problem is that when the compiler parses the .h file it has not seen the #import yet. Since your project is small your best bet is to put #import into stdafx.h.

    When you press F12 Visual Studio uses Intellisence database information that is formed parsing all the sources in order that might be different from the compilation order. So it’s quite typical to have Intellisence know where something is declared and the compiler to not compile it at the same time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For local testing (and learning), I wish to use x.com host name instead of
I wish to have a slider similar to they use. http://www.koovs.com/apple-ipod Can anyone suggest
I wish to use JSON.Net on a brand spankin new Mono class library (say
I wish to use LogParser.DLL assembly, so I test it over normal console application,
The class I wish to use is: https://github.com/philsturgeon/codeigniter-curl/blob/master/libraries/Curl.php How can I use this in
I wish to use the method with the following signature: exec(String command, String[] envp,
I wish to use Spring MVC to provide a REST web service. However, running
I wish to use the Translator classes of Zend framework in my app, but
I wish to use common CRC logic in a VB.NET or C# application as
I wish to use a jQuery .load(oracle apex url) query. I have a main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.