博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pinvoke 数据交互笔记
阅读量:7230 次
发布时间:2019-06-29

本文共 991 字,大约阅读时间需要 3 分钟。

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

}

}

 

转载于:https://www.cnblogs.com/Noproblem/p/3232135.html

你可能感兴趣的文章
SDUT 2012春季ACM内部测试赛4's
查看>>
Node入门教程(10)第八章:Node 的事件处理
查看>>
组策略应用之一:映射网络驱动器
查看>>
程序复杂度之圈复杂度
查看>>
【入门须知】学DIV CSS技术如何入门?学DIV CSS技术入门
查看>>
flask 中从eml中获取头邮件头信息
查看>>
laravel上传文件&获取请求实例(隐式)
查看>>
适配低内存手机让app存在多个进程
查看>>
BW中DSO的分类
查看>>
echo -en
查看>>
Mysql 复制(Replication)实现
查看>>
我的友情链接
查看>>
jar生成exe可执行的程序
查看>>
date 转化为 指定格式的String
查看>>
使用virtualbox安装RHEL 6.2+Oracle 11g
查看>>
系统的域名服务
查看>>
MySQL 复制表结构
查看>>
《Effective C#》条款8:确保0为值类型的有效状态
查看>>
动态迁移应用服务器(Esxi 动态迁移技术,业务不间断,在线迁移)
查看>>
systemd coding style
查看>>