开发者

SystemParametersInfo parameter definitions for C#

开发者 https://www.devze.com 2022-12-22 09:30 出处:网络
I want to make a call to SystemParametersInfo from C#. The first argument to this function is one of a large collection of possible values like SPI_GETACCESSTIMEOUT, which are listed in the documentat

I want to make a call to SystemParametersInfo from C#. The first argument to this function is one of a large collection of possible values like SPI_GETACCESSTIMEOUT, which are listed in the documentation, but don't seem to be defined anywhere.

I can go find the actual values of these things on the web, and make up an enum with the right magic numbers in it - that works, but it's not the right thing. I want to be able to include something that does all that for me. They have to be defined somewhere!

What do I do to make this work properly?


OJ points to the SPI page which is great if I want to copy all that into my source code. But I want the compiler to do that.

I should just be able to say:

[DllImport("user32", CharSet = CharSet.Auto)]
private static extern bool SystemParametersInfo(int uAction, bool uParam, int lpvParam, int fuWinIni);
SystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, ref IsActive, 0);

Instead I need to add:

public const uint SPI_GETACCESSTIMEOUT = 0x003C;

... and all the rest of it as well. I开发者_如何转开发'm looking for some command that will import all those definitions from wherever they live in the dll.


This is exactly what pinvoke.net is all about :)

See the SystemParametersInfo page for a full description and sample code. Bear in mind you have to use pinvoke to deal with this API as far as I'm aware.

Cheers!

EDIT: In case it's not immediately obvious, the information for SPI_GETACCESSTIMEOUT can be found on the SPI page (which is linked from the SystemParametersInfo page). There is also another sample here.

0

精彩评论

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