K so I got bored with their example and wanted to try out what I had gathered from reading things. I made a program to calculate the area of a circle, here's my VB code:
Code:
Private Declare Function ReturnVersion Lib "C:\Documents and Settings\Tim Hansen\My Documents\Visual Studio Projects\circlearea_devcpp.dll" () As Long
Private Declare Function circlearea Lib "C:\Documents and Settings\Tim Hansen\My Documents\Visual Studio Projects\circlearea_devcpp.dll" (ByVal area As Double) As Double
Private Sub About_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles About.Click
' Report Version Number
Call MsgBox(ReturnVersion())
End Sub
Private Sub Bye_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bye.Click
Application.Exit()
End Sub
Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calculate.Click
Dim area, radius As Double
radius = InputBox.Text
area = circlearea(radius)
OutputBox.Text = Str$(area)
End Sub
Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear.Click
InputBox.ResetText()
OutputBox.ResetText()
End Sub
and here's my C++ code:
Code:
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
int ReturnVersion(void)
{
int version = 1;
return version;
}
double circlearea(double radius)
{
double area;
area = 3.1415926535 * (radius * radius);
return area;
}
and finally, here's my .def file:
Code:
; dlltool --base-file C:\DOCUME~1\TIMHAN~1\LOCALS~1\Temp/cca03432.base --output-exp circlearea_devcpp.exp --dllname circlearea_devcpp.dll --output-def libcirclearea_devcpp.def --no-export-all-symbols --add-stdcall-alias --exclude-symbol=DllMainCRTStartup@12 --def C:\DOCUME~1\TIMHAN~1\LOCALS~1\Temp/cca03432.def --output-lib libcirclearea_devcpp.a
EXPORTS
the .def file was automatically generated by Dev-C++ and if i modify it by taking out everything before "EXPORTS" and adding ReturnVersion and circlearea after exports, it will not work with the VB interface.
So I have two questions: How do I get it to work? lol
And how can I call each function seperately? Because the same code in MSVC++ works but I get a message saying its a limited version of the program and when I ask for the version, it gives me a message that has "circlearea" for the title and then in the message has "7479125..." (probably whatever random junk is chilling in my ram) Do I need to create a seperate cpp file for each function? Thanks