COM导入到C#开发 HWND句柄类型 对应于C#的 _RemotableHandle结构处理
2009-11-26 01:19
417 查看
函数原型: ShowMessage(HWND hwnd,uint msg,int wp,int lp)
COM导入进C#: ShowMessage(_RemotableHandle hwnd,uint msg,int wp,int lp)
导入COM之后 在C++中调用直接用HWND句柄类型,而在C#中,类型为_RemotableHandle,此为一个结构:
public struct _RemotableHandle
{
public int fContext;
public __MIDL_IWinTypes_0009 u;
}
public struct __MIDL_IWinTypes_0009
{
public int hInproc;
public int hRemote;
}
那么C#中的窗口句柄IntPtr是不能as到_RemotableHandle结构,也不能强制类型转换. 尝试Marshal.PtrToStructure 仍然失败.最后采用以下方法成功:
unsafe
{
RemotableHandle* rh = (_RemotableHandle*)this.Handle.ToPointer();
ShowMessage(ref *rh, 0x1000, 0, 0);
}
COM导入进C#: ShowMessage(_RemotableHandle hwnd,uint msg,int wp,int lp)
导入COM之后 在C++中调用直接用HWND句柄类型,而在C#中,类型为_RemotableHandle,此为一个结构:
public struct _RemotableHandle
{
public int fContext;
public __MIDL_IWinTypes_0009 u;
}
public struct __MIDL_IWinTypes_0009
{
public int hInproc;
public int hRemote;
}
那么C#中的窗口句柄IntPtr是不能as到_RemotableHandle结构,也不能强制类型转换. 尝试Marshal.PtrToStructure 仍然失败.最后采用以下方法成功:
unsafe
{
RemotableHandle* rh = (_RemotableHandle*)this.Handle.ToPointer();
ShowMessage(ref *rh, 0x1000, 0, 0);
}
相关文章推荐
- 近期.NET学习及项目开发整理-SQLSERVER中的数据类型和C#中数据类型的对应
- [C#]Winform开发框架中实现同时兼容多种数据库类型处理
- C++数据类型和C#的部分对应关系 API与C#数据结构类型对应关系表
- C#引用C++开发的DLL的类型对应及注意事项
- 近期.NET学习及项目开发整理-SQLSERVER中的数据类型和C#中数据类型的对应
- C++ 和 C# 开发类型对应信息
- 功能齐全、效率一流的免费开源数据库导入导出工具(c#开发,支持SQL server、SQLite、ACCESS三种数据库),每月借此处理数据5G以上
- 使用C#在VS中开发:未处理AccessViolationException “System.AccessViolationException”类型的未经处理的异常
- Sql2012如何将远程服务器数据库及表、表结构、表数据导入本地数据库 自定义日志记录功能,按日记录,很方便 C#常量和字段以及各种方法的语法总结 类型,对象,线程栈,托管堆在运行时的关系,以及clr如何调用静态方法,实例方法,和虚方法 asp.net webapi 自定义身份验证
- C#excel数据导入DataGridView第一行数据变成标题处理方法
- C++数据类型与C#对应关系
- SQL Server数据库中导入导出数据及结构时主外键关系的处理
- 基于Metronic的Bootstrap开发框架经验总结(7)--数据的导入、导出及附件的查看处理
- 对于c#中的数据类型对应得.netfrmwork
- WindowsAPI对应C#的数据类型
- C# 多线程处理相关说明: WaitHandle,waitCallback, ThreadPool.QueueUserWorkItem
- SQL2005中的字段类型对应C#的变量类型
- c#的结构类型也可以有构造函数
- SQL SERVER与C#中数据类型的对应关系
- 实用开发一:c#封装好的处理图片的水印和生成缩略图的类