动态调用Dll是会出现一些问题,我还取不到dll中的全局变量呢

解决方案 »

  1.   

    改成Int类型:
    [DllImport("DSStream.dll", EntryPoint = "DSStream_SetOwnerWnd")]
    public static extern Int32 DSStream_SetOwnerWnd(int iCardID, int hParentWnd);在C#中调用DSStream_SetOwnerWnd(0,this.Handle.ToInt32());
      

  2.   

    HANDLE(void *) System.IntPtr
    Byte(unsigned char) System.Byte
    SHORT(short) System.Int16
    WORD(unsigned short) System.UInt16
    INT(int)          System.Int16 →  System.Int32
    UINT(unsigned int) System.UInt16 → System.UInt32
    LONG(long) System.Int32
    ULONG(unsigned long) System.UInt32
    DWORD(unsigned long) System.UInt32
    DECIMAL          System.Decimal
    BOOL(long) System.Boolean
    CHAR(char) System.Char
    LPSTR(char *) System.String
    LPWSTR(wchar_t *) System.String
    LPCSTR(const char *) System.String
    LPCWSTR(const wchar_t *) System.String
    PCAHR(char *) System.String
    BSTR          System.String
    FLOAT(float) System.Single
    DOUBLE(double) System.Double
    VARIANT          System.Object
    PBYTE(byte *) System.Byte[]
    这是我做的一个项目中定义的不知道能不能帮上忙!!!
      

  3.   

    TO   hamehameha(天刑者) ( ) 信誉:100 
    //---------------------------------------------
    很感谢你贴出这么多类型对应关系!
    请问 c++中 bool * 对应C#什么类型?
      

  4.   

    owennol(好好学习,天天向上) ( ) 信誉:97  2007-08-07 09:56:25  得分: 0 
     
       改成Int类型:
    [DllImport("DSStream.dll", EntryPoint = "DSStream_SetOwnerWnd")]
    public static extern Int32 DSStream_SetOwnerWnd(int iCardID, int hParentWnd);在C#中调用DSStream_SetOwnerWnd(0,this.Handle.ToInt32());
    、、-----------------------------------------------------------
    此方法已试用还是不行!急啊!!高人在哪?
      
     
      

  5.   

    句柄直接用int 使用IntPtr  也行
    不过我一般用int
      

  6.   

    看看directx的版本,装个最新的
      

  7.   

    平台调用是很麻烦的。
    最好的做法是采用c++混合编程,将本地代码集中到DLL中,而在托管代码中也可以很方便的引用DLL,直接调用里面的函数。
      

  8.   

    [DllImport("DSStream.dll", EntryPoint = "DSStream_SetOwnerWnd",CharSet=CharSet.Ansi)]
    public static extern Int32 DSStream_SetOwnerWnd(int iCardID, int hParentWnd);
    看看这样可以吗?HWND 转换成IntPtr是对的
    如果还有问题,那么用Marshal.sizeof()比对下参数的长度是否一致,好运!