Board index » cppbuilder » Using BCB6 Dll in VB

Using BCB6 Dll in VB


2004-06-11 09:45:55 PM
cppbuilder110
Hi,
I have made this testdll witch should run in my own BCB6 application and
inVB.
extern "C" void __export __pascal TestDll2 (char *file)
{
int i, x, y = 0;
String S;
String Message;
TStringList *TempList = new TStringList();
S = file;
TempList->LoadFromFile(S);
x = TempList->Count;
for (i=0; i<x; i++)
{
y += TempList->Strings[i].Length();
}
Message = "The file";
Message += S;
Message += " has ";
Message += y;
Message += " characters";
MessageDlg(Message, mtInformation,
TMsgDlgButtons() << mbOK,0);
}
1) It runs well in my application, but what do I have to change that it runs
in VB?
2) The 'pascal' calling convention should be the most universal calling
method used by WIN 32API functions?
3) I suppose I have to set also Project/Options/Advanced Compiler/Calling
convention to 'pascal'?
4) If I built this dll with 'Use Dynamic RTL' UNchecked, it's OK.
But if I also have 'Build with Runtime Packages' UNchecked, I get:
[Linker Error] Unresolved external '__fastcall Dialogs::MessageDlg(const
System::AnsiString, Dialogs::TMsgDlgType, System::Set<Dialogs::TMsgDlgBtn,
0, 10>, int)' referenced from C:\PROGRAM
FILES\BORLAND\CBUILDER6\PROJECTS\TESTDLL2\TESTDLL2.OBJ
5) And last, where can I find some info of how to implement my dll in VB.
Thankyou very much,
Jan Vandyck
 
 

Re:Using BCB6 Dll in VB

Quote
extern "C" void __export __pascal TestDll2 (char *file)
use __declspec(dllexport) instead of __export.
Quote
2) The 'pascal' calling convention should be the most universal calling
method used by WIN 32API functions?
__stdcall is the most universal, followed by __cdecl. To use
the dll from VB, I think you want __stdcall.
Quote
3) I suppose I have to set also Project/Options/Advanced Compiler/Calling
convention to 'pascal'?
No. This will change all internal routines to use the __pascal
calling convention. This is not necessary.
H^2
 

Re:Using BCB6 Dll in VB

"Jan" < XXXX@XXXXX.COM >wrote in message
Quote
1) It runs well in my application, but what do I
have to change that it runs in VB?
The calling convension.
Quote
2) The 'pascal' calling convention should be the most
universal calling method used by WIN 32API functions?
No. You should be using __stdcall instead. All Win32 API functions (except
for wsprintf()) use __stdcall.
Quote
3) I suppose I have to set also Project/Options/Advanced
Compiler/Calling convention to 'pascal'?
No. You should not touch that at all. That only effects which calling
convention is used by default when no convention is explicitally specified
in the code. That is not the case here.
Quote
4) If I built this dll with 'Use Dynamic RTL' UNchecked, it's OK.
But if I also have 'Build with Runtime Packages' UNchecked, I get:
Did you enable the VCL when you first made the DLL project? Alternatively,
use the Win32 API's MessageBox() instead of the VCL's MessageDlg(). Even
better, if you access the file data directly without using TStringList then
you don't need the VCL at all.
Gambit
 

{smallsort}

Re:Using BCB6 Dll in VB

Quote
Did you enable the VCL when you first made the DLL project?
Alternatively,
use the Win32 API's MessageBox() instead of the VCL's MessageDlg(). Even
better, if you access the file data directly without using TStringList
then
you don't need the VCL at all.

Yes I did enable the VCL. In this testdll I can skip the VCL,
but this dll is made only to test the compatibility with VB.
In my real dll's I use the VCL alot.
Do I have to ship my dll's together wit VCL60.BPL or change my code (skip
VCL)?
I don't like any of them. Is there another solution?
Thanks very much Gambit.
(and also Harold)
Jan Vandyck