开发者

How to get SYSTEM_POWER_STATUS using Silverlight 2/3/4?

I have a Silverlight application running full screen. Is there a way i can display system power status ( basically battery indicator how much is remaining ? ) using silverlight?

I tried following

[DllImport("kernel32.dll")]
private static extern long GetSystemPowerStat开发者_Python百科us(SYSTEM_POWER_STATUS
lpSystemPowerStatus);

But got error message -

Attempt by security transparent method 'SilverlightApplication1.MainPage.x()' to call native code through method 'SilverlightApplication1.MainPage.GetSystemPowerStatus(SilverlightApplication1.SYSTEM_POWER_STATUS)' failed. Methods must be security critical or security safe-critical to call native code.


From Brian Henderson on the MSDN forums:

Silverlight runs in a sandboxed security environment and does not have access to client API functions. By design, Silverlight is a cross-client, cross-OS (operating system) so does not not have access to native client API methods. Since you are attempting to call specific Win32 API functions, I would recommend you choose to use a Windows OS specific client technology.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜