谁能告诉我在哪里可以找到如何为.NET在Oxygene中制作动态链接库(WindowsControlLibrary)的示例?
在旧的Delphi中,您创建了一个导出部分。
发布于 2009-10-29 08:13:31
要使用Delphi Prism创建非托管DLL导出并使用Delphi 2010调用它,您必须执行以下操作:
在Delphi Prism中:
按OK。
这将为Windows类库创建模板
在项目"ClassLibraryX“上单击鼠标右键,然后选择属性:
这将设置项目以支持UnmanagedExportAttribute。
然后,您需要在代码中创建一个类方法。在下面的示例中,我添加了对System.Windows.Forms的引用。
namespace ClassLibrary2;
interface
type
Class1 = public class
private
protected
public
[UnmanagedExport('ShowMessage')]
class method ShowMessage(aMsg : String);
end;
implementation
class method Class1.ShowMessage(aMsg : String);
begin
System.Windows.Forms.MessageBox.Show(aMsg);
end;
end.使用JCL中附带的PEViewer作为示例,您应该能够看到新的导出。在上面的示例中,"ShowMessage“
发布于 2010-08-14 02:50:06
如果你想让它与delphi兼容,那么你必须指定一个"stdcall“调用约定
命名空间ClassLibrary2;
接口
类型Class1 =公共类
私有
受保护
公共的
System.Runtime.InteropServices.CallingConvention.StdCall,UnmanagedExport('ShowMessage')
类方法ShowMessage(aMsg : String);end;
实现
类方法Class1.ShowMessage(aMsg : String);
开始
System.Windows.Forms.MessageBox.Show(aMsg);
结束;
结束。
https://stackoverflow.com/questions/1637643
复制相似问题