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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:01:51+00:00 2026-05-16T18:01:51+00:00

I have acquired a DLL that was created in Visual Basic from a third

  • 0

I have acquired a DLL that was created in Visual Basic from a third party vendor(Sensor DLL.dll). This DLL contains functions for talking to a sensor, and I need to call these functions from a Visual C++ program I am writing. The vendor will not provide a header file, and I do not know Visual Basic. If I had a header file this would be a 15 minute project… instead I am still struggling with it a week later. Please Help!

I am told one function (Get_Data) in the DLL is of the form:

Public Function Get_Data(ByVal Handle As String) As String

I have tried several methods for calling this Get_Data function with no success:

Method 1) the DllImport attribute

#using <mscorlib.dll>
using namespace System::Runtime::InteropServices; 

namespace Sensor
{

[DllImport(“Sensor DLL.dll”, EntryPoint = “Get_Data”, CharSet = System::Runtime::InteropServices::CharSet::Unicode)]
BSTR Get_Data(BSTR Handle);
}

//then I call the function
Sensor::Get_Data(Handle);

This method seems to be the closest I have gotten to a sloution. It compiles, but gives the following error when it runs:

An unhandled exception of type ‘System.EntryPointNotFoundException’ occurred

Additional information: Unable to find an entry point named ‘Get_Data’ in DLL ‘Sensor DLL.dll’.

I have tried various datatype combinations/permutations besides BSTR including BSTR*, wchar_t, int, etc. It is possible that I missed one, but each datatype returns the same error.

Method 2) dllimport storage-class attribute

__declspec(dllimport) BSTR Get_Data(BSTR Handle);

//then I call the function
Get_Data(Handle);

This method is confusing to me because I don’t specify the DLL I want to import from. I have copied the DLL to the project folder and I have added it to the project manually, so hopefully that means it can be found. When I compile the linker returns the following errors:


error LNK2028: unresolved token (0A00034F) “wchar_t * __cdecl Get_Data(wchar_t *)” (?Get_Data@@$$FYAPA_WPA_W@Z) referenced in function “int __cdecl main(void)” (?main@@$$HYAHXZ)

error LNK2019: unresolved external symbol “wchar_t * __cdecl Get_Data(wchar_t *)” (?Get_Data@@$$FYAPA_WPA_W@Z) referenced in function “int __cdecl main(void)” (?main@@$$HYAHXZ)

I suspected maybe this meant I should be using wchar_t or wchar_t* instead of BSTR, but changing to either datatype results in the same error.

Method 3) GetProcAddress

typedef BSTR (*Get_Data_Ptr)(BSTR Handle);  
HINSTANCE LoadMe;
LoadMe = LoadLibraryA("Sensor DLL.dll");

if (!LoadMe)
    std::cout << "\nDLL failed to load!\n";

Get_Data_Ptr LibMainGet_Data;  
LibMainGet_Data = (Get_Data_Ptr)GetProcAddress(LoadMe,"Get_Data");

//then I call the function
LibMainGet_Data(Handle);

This will compile, but gives the following error when run:


An unhandled exception of type ‘System.AccessViolationException’ occurred

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

When I mouse over the various parts of this code in debug mode it seems that, like the first method, it was also unable to find the ‘Get_Data’ entry point in the DLL.

Has anyone called functions from a VB DLL using C++ when you haven’t made the DLL yourself and you don’t have .idl files, etc? Does anyone have a working example like this you could share?
Thanks!

  • 1 1 Answer
  • 2 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-16T18:01:52+00:00Added an answer on May 16, 2026 at 6:01 pm

    A VB6 DLL is normally a COM server. You do in fact have the equivalent of a .h file, it has a type library embedded in it. Start this off with Project + Properties, Common Properties, Framework and References. Add New Reference button, Browse tab, select the DLL.

    Next, View + Object Browser. You should see the generated Interop library in the list. Open the node to see what is there. You write normal managed code, like gcnew, to create the COM object and call the interface methods. You do need some minimum documentation on the available methods to have a guess at how they should be called.

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

Sidebar

Related Questions

I have a class with member functions that require a boost::unique_lock be acquired on
I have acquired the habit of declaring reused variables outside loops from having worked
Here is the problem: I have datagrid binded with data acquired from web service
I'm writing a C# application that calls a C++ dll. This dll is a
I have an accordion with single title like this <div class=accordion id=accordion_acquired_services> <h3><a href=#>Acquired
I have a map of the US acquired from here (called U.S. Map). I
I read that every object in java have a lock.That will be acquired by
I have acquired a subversion repository. The problem with it is that everything is
I have a asp:Wizard control on a site running Framework 3.5. I acquired the
I typically acquire a character with %c , but I have seen code that

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.