title: How to use COM dll in my C++ program
body: <p>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 : </p>
  
  <pre><code>#import "mycom.tlb" no_namespace
  </code></pre>
  
  <p>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. </p>
  
  <p>in the H file I have this member declared :</p>
  
  <pre><code>ILogicSecuredPtr m_pbLogic;
  </code></pre>
  
  <p>(where ILogicSecured is the interface I want to work with in my COM dll)</p>
  
  <p>Then I added this in the constructor to instantiate the interface : </p>
  
  <pre><code>CoInitialize(NULL);
  m_pbLogic(__uuidof(LogicSecured)); 
  </code></pre>
  
  <p>(where LogicSecured is the name of the object that implements the interface)</p>
  
  <p>In the destructor I added : </p>
  
  <pre><code>CoUninitialize();
  </code></pre>
  
  <p>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 : </p>
  
  <pre><code>Error   2   error C2146: syntax error : missing ';' before identifier 'm_pbLogic'
  </code></pre>
  
  <p>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.    </p>
  
  <p>What am I doing wrong here?</p>
  
  <p>Thanks alot.
  Roey</p>