Delphi: Access type defined in dll for use as return type
I am writing a DLL with one function in it. This functions return value is a datatype defined in code within the DLL. On the applications side where I reference the function as an external c开发者_高级运维all to a DLL
Function CreateMyObject( MyString : String ) : TReturnType; external 'MyDLL.dll'
How do I get access from the DLL to the TReturn type so the application will know what type it is supposed to be.
Thank you
You should define TReturnType in a separate unit and use the unit both in application and dll, ex:
unit SharedUnit;
interface
type
TReturnType = ...
implementation
end.
In Dll:
library MyDll;
uses
SharedUnit;
function MyFunc: TReturnType;
begin
// ...
end;
exports MyFunc;
{$R *.res}
begin
end.
精彩评论