EDN Admin
Well-known member
Hello All,
Ive got some functions I need to call that are in some DLL files that have been written in Delphi 5 in a VB.NET 2005 application. Im able to use the DllImport function to access the functions just fine; however, Im having an issue with the Delphi
string data type and passing it to and from the .NET application.
Take this delphi function for example:
<pre>function AllocateInventory2(ItemNo: string;
Warehouse: string;
Quantity: double): Boolean;
begin
result := AllocateInv(UpperCase(ItemNo), , UpperCase(Warehouse), Quantity);
end;[/code]
It takes two string parameters and one double. I can call this function from VB.NET just fine, but it will error as soon as it tries to use one of the string variables (so in this case, when it passes them to another function) and Ive found that the
string values in Delphi are junk when theyve been passed to .NET. Im guessing that the string objects behave and/or are encoded differently between .NET & Delphi 5, and that I have to apply some sort of Marshaling to the function parameters in
.NET, but Ive tried all of the different types of marshaling and nothing has worked. Unfortunately, I havent been able to find anything about this issue on the internet.
Does anyone know how I can call this Delphi function from .NET and have it pass the string values in a manner so that they wont be corrupted when stored in Delphi?
<br/>
View the full article
Ive got some functions I need to call that are in some DLL files that have been written in Delphi 5 in a VB.NET 2005 application. Im able to use the DllImport function to access the functions just fine; however, Im having an issue with the Delphi
string data type and passing it to and from the .NET application.
Take this delphi function for example:
<pre>function AllocateInventory2(ItemNo: string;
Warehouse: string;
Quantity: double): Boolean;
begin
result := AllocateInv(UpperCase(ItemNo), , UpperCase(Warehouse), Quantity);
end;[/code]
It takes two string parameters and one double. I can call this function from VB.NET just fine, but it will error as soon as it tries to use one of the string variables (so in this case, when it passes them to another function) and Ive found that the
string values in Delphi are junk when theyve been passed to .NET. Im guessing that the string objects behave and/or are encoded differently between .NET & Delphi 5, and that I have to apply some sort of Marshaling to the function parameters in
.NET, but Ive tried all of the different types of marshaling and nothing has worked. Unfortunately, I havent been able to find anything about this issue on the internet.
Does anyone know how I can call this Delphi function from .NET and have it pass the string values in a manner so that they wont be corrupted when stored in Delphi?
<br/>
View the full article