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);
}

解决方案 »

  1.   

    这有啥好转的,你按照delphi调用dll的方法写就是了,int就是integer,byte[]就是array of byte或pbyte
      

  2.   

    给一段参考代码吧:unit LEDDLL;interfaceuses
      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;implementationprocedure 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.