English 中文(简体)
是否安全使用电梯接口
原标题:Is it safe to use interfaces from dll

When I want to export a class within a DLL, is it the right approach to derive it from an interface and return that interface by an exported function?

//exported dll function, which is used in the exe.
function MyClass_Create: IMyClass;
begin
  result := TMyClass.Create;
end;

记忆管理是什么? Can 我不是穿过/穿过不同的接口和铺设,没有麻烦和坠机?

IMyClass = interface
  procedure SetString(aMsg: string);
  function GetString: string;

  procedure SetClass(aClass: ITestClass);
  function GetClass: ITestClass;
end;
最佳回答

采用这种接口将确保安装接口的物体在相同的坡度上形成和释放。

However, this will not solve the problem of dynamic string types being allocated and deallocated on different heaps. There are many possible solutions to this, but in my view the best approach is to use WideString across the module boundary.

广域的类型围绕COM BSTR进行包装,并分配给共同的COM惠普。 你们只需要广泛使用接口。 执行班的内部可以使用本土的德尔菲斯特。

正如存在问题一样,充满活力的阵列也是如此。 试图跨越模块边界使用有活力的阵列是不安全的。 不存在像方便的解决办法。 你们可以使用变量阵列,但与广域相比,这种阵列非常高。

问题回答

内部参考资料是传记管理的基本参考资料。 通常,你出口一种功能,即从干.中回收,不关心记忆管理。 在参考计数接口中,你可以确保安装接口的标的也会在批次中释放。

力量不同。 无论出口接口还是出口固定功能,都适用同样的限制。

BTW 贵问题的标题不正确,Delphi没有接口。





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签