是否有可能,不使用的PInvoke,使用.NET重新启动电脑?
Is it possible, without employing pinvoke, to restart a PC using .NET?
我只是重复了冠军,但我不太清楚如何更进一步阐述!
I kind of just repeated the title, but I'm not too sure how to elaborate much further!
编辑:
我应该提到不希望使用执行shutdown -r作为解决方案。
I should have mentioned that don't want to use "shutdown -r" as a solution.
我是真的后,一个纯粹的.NET的方式,是这样的:
I was really after a pure .NET way, something like:
Environment.ShutDown();
在换句话说,即保持与.NET的出现新版本的Windows的东西。
In other words, something that is maintained with .NET as new versions of Windows arise.
修改2:
请的,别再问这有什么错的P / Invoke。这些种类的答案是完全有啥用户似乎更喜欢;所谓横向的方式来回答问题。然而,虽然没有真正的问题的P / Invoke,我会很乐意使用它,地球上有什么问题,询问是否有.NET实现一些更正式的方式?如果它在.NET那么操作系统之间的API的变化将(最有可能)得到体现。不管什么原因,它不是犯罪,寻求以最小化DLL导入的用法是什么呢?
Please stop asking "what's wrong with p/invoke". Those sort of answers are exactly what SO users seem to love; the supposed "lateral" approach to answering a question. However, although there is no real problem with p/invoke and I will happily use it, what on earth is wrong with asking if .NET has a more official way of achieving something? If it's in .NET then any API changes between OSes will (most likely) get reflected. Whatever the reason, it's not a crime to seek to minimise DLL import usage is it?
我敢肯定,如果我包括东西的问题,如:
I'm sure if I included something in a question like:
[DllImport("something32.dll")]
static extern int ClimbWall32Ex(IntPtr32 blah);
和你可能只是做:
SomeNamespace.ClimbWall();
大家一个在这里会尖叫:什么是错用 SomeNamespace.ClimbWall();
?
唉。
推荐答案
您需要调用ExitWindowsEx这是唯一可通过的DllImport
You need to call ExitWindowsEx which is only available through DllImport
相关推荐
最新文章