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

    }

    }

  • 相关阅读:
    前端事件系统(四)
    前端事件系统(三)
    前端事件系统(二)
    前端事件系统(一)
    前端图片选择问题
    浅谈前端移动端页面开发(布局篇)
    诙谐论设计模式(一)——创建型设计模式
    总结三年未满的工作经历,写下自己对技术的坚持
    java内存优化牛刀小试
    将上下文融入知识图谱以进行常识推理
  • 原文地址:https://www.cnblogs.com/Noproblem/p/3232135.html
Copyright © 2011-2022 走看看