与C#和托管C ++之间的C ++ HWND? [英] C++ HWND to and from C# and Managed C++?

查看:74
本文介绍了与C#和托管C ++之间的C ++ HWND?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#和托管C ++之间传递C ++ HWND?

How can I pass a C++ HWND to and from C# and Managed C++?

推荐答案

好像你可以使用void *:


C#:

MyMethod(this.Handle.ToPointer());


C ++:

public:

void MyMethod(void * handle)

{

HWND l_wnd(句柄);

....

}


然而,这似乎需要unsafe关键字,并且代码是

编译的/ unsafe参数。但是2,我已经找到了关于如何添加这个编译器选项的描述(例如
http://forums.microsoft.com/MSDN/Sho...22815&SiteID=1 )会谈

关于配置属性下的Build子文件夹。我有:一般,

调试,C / C ++,链接器,清单工具,资源,XML文档生成,

浏览信息,构建事件,自定义构建设置和Web部署。

没有什么叫做Build。我在哪里可以找到这个设置?


也许这不是最好/最简单的方法。如果我能被告知这件事,我会感激的。

" Joachim"写道:
Seems like you could use a void*:

C#:
MyMethod(this.Handle.ToPointer());

C++:
public:
void MyMethod(void* handle)
{
HWND l_wnd(handle);
....
}

However, that seems to require the unsafe keyword and that the code is
compiled with the /unsafe parameter. However 2, the descriptions I have found
about how to add this compiler option (e.g.
http://forums.microsoft.com/MSDN/Sho...22815&SiteID=1) talks
about a Build subfolder under Configuration Properties. I have: General,
Debugging, C/C++, Linker, Manifest Tool, Resources, XML Document Generation,
Browse Information, Build Events, Custom Build setup, and web deployment.
Nothing called Build. Where do I find this setting?

Perhaps this is not the best / simplest way to do it. Then I would
appreciate if I could be told this.
"Joachim" wrote:

我真正想做的是将一个C#等价物传递给

C ++中的HWND结构并将其作为指针传递到托管C ++中的HWND。我需要获得第三方非托管C ++函数的这个

窗口句柄来分配第三个

派对软件来将视频渲染到这个窗口。

" Joachim"写道:
What I really want to do is to pass a C# equivalent to the HWND structure in
C++ and pass it as a pointer to a HWND in managed C++. I need to get this
window handle to a third party unmanaged C++ function to assign the third
party software to render video onto this window.

"Joachim" wrote:

如何在C#和托管C ++之间传递C ++ HWND?
How can I pass a C++ HWND to and from C# and Managed C++?


我真正想做的是在
C ++中传递一个等效于HWND结构的C#,将它作为指向托管C ++中HWND的指针传递给它。我需要获得第三方非托管C ++函数的这个

窗口句柄来分配第三个

派对软件来将视频渲染到这个窗口。

" Joachim"写道:
What I really want to do is to pass a C# equivalent to the HWND structure in
C++ and pass it as a pointer to a HWND in managed C++. I need to get this
window handle to a third party unmanaged C++ function to assign the third
party software to render video onto this window.

"Joachim" wrote:

如何在C#和托管C ++之间传递C ++ HWND?
How can I pass a C++ HWND to and from C# and Managed C++?


我找到了它。


" Joachim"写道:
I found it.

"Joachim" wrote:

好​​像你可以使用一个空*:


C#:

MyMethod (this.Handle.ToPointer());


C ++:

public:

void MyMethod(void * handle)

{

HWND l_wnd(句柄);

...

}


但是,这似乎需要unsafe关键字,并且代码是使用/ unsafe参数编译的
。但是2,我已经找到了关于如何添加这个编译器选项的描述(例如
http://forums.microsoft.com/MSDN/Sho...22815&SiteID=1 )会谈

关于配置属性下的Build子文件夹。我有:一般,

调试,C / C ++,链接器,清单工具,资源,XML文档生成,

浏览信息,构建事件,自定义构建设置和Web部署。

没有什么叫做Build。我在哪里可以找到这个设置?


也许这不是最好/最简单的方法。如果我能被告知这件事,我会感激的。


" Joachim"写道:
Seems like you could use a void*:

C#:
MyMethod(this.Handle.ToPointer());

C++:
public:
void MyMethod(void* handle)
{
HWND l_wnd(handle);
...
}

However, that seems to require the unsafe keyword and that the code is
compiled with the /unsafe parameter. However 2, the descriptions I have found
about how to add this compiler option (e.g.
http://forums.microsoft.com/MSDN/Sho...22815&SiteID=1) talks
about a Build subfolder under Configuration Properties. I have: General,
Debugging, C/C++, Linker, Manifest Tool, Resources, XML Document Generation,
Browse Information, Build Events, Custom Build setup, and web deployment.
Nothing called Build. Where do I find this setting?

Perhaps this is not the best / simplest way to do it. Then I would
appreciate if I could be told this.
"Joachim" wrote:

我真正想做的是将一个C#等价物传递给

C ++中的HWND结构并将其作为指针传递到托管C ++中的HWND。我需要获得第三方非托管C ++函数的这个

窗口句柄来分配第三个

派对软件来将视频渲染到这个窗口。

" Joachim"写道:
What I really want to do is to pass a C# equivalent to the HWND structure in
C++ and pass it as a pointer to a HWND in managed C++. I need to get this
window handle to a third party unmanaged C++ function to assign the third
party software to render video onto this window.

"Joachim" wrote:

如何在C#和托管C ++之间传递C ++ HWND?
How can I pass a C++ HWND to and from C# and Managed C++?


这篇关于与C#和托管C ++之间的C ++ HWND?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆