Hello,
Please help me to use a CBuilder DLL that contains classes from Visual Studio C# 2005, I have problems with the underscores.
I used a well-known example which creates a DLL in Cbuilder 5 (use VCL set, source C++) and I named it DLLProject.dll:
I tested the dll in Cbuilder 5, using C convention and Generate underscores On, and it worked.
Next step I rebuild the dll this time using Generate underscores Off, and I called this dll from C# 2005 as in the following example:
and it worked again.
My problem is when I have a class in my DLL project under CBuilder, I can’t just build it with Generate underscores unset because I receive a link error:
Unresolved external ‘_Class Create’ referenced from …
How can I get rid off the underscores from my CBuilder dll if I build it with Generate underscores set, in order to use it in my C# code
?
Or other solution to resolve this issue?
Thank you
Please help me to use a CBuilder DLL that contains classes from Visual Studio C# 2005, I have problems with the underscores.
I used a well-known example which creates a DLL in Cbuilder 5 (use VCL set, source C++) and I named it DLLProject.dll:
Code:
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#include <windows.h>
#pragma argsused
double BoxArea(double L, double H, double W);
double BoxVolume(double L, double H, double W);
extern "C" __declspec(dllexport)void BoxProperties(double Length, double Height,
double Width, double& Area, double& Volume);
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return 1;
}
//---------------------------------------------------------------------------
double BoxArea(double L, double H, double W)
{
return 2 * ((L*H) + (L*W) + (H*W));
}
//---------------------------------------------------------------------------
double BoxVolume(double L, double H, double W)
{
return L * H * W;
}
//---------------------------------------------------------------------------
void BoxProperties(double L, double H, double W, double& A, double& V)
{
A = BoxArea(L, H, W);
V = BoxVolume(L, H, W);
}
I tested the dll in Cbuilder 5, using C convention and Generate underscores On, and it worked.
Next step I rebuild the dll this time using Generate underscores Off, and I called this dll from C# 2005 as in the following example:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace UnManaged
{
public partial class Form1 : Form
{
[DllImport("DLLProject.dll")]
static extern void BoxProperties(double L, double H, double W,
double[] A, double[] V);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double myLength=2, myHeight=3, myWidth=4;
double[] myArea = new double [1];
double[] myVolume = new double [1];
BoxProperties(myLength, myHeight, myWidth, myArea, myVolume);
}
}
}
My problem is when I have a class in my DLL project under CBuilder, I can’t just build it with Generate underscores unset because I receive a link error:
Unresolved external ‘_Class Create’ referenced from …
How can I get rid off the underscores from my CBuilder dll if I build it with Generate underscores set, in order to use it in my C# code
?
Or other solution to resolve this issue?
Thank you