1

I have a vc++ dll which has a funciton call like this :

 typedef void * SIS_HANDLE;
 EXTERN_C SDK4OpenDevice (SIS_HANDLE* sDev );

Now am trying to call the VC++ dll in VB6 is there any equivalent for the same in VB6.

Thanks

1 Answer 1

4

Yes, it's a pointer-sized integer, which is Long in VB6. And your function takes a pointer to a pointer, so it will be ByRef.

Declare Sub SDK4OpenDevice(ByRef sDev As Long);

Watch out for the calling convention though, if that EXTERN_C macro doesn't hide a __stdcall or __pascal keyword, the function can't be called from VB6 directly.

4
  • Thanks ben, One more query if you dont mind What if my VC++ code returns the pointer like this : SIS_HANDLE WINAPI SDK4OpenDevice (const char *portName,int baud,int parity,int receiveTotalTimeout); how should i cast the same in VB6
    – Suave Nti
    Jun 25, 2012 at 13:24
  • 1
    It depends what SIS_HANDLE is. If it's a 32-bit then Long again is your best option. VB6 is strongly typed but not as widely as C++.
    – Deanna
    Jun 25, 2012 at 13:42
  • 1
    @Deanna: The question tells us what SIS_HANDLE is -- a pointer, and all VB6 programs are 32-bit, so a pointer is always the same size as VB6 Long.
    – Ben Voigt
    Jun 25, 2012 at 14:32
  • Sorry, I missed that the type itself was a pointer rather than just the parameter.
    – Deanna
    Jun 25, 2012 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.