Is it possible, without using pinvoke, to restart the PC using .NET?
I kind of just repeated the name, but I'm not too sure how to do it next!
Edit:
I should have mentioned that I did not want to use "shutdown -r" as a solution.
I was in a really clean .NET way, something like:
Environment.ShutDown();
In other words, something that is supported with .NET as new versions of Windows arises.
Edit 2:
Please stop asking "what's with p / invoke." These kinds of answers are exactly what SO users love; the alleged "side" approach to answering the question. However, although there is no real problem with p / invoke, and I use it with pleasure, which is actually not the case if you ask if .NET has a more formal way to achieve something? If it is in .NET, then any API changes between the OS will (most likely) be reflected. Whatever the reason, is this not a crime aimed at minimizing the use of DLL imports?
I'm sure I included something in the question like:
[DllImport("something32.dll")] static extern int ClimbWall32Ex(IntPtr32 blah);
And you could just do:
SomeNamespace.ClimbWall();
Everyone here shouts: "What's wrong with using SomeNamespace.ClimbWall(); ;?"
Sigh.
joshcomley
source share