internal static class CAUnmanaged
{
[System.Runtime.InteropServices.DllImport("cryp_api.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Crypt_OpenDevice(ref System.IntPtr handle, string pszContainer, string pszProvider, int dwProvType, int dwFlags);
[System.Runtime.InteropServices.DllImport("cryp_api.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Crypt_CloseDevice(System.IntPtr handle);
[System.Runtime.InteropServices.DllImport("cryp_api.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Crypt_ReadCert(System.IntPtr handle, int dwCertNum, byte[] pbCert, ref int pcbCert);
[System.Runtime.InteropServices.DllImport("cryp_api.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Crypt_EnvelopData(System.IntPtr handle, byte[] pbData, int cbData, int dwEncAlgId, byte[] pbRecipientInfo, int cbRecipientInfo, int dwSignAlgId, ref DATE_TIME signTime, int dwFlags, byte[] pbEnvelopedData, ref int pcbEnvelopedData);
[System.Runtime.InteropServices.DllImport("cryp_api.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Crypt_VerifyEnvelopedData(System.IntPtr handle, byte[] pbEnvelopedData, int cbEnvelopedData, byte[] pbEncedData, int cbEncedData, byte[] pbCert, int cbCert, byte[] pbData, ref int pcbData);
[System.Runtime.InteropServices.DllImport("cryp_api.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Crypt_SignData(System.IntPtr handle, byte[] pbData, int cbData, int dwSignAlgId, ref DATE_TIME signTime, int dwFlags, byte[] pbSignedData, ref int pcbSignedData);
[System.Runtime.InteropServices.DllImport("cryp_api.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Crypt_VerifySignedData(System.IntPtr handle, byte[] pbSignedData, int cbSignedData, int dwFlags, byte[] pbData, int cbData, byte[] pbCert, int cbCert);
}
uj5u.com熱心網友回復:
這有啥好轉的,你按照delphi呼叫dll的方法寫就是了,int就是integer,byte[]就是array of byte或pbyteuj5u.com熱心網友回復:
給一段參考代碼吧:
unit LEDDLL;
interface
uses
windows,Forms;
var
hDll: THandle;
SetScreenParameter: procedure(nScreenNO, nWidth, nHeight, nScreenType: Integer; nMkType, nDataDA, nDataOE: Integer; nDataStyle, nDataSort, nFrequency: Integer; pFileName: pChar); stdcall;
SetScreenState: procedure(nScreenNO: Integer; bScreenState: Integer; pFileName: pChar); stdcall;
procedure LoadDLL;
implementation
procedure LoadDLL;
begin
hDll := LoadLibrary('TsDLL.dll');
if hDll < 32 then
begin
application.MessageBox('無法加載DLL檔案!','錯誤',MB_OK+MB_ICONERROR);
exit; //如果Dll無法加載則跳出
end;
SetScreenParameter := GetProcAddress(hDll, 'SetScreenParameter');
SetScreenState := GetProcAddress(hDll, 'SetScreenState');
end;
end.
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/90377.html
標籤:語言基礎/算法/系統設計
下一篇:找Delphi兼職
