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 8757337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:16:39+00:00 2026-06-13T14:16:39+00:00

I have a dll I wrote in VS2010 C#, and ensured the project is

  • 0

I have a dll I wrote in VS2010 C#, and ensured the project is marked COM visible, and registered for COM Interop. I can use in a VS2010 C++ project, by going through the C++ Property Pages->Common Properties->Framework and References, referencing the C# project, and then writing the code to instantiate my object with gcnew.

However, this method won’t work in Borland C++. Since the C# dll was registered, I can add a reference to it, and *_OCX.h and *_TLB.h files were generated and I can see what look like usable objects in those files. But, I don’t know how to create my class. I don’t even know which class is the right one because of the renaming that’s been done.

In C#, the class can be as simple as:

public namespace MyTest
{
   public class MyClass
   {
      public MyClass() { }
      public int SomeInt { get; set; }
   }
}

In C++, a lot is generated. Some of which is:

MyTest_TLB.cpp

#include <vcl.h>
#pragma hdrstop
#include "MyTest_TLB.h"

namespace Mytest_tlb
{
const GUID LIBID_MyTest = {0xE082EF89, 0x8FE8, 0x45FA,{ 0x8D, 0x13, 0x20,0x3B, 0x58, 0xCF,0x7E, 0x82} };
const GUID CLSID_MyClass = {0x22E68247, 0x3CDB, 0x3CCA,{ 0xB8, 0x8B, 0xB9,0x52, 0xF3, 0x4C,0x11, 0x70} };
const GUID IID__MyClass = {0x6A6EC8CB, 0x1AAB, 0x3AB1,{ 0xBD, 0x57, 0x0F,0xE2, 0x17, 0x78,0xD4, 0xE2} };
};     // namespace Mytest_tlb

MyTest_TLB.h

namespace Stdvcl {class IStrings; class IStringsDisp;}
using namespace Stdvcl;
typedef TComInterface<IStrings> IStringsPtr;
typedef TComInterface<IStringsDisp> IStringsDispPtr;

namespace Mytest_tlb
{
extern __declspec (package) const GUID LIBID_MyTest;
extern __declspec (package) const GUID IID__MyClass;
extern __declspec (package) const GUID CLSID_MyClass;

interface DECLSPEC_UUID("{6A6EC8CB-1AAB-3AB1-BD57-0FE21778D4E2}") _MyClass;
typedef TComInterface<_MyClass, &IID__MyClass> _MyClassPtr;
typedef _MyClass MyClass;
typedef _MyClassPtr MyClassPtr;

interface _MyClass  : public IDispatch
{
public:
#if !defined(__TLB_NO_INTERFACE_WRAPPERS)
#endif //   __TLB_NO_INTERFACE_WRAPPERS
};

#if !defined(__TLB_NO_INTERFACE_WRAPPERS)
template <class T /* _MyClass */ >
class TCOM_MyClassT : public TComInterface<_MyClass>, public TComInterfaceBase<IUnknown>
{
public:
  TCOM_MyClassT() {}
  TCOM_MyClassT(_MyClass *intf, bool addRef = false) : TComInterface<_MyClass>(intf, addRef) {}
  TCOM_MyClassT(const TCOM_MyClassT& src) : TComInterface<_MyClass>(src) {}
  TCOM_MyClassT& operator=(const TCOM_MyClassT& src) { Bind(src, true); return *this;}
};
typedef TCOM_MyClassT<_MyClass> TCOM_MyClass;

template<class T>
class _MyClassDispT : public TAutoDriver<_MyClass>
{
public:
  _MyClassDispT(){}

  _MyClassDispT(_MyClass *pintf)
  {
    TAutoDriver<_MyClass>::Bind(pintf, false);
  }

  _MyClassDispT(_MyClassPtr pintf)
  {
    TAutoDriver<_MyClass>::Bind(pintf, true);
  }

  _MyClassDispT& operator=(_MyClass *pintf)
  {
    TAutoDriver<_MyClass>::Bind(pintf, false);
    return *this;
  }

  _MyClassDispT& operator=(_MyClassPtr pintf)
  {
    TAutoDriver<_MyClass>::Bind(pintf, true);
    return *this;
  }

  HRESULT BindDefault()
  {
    return OLECHECK(Bind(CLSID_MyClass));
  }

  HRESULT BindRunning()
  {
    return BindToActive(CLSID_MyClass);
  }
};
typedef _MyClassDispT<_MyClass> _MyClassDisp;

typedef TCoClassCreatorT<TCOM_MyClass, _MyClass, &CLSID_MyClass, &IID__MyClass> CoMyClass;
#endif  //   __TLB_NO_INTERFACE_WRAPPERS
};     // namespace Mytest_tlb

There’s also a TCOM_MyClassT.h file. I don’t know what any of this means. The tutorials or examples I’ve seen are either for VC++, out-of-date, not specific to my problem, or just don’t work.

  • 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-06-13T14:16:40+00:00Added an answer on June 13, 2026 at 2:16 pm

    Got it.

    CoInitialize(NULL);
    _MyClassPtr obj;
    HRESULT ptr = obj.CreateInstance(__uuidof(MyClass));
    

    Frustrating that some of the simplest things can be so difficult.

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

Sidebar

Related Questions

I have a DLL that I wrote in C# and I want to use
in mine project i have a Windows application and a dll. I have wrote
I wrote an asp.net website. I have a BLL project (meaning dll type project)
so I have this project in java that uses a jni .dll i wrote
I wrote a C# project in which I use a C++ dll (also written
I have a C++ DLL that I wrote that has a single exposed function,
I have a simple python script that i wrote for IDA, but i'am can't
I have a COM+ application that I wrote using C#. I have the assembly
We wrote a COM in-proc Server(dll)(say x.dll) which is dynamically linking to a library(say
I have this library http://www.codeproject.com/KB/cs/globalhook.aspx I've downloaded it and compiled it to DLL. At

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.