调用DLL中的API没有什么问题,在执行到运行错误时中断程序,看看产生错误的语句在哪里。

解决方案 »

  1.   

    using System.Runtime.InteropServices;
    [DllImport("dmawin.dll", EntryPoint="aaApi_AdminLoginDlg")]
      

  2.   

    还是有同样问题,以下是C++的头文件,请各个看看,定义是否有问题.C++头文件:AANATIVE LONG AAAPI aaApi_LoginDlg
    (
       LONG    lDSType,             /* i  datasource type               */
       LPTSTR  lptstrDataSource,    /* io datasource name               */
       LONG    lDSLength,           /* i  length of lptstrDataSource    */
       LPCTSTR lpctstrUsername,     /* i  user name                     */
       LPCTSTR lpctstrPassword,     /* i  password                      */
       LPCTSTR lpctstrSchema        /* i  schema                        */
    );
      

  3.   

    问题应该在字符集的设定上,我也遇到同样的问题
    http://expert.csdn.net/Expert/topic/2296/2296395.xml?temp=.2334558
      

  4.   

    调用时改为:
    string spaceStr="";
    Win32.aaApi_AdminLoginDlg (1, spaceStr, 256, spaceStr,spaceStr);试试
      

  5.   

    string spaceStr="";
    Win32.aaApi_AdminLoginDlg (1, spaceStr, 256, spaceStr,spaceStr);试过了还是有问题啊请问:  lornwolf80(孤独的狼) 你的问题解决了吗? 你是如何解决的?
      

  6.   

    谢谢lornwolf80(孤独的狼) 的提示, 按如下方式定义就解决了.[DllImport("dmawin.dll",EntryPoint="aaApi_AdminLoginDlg",CharSet=CharSet.Auto,CallingConvention=CallingConvention.ThisCall )]
      

  7.   

    谢谢,我的问题也已经解决,"ThisCall第一个参数是 this 指针,它存储在寄存器 ECX 中。其他参数被推送到堆栈上。此调用约定用于对从非托管 DLL 导出的类调用方法。"
    这句不太明白,能否解释一下