SystemParametersInfo parameter definitions for C #

I want to call SystemParametersInfo from C #. The first argument to this function is one of a large set of possible values, such as SPI_GETACCESSTIMEOUT, which are listed in the documentation but are not displayed anywhere.

I can find the actual values ​​of these things on the Internet and make an enumeration with the correct magic numbers in it - it works, but it doesn’t. I want to include something that does everything for me. They need to be defined somewhere!

What am I doing to get it right?


OJ points to the SPI page, and this is great if I want to copy all this into the source code. But I want the compiler to do this.

I can just 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 everything else. I am looking for some team that will import all these definitions from anywhere they live in the dll.

+6
c # include system-calls
source share
1 answer

This is exactly pinvoke.net :)

For a detailed description and sample code, see the SystemParametersInfo page . Keep in mind that you should use pinvoke to work with this API as far as I know.

Hooray!

EDIT: If this is not immediately obvious, information for SPI_GETACCESSTIMEOUT can be found on the SPI page (which is associated with the SystemParametersInfo page). There is also another example here .

+2
source share

All Articles