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

  • SEARCH
  • Home
  • 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 6196117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:35:11+00:00 2026-05-24T03:35:11+00:00

I followed this tuorial to create a COM dll in Visual Basic. http://www.codeproject.com/KB/COM/Basics_of_Idl_file.aspx I

  • 0

I followed this tuorial to create a COM dll in Visual Basic. http://www.codeproject.com/KB/COM/Basics_of_Idl_file.aspx

I now want to use this dll in a C++ project. I used OLE/COM Viewer to create an .idl file as is described in the second half this tutorial.
http://www.codeproject.com/KB/COM/vb_from_vc.aspx

I compiled the .idl with the midl compiler and included the .h file that was created in my c++ project.

Here is my Visual Basic Code

<ComClass(MyComClass.ClassId, MyComClass.InterfaceId, MyComClass.EventsId)> _
Public Class MyComClass

#Region "COM GUIDs"
    ' These  GUIDs provide the COM identity for this class 
    ' and its COM interfaces. If you change them, existing 
    ' clients will no longer be able to access the class.
    Public Const ClassId As String = "46604f8a-85a2-4027-9728-0390534c9209"
    Public Const InterfaceId As String = "30274029-711d-459a-9270-f9d73ad8737f"
    Public Const EventsId As String = "5e234d69-5263-4001-86ff-c475b113a77d"
#End Region

    ' A creatable COM class must have a Public Sub New() 
    ' with no parameters, otherwise, the class will not be 
    ' registered in the COM registry and cannot be created 
    ' via CreateObject.
    Public Sub New()
        MyBase.New()
    End Sub
    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub
    Public Sub DisplayMessage()
        MsgBox("Hello from MyComClass!")
    End Sub
End Class

Here is my c++ Code

    // Declare an HRESULT and a pointer to the clsVBTestClass interface

HRESULT     hr;
_MyComClass *IVBTestClass = NULL;

// Now we will intilize COM

hr = CoInitialize(0);

// Use the SUCCEEDED macro and see if we can get a pointer 

// to the interface

if(SUCCEEDED(hr))
{
    hr = CoCreateInstance( CLSID_MyComClass,
                NULL,
                CLSCTX_INPROC_SERVER,
                IID__MyComClass, 
                (void**) &IVBTestClass);

    // If we succeeded then call the CountStringLength method, 

    // if it failed then display an appropriate message to the user.

    if(SUCCEEDED(hr))
    {
        long        ReturnValue;
        _bstr_t     bstrValue("Hello World");

        // We can test this HR as well if we wanted to

        hr = IVBTestClass->DisplayMessage();

        hr = IVBTestClass->Release();
    }
    else
    {

    }
}
// Uninitialize COM

CoUninitialize();

I receive the following errors when I compile my c++ project

error LNK2001: unresolved external symbol _CLSID_MyComClass
error LNK2001: unresolved external symbol IID_MyComClass

Could someone help me figure out what I am doing wrong?

  • 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-24T03:35:12+00:00Added an answer on May 24, 2026 at 3:35 am

    If you did not get to the last part of creating a Type Library, that is important.

    You then need an #import statement in your C++ code to use the .tlb file (or .dll if the type library is embedded in the dll, which is common).

    #import is the equivalent to including a header file with COM, but generates a .tlh file (header) and a .tli (implementation) automatically.

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

Sidebar

Related Questions

No related questions found

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.