DLL calling...
VBBRIf I'm calling an external function from a DLL, where one of its arguments in C is defined as "const char *variable", how should I pass the string? ByVal or ByRef? Should I append a Chr(0) at the end of the string?
Sr. GuapoI'm not sure if you can pass a constant, seems like that wouldn't work... Also, I don't *think* you can pass an actual "pointer" from VB, but you can pass a reference. They are similar, and I don't know what's different. If you can't tell, my C++ skills are severly lacking, sorry I couldn't be of more help.
Eric ColemanIs it a double byte character function or a single byte? For a single byte function, you would declare it as (ByVal Data As Long) and then to call the funtion.. Dim S as String: S = "hello" Call MyFunction(StrPtr(StrConv(S, vbFromUnicode))) For a double byte string, you would decalre the function the same way. (ByVal Data As Long) but when calling the function it would look like Dim S as String: S = "hello" Call MyFunction(StrPtr(S))
Eric ColemanYou can also decalre the function as ByRef Data As Any instead of ByVal Data As Long. To call the function when decalared as ByRef Data As Any, you use the following syntax for Single and Double byte systems. For single byte characters Dim S as string: s = "hello" Dim bytArray() as Byte bytArray = StrConv(S & Chr$(0), vbFromUnicode) Call MyFunction ( bytArray(0) ) For Double byte characters. Dim S as string: s = "hello" Dim bytArray() as Byte bytArray = S & Chr$(0) Call MyFunction ( bytArray(0) )