C#中的SetDeviceGammaRamp [英] SetDeviceGammaRamp in C#

查看:416
本文介绍了C#中的SetDeviceGammaRamp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我叫克里斯蒂安(Cristian),在开发控制监视器屏幕亮度的程序时需要帮助.

我认为使用功能SetDeviceGammaRamp可以做到.

我使用C#编程语言.

请帮助我.

Hello!

My name is Cristian and I need help in development of a program that controls the brightness of the monitor screen.

I think that with the function SetDeviceGammaRamp could do it.

I use C # programming language.

Please help me.

推荐答案

您需要在C#中使用P/Invoke.

P/调用使用System.Runtime.InteropServicesSystem.Runtime.InteropServices.DllImportAttribute.
您可以在此处找到一个简单的代码示例: http://msdn.microsoft.com /en-us/library/system.runtime.interopservices.dllimportattribute.aspx [ http://msdn.microsoft.com/en-us/library/system. runtime.interopservices.marshalasattribute.aspx [ ^ ].

在更复杂的情况下(尤其是涉及内存分配时),您可能需要对类System.Runtime.InteropServices.Marshal使用显式的封送处理方法,请参见 http://msdn.microsoft.com/en-us/magazine/cc164085.aspx [ ^ ].

您还可以方便地在混合模式项目中使用C ++/CLI,请参阅我过去的解决方案:
处理Windows窗体应用程序 [
You need to use P/Invoke with C#.

P/Invoke uses System.Runtime.InteropServices and System.Runtime.InteropServices.DllImportAttribute.
You can find a simple code sample here: http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx[^].

It may me fairly simple or quite tricky. To specify marshaling between native (unmanaged) and managed parameters you may also need to use the attribute System.Runtime.InteropServices.MarshalAsAttribute, see the code sample:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx[^].

In more complex cases (in particular, when memory allocation is involved), you may need to use explicit marshaling methods with the class System.Runtime.InteropServices.Marshal, see http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.aspx[^].

In even more complex cases you may need to use custom marshaling. See, for example: http://msdn.microsoft.com/en-us/magazine/cc164085.aspx[^].

You can also conveniently use C++/CLI in mixed-mode project, see my past solution:
Dealing with windows form application[^].

—SA


我不明白.您可以发布一个代码示例吗?
谢谢!
I don''t understand. You could post a code example?
Thanks!


这篇关于C#中的SetDeviceGammaRamp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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