using System.Management;\r\n\r\n void Kapat()\r\n {\r\n ManagementBaseObject mboShutdown = null;\r\n ManagementClass mcWin32 = new ManagementClass(\"Win32_OperatingSystem\");\r\n mcWin32.Get(); \r\n mcWin32.Scope.Options.EnablePrivileges = true;\r\n ManagementBaseObject mboShutdownParams =\r\n mcWin32.GetMethodParameters(\"Win32Shutdown\"); \r\n mboShutdownParams[\"Flags\"] = \"1\";\r\n mboShutdownParams[\"Reserved\"] = \"0\";\r\n foreach (ManagementObject manObj in mcWin32.GetInstances())\r\n {\r\n mboShutdown = manObj.InvokeMethod(\"Win32Shutdown\", \r\n mboShutdownParams, null);\r\n }\r\n }
","url":"https://uzmanim.net/soru/c-ile-bilgisayari-nasil-kapatirim/1057#a1058","author":{"@type":"Person","name":"alattin"},"comment":[],"commentCount":0,"dateCreated":"2013-10-21T16:06:55.47+03:00","dateModified":"2013-10-21T17:55:13.483+03:00","text":"
Öncelikle using System.Management sınıfını direktif olarak sayfanıza eklemelisiniz.
using System.Management;\r\n\r\n void Kapat()\r\n {\r\n ManagementBaseObject mboShutdown = null;\r\n ManagementClass mcWin32 = new ManagementClass(\"Win32_OperatingSystem\");\r\n mcWin32.Get(); \r\n mcWin32.Scope.Options.EnablePrivileges = true;\r\n ManagementBaseObject mboShutdownParams =\r\n mcWin32.GetMethodParameters(\"Win32Shutdown\"); \r\n mboShutdownParams[\"Flags\"] = \"1\";\r\n mboShutdownParams[\"Reserved\"] = \"0\";\r\n foreach (ManagementObject manObj in mcWin32.GetInstances())\r\n {\r\n mboShutdown = manObj.InvokeMethod(\"Win32Shutdown\", \r\n mboShutdownParams, null);\r\n }\r\n }
","upvoteCount":0},"answerCount":1,"suggestedAnswer":{"@type":"Answer","name":"
Öncelikle using System.Management sınıfını direktif olarak sayfanıza eklemelisiniz.
using System.Management;\r\n\r\n void Kapat()\r\n {\r\n ManagementBaseObject mboShutdown = null;\r\n ManagementClass mcWin32 = new ManagementClass(\"Win32_OperatingSystem\");\r\n mcWin32.Get(); \r\n mcWin32.Scope.Options.EnablePrivileges = true;\r\n ManagementBaseObject mboShutdownParams =\r\n mcWin32.GetMethodParameters(\"Win32Shutdown\"); \r\n mboShutdownParams[\"Flags\"] = \"1\";\r\n mboShutdownParams[\"Reserved\"] = \"0\";\r\n foreach (ManagementObject manObj in mcWin32.GetInstances())\r\n {\r\n mboShutdown = manObj.InvokeMethod(\"Win32Shutdown\", \r\n mboShutdownParams, null);\r\n }\r\n }
","url":"https://uzmanim.net/soru/c-ile-bilgisayari-nasil-kapatirim/1057#a1058","author":{"@type":"Person","name":"alattin"},"comment":[],"commentCount":0,"dateCreated":"2013-10-21T16:06:55.47+03:00","dateModified":"2013-10-21T17:55:13.483+03:00","text":"
Öncelikle using System.Management sınıfını direktif olarak sayfanıza eklemelisiniz.
using System.Management;\r\n\r\n void Kapat()\r\n {\r\n ManagementBaseObject mboShutdown = null;\r\n ManagementClass mcWin32 = new ManagementClass(\"Win32_OperatingSystem\");\r\n mcWin32.Get(); \r\n mcWin32.Scope.Options.EnablePrivileges = true;\r\n ManagementBaseObject mboShutdownParams =\r\n mcWin32.GetMethodParameters(\"Win32Shutdown\"); \r\n mboShutdownParams[\"Flags\"] = \"1\";\r\n mboShutdownParams[\"Reserved\"] = \"0\";\r\n foreach (ManagementObject manObj in mcWin32.GetInstances())\r\n {\r\n mboShutdown = manObj.InvokeMethod(\"Win32Shutdown\", \r\n mboShutdownParams, null);\r\n }\r\n }
","upvoteCount":0},"upvoteCount":0}}
C# ile Windows'u kapatmak mümkün mü?
Windows Form uygulamam var ve yapılan bir işlem bittiğinde Windows'u kapatmak istiyorum. Yani işlem bittiğinde Windows'u kapat gibi bir seçenek olarak. Kullanıcı bu seçeneği seçmiş ise Windows kapanacak.
C# ile Windows işletim sistemini nasıl kapatırım?
Toplam 1 cevap
Öncelikle using System.Management sınıfını direktif olarak sayfanıza eklemelisiniz.
using System.Management; void Kapat() { ManagementBaseObject mboShutdown = null; ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem"); mcWin32.Get(); mcWin32.Scope.Options.EnablePrivileges = true; ManagementBaseObject mboShutdownParams = mcWin32.GetMethodParameters("Win32Shutdown"); mboShutdownParams["Flags"] = "1"; mboShutdownParams["Reserved"] = "0"; foreach (ManagementObject manObj in mcWin32.GetInstances()) { mboShutdown = manObj.InvokeMethod("Win32Shutdown", mboShutdownParams, null); } }