.net 如何在delphi prism中导入DLL?
我试图在我的delphi prism程序中导入dll,但以前从未这样做过。所以,在网上找到一些答案后,我把一些东西放在一起,如下所示,但不起作用.net 如何在delphi prism中导入DLL?,.net,dllimport,delphi-prism,oxygene,.net,Dllimport,Delphi Prism,Oxygene,我试图在我的delphi prism程序中导入dll,但以前从未这样做过。所以,在网上找到一些答案后,我把一些东西放在一起,如下所示,但不起作用 MyUtils = public static class private [DllImport("winmm.dll", CharSet := CharSet.Auto)] method timeBeginPeriod(period:Integer):Integer; external; protected publi
MyUtils = public static class
private
[DllImport("winmm.dll", CharSet := CharSet.Auto)]
method timeBeginPeriod(period:Integer):Integer; external;
protected
public
constructor;
end;
以下是我如何使用它:
var tt := new MyUtils;
tt.timeBeginPeriod(1);
当我运行我的程序时,我不断得到以下错误
- “MyUtils”不提供可访问的构造函数。
- “System.Object”在表达式中不包含“timeBeginPeriod”的定义 “tt.timeBeginPeriod。”
MyUtils = public static class
private
[DllImport("winmm.dll", CharSet := CharSet.Auto)]
method timeBeginPeriod(period:Integer):Integer; external;
protected
public
end;
如果从声明的单元外部调用timeBeginPeriod
函数,则需要将其可见性更改为public
您也不需要创建实例来调用函数:
MyUtils.timeBeginPeriod(1);
我用一个声明并使用
SendMessage
的应用程序测试了这一点,因此我可以轻松地检查以确保它实际工作(我向同一表单上的编辑控件发送了一条EM_SETTEXT
消息)。Ck。非常感谢。我确实改变了你的答案,而且很有效。现在,我有一个问题。我可以把这个程序和winmm.dll一起在Linux上的mono下运行吗?它会像预期的那样工作吗?
MyUtils = public static class
public
[DllImport("winmm.dll", CharSet := CharSet.Auto)]
class method timeBeginPeriod(period:Integer):Integer; external;
end;
MyUtils.timeBeginPeriod(1);