??????????????C#??????????????????10??C#????????????????????????????????????????????????UI??????Щ????????????????????????????????????
????1 ???????????CLR??汾
????OperatingSystem os = System.Environment.OSVersion;
????Console.WriteLine(“Platform: {0}”?? os.Platform);
????Console.WriteLine(“Service Pack: {0}”?? os.ServicePack);
????Console.WriteLine(“Version: {0}”?? os.Version);
????Console.WriteLine(“VersionString: {0}”?? os.VersionString);
????Console.WriteLine(“CLR Version: {0}”?? System.Environment.Version);
?????????Windows 7???У???????????
????Platform: Win32NT
????Service Pack:
????Version: 6.1.7600.0
????VersionString: Microsoft Windows NT 6.1.7600.0
????CLR Version: 4.0.21006.1
????2 ???CPU?????????????
???????????Windows Management Instrumentation (WMI)????????????????????
????private static UInt32 CountPhysicalProcessors()
????{
????ManagementObjectSearcher objects = new ManagementObjectSearcher(
????“SELECT * FROM Win32_ComputerSystem”);
????ManagementObjectCollection coll = objects.Get();
????foreach(ManagementObject obj in coll)
????{
????return (UInt32)obj[“NumberOfProcessors”];
????}
????return 0;
????}
????private static UInt64 CountPhysicalMemory()
????{
????ManagementObjectSearcher objects =new ManagementObjectSearcher(
????“SELECT * FROM Win32_PhysicalMemory”);
????ManagementObjectCollection coll = objects.Get();
????UInt64 total = 0;
????foreach (ManagementObject obj in coll)
????{
????total += (UInt64)obj[“Capacity”];
????}
????return total;
????}
?????????????System.Management????????????????????????
????Console.WriteLine(“Machine: {0}”?? Environment.MachineName);
????Console.WriteLine(“# of processors (logical): {0}”?? Environment.ProcessorCount);
????Console.WriteLine(“# of processors (physical): {0}”  CountPhysicalProcessors());
????Console.WriteLine(“RAM installed: {0:N0} bytes”??  CountPhysicalMemory());
????Console.WriteLine(“Is OS 64-bit? {0}”??   Environment.Is64BitOperatingSystem);
????Console.WriteLine(“Is process 64-bit? {0}”??  Environment.Is64BitProcess);
????Console.WriteLine(“Little-endian: {0}”?? BitConverter.IsLittleEndian);
????foreach (Screen screen in  System.Windows.Forms.Screen.AllScreens)
????{
????Console.WriteLine(“Screen {0}”?? screen.DeviceName);
????Console.WriteLine(“ Primary {0}”?? screen.Primary);
????Console.WriteLine(“ Bounds: {0}”?? screen.Bounds);
????Console.WriteLine(“ Working Area: {0}”??screen.WorkingArea);
????Console.WriteLine(“ BitsPerPixel: {0}”??screen.BitsPerPixel);
????}
????3 ???????????
????using (RegistryKey keyRun = Registry.LocalMachine.OpenSubKey(@”SoftwareMicrosoftWindowsCurrentVersionRun”))
????{
????foreach (string valueName in keyRun.GetValueNames())
????{
????Console.WriteLine(“Name: {0} Value: {1}”?? valueName?? keyRun.GetValue(valueName));
????}
????}
????????????????Microsoft.Win32?????????????????????
????4 ???????Windows????
????????API??????ù????????????????ó????е??????????????????????????н??в?????
????ServiceController controller = new ServiceController(“e-M-POWER”);     
????controller.Start();     
????if (controller.CanPauseAndContinue)     
????{     
????controller.Pause();     
????controller.Continue();     
????}     
????controller.Stop();
????.net????API?У??????????仰?????ж?????
????if (args[0] == "/i")
????{
????ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location });
????}
????else if (args[0] == "/u")
????{
????ManagedInstallerClass.InstallHelper(new string[] { "/u"?? Assembly.GetExecutingAssembly().Location });
????}
??????????????????ó?????i??u????????????ж???????????
????5 ????????????strong name (P/Invoke)
??????????????У?????????????????????????????·???
????[DllImport("mscoree.dll"?? CharSet=CharSet.Unicode)]
????static extern bool StrongNameSignatureVerificationEx(string wszFilePath?? bool fForceVerification?? ref bool pfWasVerified);
????bool notForced = false;
????bool verified = StrongNameSignatureVerificationEx(assembly?? false?? ref notForced);
????Console.WriteLine("Verified: {0} Forced: {1}"?? verified?? !notForced);
????????????????????????????????????????????????????????????????????????г????????????????????????????????????????????????????С?
????6 ??????????????
???????????????????????QQ????????????????????μ????
????????????????Microsoft.Win32???????????????????
????. DisplaySettingsChanged (????Changing) ???????
????. InstalledFontsChanged ????仯
????. PaletteChanged
????. PowerModeChanged ?????
????. SessionEnded (??????????????????)
????. SessionSwitch (?????????)
????. TimeChanged ?????
????. UserPreferenceChanged (?????? ????Changing)
?????????ERP???????????????????????????????ERP???????????Χ??????ERP????????á?
????7 ????Windows7????????
????Windows7???????Щ?????????????????????????????????????????
????Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog ofd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
????ofd.AddToMostRecentlyUsedList = true;
????ofd.IsFolderPicker = true;
????ofd.AllowNonFileSystemItems = true;
????ofd.ShowDialog();
????????????????????????BCL???????е?OpenFileDialog????????Щ???????????Windows 7???У????????????δ????????????????汾?????6?????????????Windows API Code Pack for Microsoft?.NET Framework??????????????????? http://code.msdn.microsoft.com/WindowsAPICodePack
????8 ???????????????
??????????????????????.NET?????????????????
????long available = GC.GetTotalMemory(false);
????Console.WriteLine(“Before allocations: {0:N0}”?? available);
????int allocSize = 40000000;
????byte[] bigArray = new byte[allocSize];
????available = GC.GetTotalMemory(false);
????Console.WriteLine(“After allocations: {0:N0}”?? available);
????????????У??????е??????????
????Before allocations: 651??064
????After allocations: 40??690??080
??????????????????????鵱???ó??????????
????Process proc = Process.GetCurrentProcess();
????Console.WriteLine(“Process Info: “+Environment.NewLine+
????“Private Memory Size: {0:N0}”+Environment.NewLine +
????“Virtual Memory Size: {1:N0}” + Environment.NewLine +
????“Working Set Size: {2:N0}” + Environment.NewLine +
????“Paged Memory Size: {3:N0}” + Environment.NewLine +
????“Paged System Memory Size: {4:N0}” + Environment.NewLine +
????“Non-paged System Memory Size: {5:N0}” + Environment.NewLine??
????proc.PrivateMemorySize64??   proc.VirtualMemorySize64??  proc.WorkingSet64??  proc.PagedMemorySize64?? proc.PagedSystemMemorySize64??  proc.NonpagedSystemMemorySize64 );