小编Sor*_*6pt的帖子

P /通过错位名称调用函数

我试图在windows ce 6.0环境中调用.net cf 3.5中的非托管c ++ dll中的函数.

结构定义为:

typedef struct TagOperatorInfo
{
    DWORD dwMode;       
    DWORD dwFormat;     //Operator name format
    DWORD dwAct;        //Network type(Available in 3G module£ºGSM or 3G),
    TCHAR szOper[32];   
}OperatorInfo,*LPOperatorInfo;
Run Code Online (Sandbox Code Playgroud)

和函数调用是:

BOOL GetCurOperatorInfo(LPOperatorInfo pinfo);
Run Code Online (Sandbox Code Playgroud)

我在.net中定义了TagOperatorInfo,如下所示:

[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
    public struct TagOperatorInfo
    {

        /// DWORD->unsigned int
        public uint dwMode;

        /// DWORD->unsigned int
        public uint dwFormat;

        /// DWORD->unsigned int
        public uint dwAct;

        /// TCHAR[32]
        [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 32)]
        public string szOper;
    }
Run Code Online (Sandbox Code Playgroud)

在看到一些文章和msdn文档后,我将本机函数称为:

[System.Runtime.InteropServices.DllImportAttribute(gsmaAdapterDLLName, EntryPoint = "#30", CallingConvention = CallingConvention.Winapi)] …
Run Code Online (Sandbox Code Playgroud)

c# pinvoke compact-framework

2
推荐指数
1
解决办法
2527
查看次数

标签 统计

c# ×1

compact-framework ×1

pinvoke ×1