开发者

Delphi: Access type defined in dll for use as return type

开发者 https://www.devze.com 2023-01-11 22:55 出处:网络
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开发者_高级

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.
0

精彩评论

暂无评论...
验证码 换一张
取 消