C# 的 SystemParametersInfo 参数定义
我想从 C# 调用 SystemParametersInfo。该函数的第一个参数是诸如 SPI_GETACCESSTIMEOUT 之类的大量可能值之一,这些值在文档中列出,但似乎没有在任何地方定义。
我可以在网络上找到这些东西的实际值,并用其中正确的幻数组成一个枚举 - 这可行,但不是正确的事情。我希望能够包含一些可以为我完成所有这一切的东西。它们必须在某个地方定义!
我该怎么做才能使其正常工作?
OJ 指向 SPI 页面,如果我想复制,这非常有用所有这些都进入我的源代码。 但我希望编译器能够做到这一点。
我应该只能说:
[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);
相反,我需要添加:
public const uint SPI_GETACCESSTIMEOUT = 0x003C;
... 以及所有其余的内容。我正在寻找一些命令,可以从 dll 中的任何位置导入所有这些定义。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这正是 pinvoke.net 的全部内容:)
请参阅 SystemParametersInfo 页面以获得完整的描述和示例代码。请记住,据我所知,您必须使用 pinvoke 来处理此 API。
干杯!
编辑:如果不是很明显,可以在 SPI 页面(从 SystemParametersInfo 页面链接)。还有另一个示例此处。
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.