简体   繁体   English

delphi使用指定的入口点导入dll函数

[英]delphi Import dll function with specified entry point

How can I define this function in Delphi ? 如何在Delphi中定义此功能? I know imports only without entry point and can't find any usefull example :( 我知道只有没有入口点的进口,并且找不到任何有用的例子:(

That's written in C# 这是用C#编写的

[DllImport("dwmapi.dll", EntryPoint = "#131")]
static extern int DwmpSetColorizationParameters(ref DwmColorParams dcpParams, 
bool alwaysTrue);

Thanks a lot 非常感谢

Best regards 最好的祝福

This should do, although I'm not sure about the const for alwaysTrue . 这应该做,虽然我不确定alwaysTrueconst

function DwmpSetColorizationParameters(var dcpParams: TDwmColorParams; 
  alwaysTrue: BOOL): Integer; stdcall; 
  external 'dwmapi.dll' index 131;

The EntryPoint field allows the function to be declared with a name other than what the DLL used to export it. EntryPoint字段允许使用除用于导出DLL的名称之外的名称声明函数。 If the first character of the value is # , then it indicates the ordinal value of the function instead of the DLL's name for it. 如果值的第一个字符是# ,则它表示函数的序数值而不是DLL的名称。

Delphi uses two different clauses. Delphi使用两个不同的子句。 If the DLL uses a name different from the one in your code, then you can use a name clause: 如果DLL使用的名称与代码中的名称不同,则可以使用name子句:

procedure Foo(...); external DLL name 'Bar';

But if the DLL doesn't export any name at all, then you can use an index clause to tell which ordinal value the function has: 但是如果DLL根本没有导出任何名称,那么你可以使用index子句来告诉函数具有哪个序数值:

procedure Foo(...); external DLL index 131;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM