I have written a quick C++ DLL in Visual Studio, with a single function called ReportVersion() that returns 1.
int _stdcall ReportVersion() {
return 1;
}
I then created a VB.net EXE to call this DLL.
Public Class Form1
Private Declare Function ReportVersion Lib "Test_DLL.dll" () As Long
Private Sub btnVersion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVersion.Click
Call MsgBox(ReportVersion())
End Sub
End Class
If I press F5 and run in either Release/Debug mode, the return value of ReportVersion is 6824607285638070273.
If I build the solution and run the .EXE manually, the return value is 1 (as expected).
Where on earth is it getting 6824607285638070273 from?
For reference, I used these 2 articles as examples for creating them
http://edais.mvps.org/Tutorials/CDLL/CDLLch1b.html
http://edais.mvps.org/Tutorials/CDLL/CDLLch2.html
As I’ve never done a call between DLL/Application written in different languages.
Having emailed the original author of the linked articles, I was pleasantly surprised to get a response back about such an old article. This helped me understand the problem.