Oh, VS6. Use DumpBin /exports on your DLL to find out the exact spelling of the export name in the DLL. You can use DependencyWalker too. You can use a .def file to force the name exactly the way you want it.
Compiled it into a DLL (removed the precompiled headers that the 'wizard' put in), then created a VB Windows program:
Public
Class Form1
Private Declare Auto Function DoMultiply Lib "test.dll" (ByVal x As Single, ByVal y As Single) As Single
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim result As Single = DoMultiply(45, 7.3) MessageBox.Show(result.ToString) End Sub End Class
Ensured the DLL was in the same folder as the VB EXE. Now the C program is ready for fine tuning, but that basically works.
Class Form1
Public Declare Ansi Function b5 Lib "b1.dll" (ByVal x As Integer) As Double
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim y As Double
Dim x As Integer
x = 9
y = b5(x)
MsgBox(y)
End Sub
End
Class
I get an error = > in the line y= b5(x) => Unable to find an entry point named 'b5' in DLL 'b1.dll'.
No, an app is infinitely harder than a DLL, if possible at all. Create a DLL with the C/C++ compiler, use __declspec(dllexport) on the functions that you want to use in your VB program. Then in your VB program, declare the functions with the Declare statement. The trivial example is:
In 'C': double __declspec(dllexport) MyCFunction(int arg) { // blabla }
In VB.NET: Public Declare Ansi Function MyCFunction Lib "myclibrary.dll" (ByVal arg As Integer) As Double
how can I integrate C program in VB express?
gtjr92
PK2000
jitendra badkas
Leaf.
extern "C" double __declspec(dllexport) b5(int x) {
return x;
}
Mikaelm
Here's what I did to test. Created a C Win32 DLL, removed all the superfluous ***, including the precompiled headers:
Created a file called test.cpp
#include
<windows.h>float __stdcall DoMultiply( float x, float y)
{
return x * y;
}
Added a .DEF file, also:
LIBRARY "test"
EXPORTS
DoMultiply @1
Compiled it into a DLL (removed the precompiled headers that the 'wizard' put in), then created a VB Windows program:
Public
Class Form1Private Declare Auto Function DoMultiply Lib "test.dll" (ByVal x As Single, ByVal y As Single) As Single
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim result As Single = DoMultiply(45, 7.3)
MessageBox.Show(result.ToString)
End Sub
End Class
Ensured the DLL was in the same folder as the VB EXE. Now the C program is ready for fine tuning, but that basically works.
Ephi
thank you... it's working...
I'm really appreciate all of you for your help...
Best Regards,
Yaniv
Ion101
Create a .DEF file in the C project, with something like:
LIBRARY MyFileName
EXPORTS
MyFunction @1
MyOtherFunction @2
And change the declaration to __stdcall instead of __declspec(dllexport).
See if that works.
mahima
I tried extern "C" I get the same error...
any more ideas
djshades2004
I wrote dumpbin /exports b1.dll and I get this information:
Dump of file b1.dll
file type: DLL
summary
4000 .data
1000 .idata
2000 .rdata
2000 .reloc
28000 .text
and in the b1.def file I saw this :
# microsoft Developer studio............,included by b1.mak
./stdafx.cpp : /
"..\..\vc98\include\basetsd.h"\
".\stdafx.h"\
So I don't understand how this information help me
sascue
I tried to do a sample program that using DLL
in c++ =>B1.DLL:
double __declspec(dllexport) b5(int x) {
x=5;
return x;
}
in vb .net:
Public
Class Form1 Public Declare Ansi Function b5 Lib "b1.dll" (ByVal x As Integer) As Double Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim y As Double Dim x As Integerx = 9
y = b5(x)
MsgBox(y)
End SubEnd
ClassI get an error = > in the line y= b5(x) => Unable to find an entry point named 'b5' in DLL 'b1.dll'.
any ideas what I'm doing wrong
Regards,
Yaniv
Matt354245
still the same error...
I copy paste the code in C++ and VB and I get the same error maybe I'm doing something wrong in VS6 C++...
this is how I open a new DLL file:
File=> New
projects=> win32 dynamic-link library
files=> c/c++ Header File
I copy paste your code
and click the Bulid(F7) button
and copy the DLL file to the debug VB folder.
what I'm doing wrong...
thank you for you help... I'm really appreciate it
Yaniv
robertje
Benj78
In 'C':
double __declspec(dllexport) MyCFunction(int arg) {
// blabla
}
In VB.NET:
Public Declare Ansi Function MyCFunction Lib "myclibrary.dll" (ByVal arg As Integer) As Double