从C中的外部DLL声明接口的常用方法是在.H头文件中公开其接口。然后,要从C访问DLL,.H头文件在C源代码中必须是#include
d。
翻译为Delphi术语,您需要创建一个单元文件,以pascal术语描述相同的界面,将c语法翻译为pascal。
对于你的情况,你会创建一个文件,如...
unit xyzDevice;
{ XYZ device Delphi interface unit
translated from xyz.h by xxxxx -- Copyright (c) 2009 xxxxx
Delphi API to libXYZ - The Free XYZ device library --- Copyright (C) 2006 yyyyy }
interface
type
TXyzDeviceType = integer;
const
xyzDll = 'xyz.dll';
XYZ_DEVICE_PCI = 1;
XYZ_DEVICE_USB = 2;
function XyzDeviceStatus (kind : TXyzDeviceType) : integer; stdcall;
external xyzDLL; name 'DeviceStatus';
implementation
end.
而且你的源代码中uses
子句中声明它。并调用该函数是这样的:
uses xyzDevice;
...
case XyzDeviceStatus(XYZ_DEVICE_USB) of ...
如果你想使用它作为一个枚举你必须使用{$ MINENUMSIZE 4}指令 – Remko 2010-04-15 07:43:21