Share via

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!

Developer technologies | C++
Developer technologies | 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.

Developer technologies | VB

Your answer

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