Pasar el parámetro Integer de Vb6 a C++ dll
Public Declare Function getTable Lib "LuxDll.dll" (ByVal table As Integer, _ ByVal col As Integer) As String BSTR _stdcall getTable(int table, int col) Dim i i=5 debug.print getTable(i, 1)
Lo anterior funciona
but if I did "Dim i as integer" it crashes
should the parameters in VB be something other than integer?
EDIT: I should specify the C++ side crashes and its because the integer value gets passed as -65000ish
preguntado el 27 de noviembre de 13 a las 00:11
In mixing VB6 with C/++, a C int equates to a Long in VB6: so
Dim i As Long should work. That is no longer true in .NET. And though you had it right, it should be BYVAL (another common mistake)
When I do something like this, I try to be very explicit with my types. Int changes from implementation to implementation, platform to platform.
Utilice la herramienta
signed long, or the equivalent type in VB
Int32 everywhere, instead of int or integer. That will save you lots of pain.
There's also something to be said for being explicit about your types for documentation purposes. I have had tons of problems trying to get a DLL from a vendor with bad documentation working. Something as simple as saying Int64, or unsigned short will go a long way to informing someone trying to interface with your DLL how it is to be dealt with.
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c++ vb6 or haz tu propia pregunta.
haha, I should have tried this before asking.. that worked :D thanks.. also thanks for the edit (I always butch the formatting lol). Should I change the byval table as integer and col as integer to longs too? it seems to work with them as integers but I dont understand why - user1088794