当前位置: 代码迷 >> PB >> DELPI7编写的动态库,在PB中怎么声明
  详细解决方案

DELPI7编写的动态库,在PB中怎么声明

热度:130   发布时间:2016-04-29 09:28:00.0
DELPI7编写的动态库,在PB中如何声明
DELPI7中 test.dll中的函数如下:
  function gf_jmword(as_string: ShortString): wideString; stdcall;
  functiongf_word(ac_word: pchar; ac_ts: integer): wideString; stdcall;


上边两个函数想在PB中调用,在PB中如何声明这连个函数,请各位指教。




------解决方案--------------------
看不懂你的类型.

你下个PB的API大全,看看就知道了.




API调用规范及方法













(独孤求败二零零四年一月二十六日整理于深圳市南山区)



外部函数就是用其他语言编写并储存在动态链接库里面的函数。这些动态链接库可以存放多个外部函数,外部函数可以是用VC++、Delphi等其他编程语言编写的。但是无论用什么语言编写,它都要符合基本的原则,就是必须用Pascal(16位)或标准(32位)调用规则编写,否则在PB中将无法调用。
PB中调用外部函数的语法是:
{access} FUNCTION returndatatype FunctionName ( { { REF} datatype1 arg1, …, {REF} datatypen argn}) LIBRARY “libname” ALLAS FOR “extname”
或:{access} SUBROUTINE SubroutineName ( { {REF} datatype1 arg1, … ,{REF} datatypen argn }) 
LIBRARY “libname” ALLAS FOR “extname”
由于编写语言的不同,所以肯定会有数据类型不匹配的问题,下表列出了C++和PB数据类型的转换对应关系:
C++数据类型 PB数据类型
Byte,Char Char
Bool Boolean
Char Blob
Char* String Ref
Double Double
Dword Ulong
Float Real
Handle Uint
Hwnd Ulong
Int Integer
Long Long
Lpbyte String Ref
Lpdword Ulong
Lpint Integer
Lplong Long
Lpstr String Ref
Lpviod String
Lpword Uint
Ulong/unsigned long Ulong
Unsigned int/Unsigned Short/Word Uint


------解决方案--------------------
拷贝一些调用方法,你参考:
FUNCTION ulong AbortDoc(ulong hdc) LIBRARY "gdi32.dll"
FUNCTION ulong AbortPath(ulong hdc) LIBRARY "gdi32.dll"
FUNCTION ulong AbortPrinter(ulong hPrinter) LIBRARY "winspool.drv"
FUNCTION ulong AbortSystemShutdown(ref string lpMachineName) LIBRARY "advapi32.dll" ALIAS FOR "AbortSystemShutdownA"
FUNCTION ulong AccessCheck(ref SECURITY_DESCRIPTOR pSecurityDescriptor,ulong ClientToken,ulong DesiredAccess,ref GENERIC_MAPPING GenericMapping,ref PRIVILEGE_SET PrivilegeSet,ref ulong PrivilegeSetLength,ref ulong GrantedAccess,ulong Status) LIBRARY "advapi32.dll"
FUNCTION ulong AccessCheckAndAuditAlarm(ref string SubsystemName,ref Any HandleId,ref string ObjectTypeName,ref string ObjectName,ref SECURITY_DESCRIPTOR SecurityDescriptor,ulong DesiredAccess,ref GENERIC_MAPPING GenericMapping,ulong ObjectCreation,ref ulong GrantedAccess,ulong AccessStatus,ulong pfGenerateOnClose) LIBRARY "advapi32.dll" ALIAS FOR "AccessCheckAndAuditAlarmA"
FUNCTION ulong ActivateKeyboardLayout(ulong HKL,ulong flags) LIBRARY "user32.dll"
FUNCTION ulong AddAccessAllowedAce(ref ACL pAcl,ulong dwAceRevision,ulong AccessMask,ref Any pSid) LIBRARY "advapi32.dll"
FUNCTION ulong AddAccessDeniedAce(ref ACL pAcl,ulong dwAceRevision,ulong AccessMask,ref Any pSid) LIBRARY "advapi32.dll"
FUNCTION ulong AddAce(ref ACL pAcl,ulong dwAceRevision,ulong dwStartingAceIndex,ref Any pAceList,ulong nAceListLength) LIBRARY "advapi32.dll"
FUNCTION Integer AddAtom(ref string lpString) LIBRARY "kernel32.dll" ALIAS FOR "AddAtomA"
FUNCTION ulong AddAuditAccessAce(ref ACL pAcl,ulong dwAceRevision,ulong dwAccessMask,ref Any pSid,ulong bAuditSuccess,ulong bAuditFailure) LIBRARY "advapi32.dll"
FUNCTION ulong AddFontResource(ref string lpFileName) LIBRARY "gdi32.dll" ALIAS FOR "AddFontResourceA"
FUNCTION ulong AddForm(ulong hPrinter,ulong Level,ref Byte pForm) LIBRARY "winspool.drv" ALIAS FOR "AddFormA"
FUNCTION ulong AddJob(ulong hPrinter,ulong Level,ref Byte pData,ulong cdBuf,ref ulong pcbNeeded) LIBRARY "winspool.drv" ALIAS FOR "AddJobA"
FUNCTION ulong AddMonitor(ref string pName,ulong Level,ref Byte pMonitors) LIBRARY "winspool.drv" ALIAS FOR "AddMonitorA"
  相关解决方案