public aaa(IntPtr myPtr,int left, int top, int width, short height)

这里myPtr应该是对应到一块内存,你需要查看aaa函数是如何把myPtr转化成它内部要使用的结构体的(一般都是结构体,也可能是其它对象,比如数组)。

然后,你需要在你的托管代码中,定义该结构体,使用StructLayout特性,对结构体的字段使用MarshalAs特性,类似这样:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Size = 13)]
public struct A101220Output
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
public string TransactionAccountID; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]
public string IsAuthenticated;
}

然后在需要使用的地方,获取该结构体对象的IntPtr,如下:
//创建托管对象
A101220Output output = new A101220Output ();
output.TransactionAccountID = "11000000841";
output.IsAutienticated = "false"; //分配非托管内存,并获取非托管内存地址起始位置指针
int size = Marshal.SizeOf(output);
IntPtr buffer = Marshal.AllocHGlobal(size); try
{
//将托管对象拷贝到非托管内存
Marshal.StructureToPtr(output, buffer, false); //调用非托管方法
aaa.(buffer,0,0,640,480);
}
finaly
{
//释放非托管内存
Marshal.FreeHGlobal(buffer);
}

IntPtr问题的更多相关文章

  1. C# byte[]、struct、intptr等的相互转换

    1.struct byte[]互相转换 //struct转换为byte[] public static byte[] StructToBytes(object structObj) { int siz ...

  2. 为什么C#中要设计IntPtr?

    示例代码: IntPtr vertex = someObj.Get().Lock(0, someObj.Get().GetSizeInBytes(), HardwareBuffer.LOCKOPTIO ...

  3. C# IntPtr转换为Byte[]

    [DllImport("OpenNetStream.dll")] public static extern int OpenSDK_Data_GetDevList(IntPtr s ...

  4. CloseHandle(IntPtr handle)抛异常

    [DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static ext ...

  5. EmguCV 如何从数组中创建出IntPtr

    需要添加引用:System.Runtime.InteropServices 举例如下: float[] priors={1,10}; IntPtr intPtrSet = new IntPtr(); ...

  6. C#中的IntPtr类型

    本文转自:http://zhidao.baidu.com/question/22825956.html 问: c#中无法将类型“int”隐式转换为“System.IntPtr” 这个是我引用了一个ap ...

  7. 任意类型转换为IntPtr

    之前,将数组.结构体等转换为IntPtr使用的是Marshal.Copy().Marshal.StructureToPtr(),但是有个问题自定义的结构体数组没法这样转化,一般网上给出的解决方法就是通 ...

  8. (转)C#进行图像处理的几种方法(Bitmap,BitmapData,IntPtr)

    转自 http://blog.sina.com.cn/s/blog_628821950100wh9w.html C#进行图像处理的几种方法 本文讨论了C#图像处理中Bitmap类.BitmapData ...

  9. c# 读取IntPtr 中的数据 z

    c++的写法是这样的: LRESULT CPictureQueryDlg::OnQueryPicNty(WPARAM wp, LPARAM lp) { EnableWindow(TRUE); BYTE ...

  10. [转载]C#中int和IntPtr相互转换

    方法一. int转IntPtr int i = 12;           IntPtr p = new IntPtr(i); IntPtr转int int myi = (int)p;         ...

随机推荐

  1. EntityFramework1

    1.ORM都是Select * ,即使不需要某些字段,也要查询出来,效率是否很低. 可以使用视图来解决,比如对于列表页,可以定义一个视图,只查询列表中需要使用的字段,然后将列表映射为实体 2.ORM中 ...

  2. iOS9基础知识(OC)笔记

    1月16日 Objective  C(20世纪80年代初) 一.OC语言概述 1.1985年,Steve  Jobs成立了NeXT公司 2.1996年,12月20日,苹果公司宣布收购了NeXT  ...

  3. iOS中的下载管理器(支持断点续传)

    在空闲时间自己编写了一个简单的iOS下载管理器.该管理器实现如下功能: 1.能够支持正常的下载,暂停,继续操作. 2.支持断点续传,实现暂停执行继续操作后,依然能正常将文件下载完成. 3.实现实时状态 ...

  4. 开发网站相关知识html和javascript

    1.html 布局 https://github.com/bramstein/jlayout/ http://welcome.totheinter.net/columnizer-jquery-plug ...

  5. 从汇编看c++中成员函数指针(一)

    下面先来看c++的源码: #include <cstdio> using namespace std; class X { public: int get1() { ; } virtual ...

  6. WebService使用的一些总结

    什么是WebService: 这个不用我在这里废话,网上的资料一搜一大把,如果你没有接触过这方面的知识,你可以先去网上查一下.这里我只想说一下我印象比较深刻的几点: WebService是基于soap ...

  7. Apriori algorithm

    本文是个人对spmf中example1. mining frequent itemsets by  using the apriori algorithm的学习. What is Apriori? A ...

  8. Nutch配置

    http://www.linuxidc.com/Linux/2011-12/48782.htm http://wiki.apache.org/nutch/NutchHadoopTutorial htt ...

  9. SQL Server中各个系统表的作用

    sysaltfiles            主数据库               保存数据库的文件 syscharsets         主数据库               字符集与排序顺序 s ...

  10. Linux进程间通信——使用信号

    一.什么是信号 用过Windows的我们都知道,当我们无法正常结束一个程序时,可以用任务管理器强制结束这个进程,但这其实是怎么实现的呢?同样的功能在Linux上是通过生成信号和捕获信号来实现的,运行中 ...