zoukankan      html  css  js  c++  java
  • pinvoke 数据交互笔记

    intptr to array string

    string[]  _outputStrArray=null;

         int channelCount = 0;///返回数组大小
                IntPtr Channels = new IntPtr();
              
                int reslut = NativeMethods.getChannels(Global.Handle, nru, ref Channels, ref channelCount);
                if (reslut == 0) //将指针数据转换为string 数组
                {
                    IntPtr[] OutPointers = new IntPtr[channelCount];
                    Marshal.Copy(Channels, OutPointers, 0, channelCount);
                    _outputStrArray = new string[channelCount];
                    for (int i = 0; i < channelCount; i++)
                    {
                        _outputStrArray[i] = Marshal.PtrToStringAnsi(OutPointers[i]);
                    }
                }

    结构体数组指针

    定义结构体

     public struct out_TMitObjIdKVPair
        {

    ...

    ...

    ..

    }

    IntPtr timitobjs = new IntPtr();

     int count = 0;

     int result = NativeMethods.getSubObjs(Global.Handle, par, ref timitobjs, ref count);
                if (result == 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        out_TMitObjIdKVPair q = (out_TMitObjIdKVPair)Marshal.PtrToStructure((IntPtr)(timitobjs.ToInt32() + i * Marshal.SizeOf(typeof(out_TMitObjIdKVPair))), typeof(out_TMitObjIdKVPair));

    }

    }

  • 相关阅读:
    JQuery框架中使用blockUI制作自定义的漂亮的网页提示框
    PHP树形菜单一次展开一个子项目,可以记录打开的项目,刷新后不变
    第一次面试
    东软的校园招聘笔试
    fscommand
    从 ActionScript 中调用外部代码
    GCC 参数详解
    flash build找不到调试版plashplayer的解决办法
    C# winform与 flash as 的交互通讯
    LLVM 与 Clang 介绍
  • 原文地址:https://www.cnblogs.com/Noproblem/p/3232135.html
Copyright © 2011-2022 走看看