C
Carlos Villaseñor M.
Hi everybody!
I finally have success implementing my first DLL function, I have exported a
C++ function with a DLL using the "Declare" statement in Basic, but now I
have a doubt, how can I to pass an array in the DLL function parameters
list, I need to pass y return the same array, but changed, to my Basic
application.
Below I show my code in Basic:
Private Declare Function CreateDll3 Lib "DLL3.dll" () As Long
Private Declare Sub DestroyDll3 Lib "DLL3.dll" (ByVal objptr As Long)
Private Declare Function GetCpuSpeedDll3 Lib "DLL3.dll" (ByVal objptr As
Long) As Integer
Private Declare Sub valor_prueba Lib "DLL3.dll" (ByVal objptr As Long, ByRef
val()) <--------- this is te function that need to pass an array
Private Declare Sub InitCommonControls Lib "comctl32.dll" ()
Private Sub Form_Initialize()
InitCommonControls
ChDir App.Path
End Sub
Private Sub Command1_Click()
Dim nSpeed As Integer
Dim s As String
Dim s2 As String
Dim objptr As Long
Dim valor(0 To 3) As Integer
valor(0) = 3
valor(1) = 3
valor(2) = 3
Screen.MousePointer = vbHourglass
objptr = CreateDll3()
nSpeed = GetCpuSpeedDll3(objptr)
valor_prueba(objptr, valor()) <--------Here I call the DLL function, I
don't know if this is right....
DestroyDll3 (objptr)
Screen.MousePointer = 0
s = nSpeed
Form1.Text1.Text = "GetCpuSpeedDll3(objptr) returned " + s
Form1.Text2.Text = "El valor calculado es " + s2
End Sub
I appreciate some help!
Thank you
Carlos Villaseñor
I finally have success implementing my first DLL function, I have exported a
C++ function with a DLL using the "Declare" statement in Basic, but now I
have a doubt, how can I to pass an array in the DLL function parameters
list, I need to pass y return the same array, but changed, to my Basic
application.
Below I show my code in Basic:
Private Declare Function CreateDll3 Lib "DLL3.dll" () As Long
Private Declare Sub DestroyDll3 Lib "DLL3.dll" (ByVal objptr As Long)
Private Declare Function GetCpuSpeedDll3 Lib "DLL3.dll" (ByVal objptr As
Long) As Integer
Private Declare Sub valor_prueba Lib "DLL3.dll" (ByVal objptr As Long, ByRef
val()) <--------- this is te function that need to pass an array
Private Declare Sub InitCommonControls Lib "comctl32.dll" ()
Private Sub Form_Initialize()
InitCommonControls
ChDir App.Path
End Sub
Private Sub Command1_Click()
Dim nSpeed As Integer
Dim s As String
Dim s2 As String
Dim objptr As Long
Dim valor(0 To 3) As Integer
valor(0) = 3
valor(1) = 3
valor(2) = 3
Screen.MousePointer = vbHourglass
objptr = CreateDll3()
nSpeed = GetCpuSpeedDll3(objptr)
valor_prueba(objptr, valor()) <--------Here I call the DLL function, I
don't know if this is right....
DestroyDll3 (objptr)
Screen.MousePointer = 0
s = nSpeed
Form1.Text1.Text = "GetCpuSpeedDll3(objptr) returned " + s
Form1.Text2.Text = "El valor calculado es " + s2
End Sub
I appreciate some help!
Thank you
Carlos Villaseñor