Hello everyone. Thanks in advance for your advice.
I'm building a web service that needs to access a DLL that was written in C++. I saw somewhere that the way to access a specific function from a DLL is to declare it thusly:
This seems to work in terms of allowing the program to recognize the function. However, when I call this function (or any other function from the DLL that returns a string), I'm only getting the first character of what should be returned.
For example, if the function is supposed to return "Numer of Matches: 90" it returns "N" instead. I have a feeling this has to do with two thngs -- that the DLL was written with VB 6.0 in mind and also it was written in C++, so I have to do some sort of conversion. Functions that return an integer are also not returning the right number by a factor of 4 billion.
The example code that was given to me actually does do a conversion, but it is a conversion that was deprecated from VB 6.0 to VB.NET. I found the way to do it in VB.NET and it still doesn't work.
Just for reference, here's what I changed for that conversion:
goes to:
Does anyone have an idea of what I can do?
I'm using ASP.NET Web Matrix to program this Web Service.
Thanks.
I'm building a web service that needs to access a DLL that was written in C++. I saw somewhere that the way to access a specific function from a DLL is to declare it thusly:
Code:
Public Declare Function GetResultsTextBSTR Lib "BridgerTracker.dll"
(ByVal iFormat As enumBridgerTrackerFormat) As String
This seems to work in terms of allowing the program to recognize the function. However, when I call this function (or any other function from the DLL that returns a string), I'm only getting the first character of what should be returned.
For example, if the function is supposed to return "Numer of Matches: 90" it returns "N" instead. I have a feeling this has to do with two thngs -- that the DLL was written with VB 6.0 in mind and also it was written in C++, so I have to do some sort of conversion. Functions that return an integer are also not returning the right number by a factor of 4 billion.
The example code that was given to me actually does do a conversion, but it is a conversion that was deprecated from VB 6.0 to VB.NET. I found the way to do it in VB.NET and it still doesn't work.
Just for reference, here's what I changed for that conversion:
Code:
StrConv(GetLastErrorMessageBSTR(), vbFromUnicode)
goes to:
Code:
Dim s As String
Dim b() As Byte
b = System.Text.UnicodeEncoding.Unicode.GetBytes(GetLastErrorMessageBSTR())
s = System.Text.ASCIIEncoding.ASCII.GetString(b)
Does anyone have an idea of what I can do?
I'm using ASP.NET Web Matrix to program this Web Service.
Thanks.