Hello,
I am trying to create a function in a DLL (using Visual C++) that returns a string, and then use it in Visual Basic.
I have never actually created a dll before, but after following a tutorial, i ended up with both sides compiling succesfully, but when i run the vb prog, Visual Basic, causes an illegal operation and closes..
Here is a quick insight...
Visual Basic Side:
--------------------
Option Explicit
Private Declare Function getSerial Lib "getProp.dll" (ByVal Drv As Integer) As String
Private Sub Command1_Click()
Text1.Text = getSerial(0)
End Sub
--------------that's all!
for the Visual C++ side...
CString serial[4]; //global array
CString _stdcall getSerial(int device)
{
FillValues();
return serial[device];
}
=====================
and then the def file
; getharddll.def : Declares the module parameters for the DLL.
LIBRARY "getprop"
DESCRIPTION 'Gets physical properties of hard drives'
EXPORTS
; Explicit exports can go here
getSerial
IS there anything wrong?
The important question is
can i return a CString in vC++ and receive it as a String in VB? are there any other solutions??
Thank you very much in advance...
I am trying to create a function in a DLL (using Visual C++) that returns a string, and then use it in Visual Basic.
I have never actually created a dll before, but after following a tutorial, i ended up with both sides compiling succesfully, but when i run the vb prog, Visual Basic, causes an illegal operation and closes..
Here is a quick insight...
Visual Basic Side:
--------------------
Option Explicit
Private Declare Function getSerial Lib "getProp.dll" (ByVal Drv As Integer) As String
Private Sub Command1_Click()
Text1.Text = getSerial(0)
End Sub
--------------that's all!
for the Visual C++ side...
CString serial[4]; //global array
CString _stdcall getSerial(int device)
{
FillValues();
return serial[device];
}
=====================
and then the def file
; getharddll.def : Declares the module parameters for the DLL.
LIBRARY "getprop"
DESCRIPTION 'Gets physical properties of hard drives'
EXPORTS
; Explicit exports can go here
getSerial
IS there anything wrong?
The important question is
can i return a CString in vC++ and receive it as a String in VB? are there any other solutions??
Thank you very much in advance...