Importing C/C++ function from DLL in a Visual Basic application

Mattia Valassi 1 Reputation point
2021-02-11T12:35:45.68+00:00

Guys,
I'm developing an application in VB which requires importing functions from a C/C++ DLL.
Now, I imported several of the functions structuring them like this:

Declare Auto Function functionName_i Lib "library.dll" Alias functionName(ByVal something, ByRef somethingElse) As ReturnClass

Public Function functionName(ByVal something, ByRef somethingElse) As ReturnClass
Return (functionName_i (something, somethingElse))
End Function

When the functions I import have parameters, either by ref or value, everything works all right.
But when I try to use a function without parameters, like a C++ function with functionName(void) as signature, it does not work, with an exception telling me it was impossible to call the function from the library.
Where is my mistake? How should I import functions without parameters correctly?

Thanks,
hope you can help me!

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,690 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,714 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.