|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can I to pass an array to a DLL function?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 Hello carlos
Private Declare Sub valor_prueba Lib "DLL3.dll" (ByVal objptr As Long, ByRef val()) <--------- there is no declaration type so , you should pass a array of objects in VB.Net ( in VB6 you would have passed a variant array ) regards Michel Posseth Show quoteHide quote "Carlos Villaseñor M." <cvmdis***@avantel.net> schreef in bericht news:uX6hVHQrGHA.4212@TK2MSFTNGP02.phx.gbl... > 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 > > >
Not first class in file
Coding style acceptable rounding practices in banking. Can't get <ToolboxBitmap> to work! Inserting a space into a string Program flow with multi-threading app - corrupted datatables where to store sound file WebBrowser control not responding to SetScroll API spurious error 2005 Express Version |
|||||||||||||||||||||||