Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for systeminformationdll.cs

(view source code of systeminformationdll.cs as plain text)

  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Reflection;
  5. using System.Runtime.InteropServices;
  6. using System.Windows.Forms;
  7.  
  8.  
  9. namespace RobvanderWoude
  10. {
  11. 	[ComVisible( true )]
  12. 	public class SystemInformation
  13. 	{
  14. 		private static string mypath = Assembly.GetAssembly( typeof( RobvanderWoude.SystemInformation ) ).Location.ToString( );
  15.  
  16. 		[ComVisible( true )]
  17. 		public string GetHelp( )
  18. 		{
  19. 			string helptemplate = "{0}, Version {1}\n{2}\n\nUsage in VBScript:\n\n";
  20. 			helptemplate += "Set objSysInfo=CreateObject( \"RobvanderWoude.SystemInformation\" )\n";
  21. 			helptemplate += "' Read some property values\n";
  22. 			helptemplate += "WScript.Echo objSysInfo.UserName\n";
  23. 			helptemplate += "WScript.Echo objSysInfo.MonitorCount\n";
  24. 			helptemplate += "' Get the DLL's version\n";
  25. 			helptemplate += "WScript.Echo objSysInfo.GetVersion( )\n";
  26. 			helptemplate += "' List all available property names\n";
  27. 			helptemplate += "WScript.Echo objSysInfo.ListPropertyNames( )\n";
  28. 			helptemplate += "' List all property names and their values\n";
  29. 			helptemplate += "Wscript.Echo objSysInfo.ListPropertyValues( )\n\n";
  30. 			helptemplate += "Note: All property values are returned as string or 32-bit integer.\n\n";
  31. 			helptemplate += "{3}\n";
  32. 			helptemplate += "http://www.robvanderwoude.com\n";
  33. 			FileVersionInfo myfileversioninfo = FileVersionInfo.GetVersionInfo( mypath );
  34. 			string filename = Path.GetFileName( myfileversioninfo.FileName );
  35. 			string fileversion = myfileversioninfo.FileVersion;
  36. 			string filecomment = myfileversioninfo.Comments;
  37. 			string copyrights = myfileversioninfo.LegalCopyright;
  38. 			string description = String.Format( helptemplate, filename, fileversion, filecomment, copyrights );
  39. 			return description;
  40. 		}
  41.  
  42. 		[ComVisible( true )]
  43. 		public string GetVersion( )
  44. 		{
  45. 			return FileVersionInfo.GetVersionInfo( mypath ).FileVersion;
  46. 		}
  47.  
  48. 		[ComVisible( true )]
  49. 		public string ListPropertyNames( )
  50. 		{
  51. 			string result = String.Empty;
  52. 			foreach ( PropertyInfo property in this.GetType( ).GetProperties( ) )
  53. 			{
  54. 				result += property.Name + "\n";
  55. 			}
  56. 			return result;
  57. 		}
  58.  
  59. 		[ComVisible( true )]
  60. 		public string ListPropertyValues( )
  61. 		{
  62. 			string result = String.Empty;
  63. 			foreach ( PropertyInfo property in this.GetType( ).GetProperties( ) )
  64. 			{
  65. 				string val = String.Empty;
  66. 				try
  67. 				{
  68. 					val = property.GetValue( this, null ).ToString( );
  69. 				}
  70. 				catch { };
  71. 				result += String.Format( "{0}={1}\n", property.Name, val );
  72. 			}
  73. 			return result;
  74. 		}
  75.  
  76. 		[ComVisible( true )]
  77. 		public int ActiveWindowTrackingDelay
  78. 		{
  79. 			get { return System.Windows.Forms.SystemInformation.ActiveWindowTrackingDelay; }
  80. 		}
  81.  
  82. 		[ComVisible( true )]
  83. 		public string ArrangeDirection
  84. 		{
  85. 			get { return Enum.GetName( typeof( ArrangeDirection ), System.Windows.Forms.SystemInformation.ArrangeDirection ); }
  86. 		}
  87.  
  88. 		[ComVisible( true )]
  89. 		public string ArrangeStartingPosition
  90. 		{
  91. 			get { return Enum.GetName( typeof( ArrangeStartingPosition ), System.Windows.Forms.SystemInformation.ArrangeStartingPosition ); }
  92. 		}
  93.  
  94. 		[ComVisible( true )]
  95. 		public string BootMode
  96. 		{
  97. 			get { return Enum.GetName( typeof( BootMode ), System.Windows.Forms.SystemInformation.BootMode ); }
  98. 		}
  99.  
  100. 		[ComVisible( true )]
  101. 		public string Border3DSize
  102. 		{
  103. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.Border3DSize.Width, System.Windows.Forms.SystemInformation.Border3DSize.Height ); }
  104. 		}
  105.  
  106. 		[ComVisible( true )]
  107. 		public int BorderMultiplierFactor
  108. 		{
  109. 			get { return System.Windows.Forms.SystemInformation.BorderMultiplierFactor; }
  110. 		}
  111.  
  112. 		[ComVisible( true )]
  113. 		public string BorderSize
  114. 		{
  115. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.BorderSize.Width, System.Windows.Forms.SystemInformation.BorderSize.Height ); }
  116. 		}
  117.  
  118. 		[ComVisible( true )]
  119. 		public string CaptionButtonSize
  120. 		{
  121. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.CaptionButtonSize.Width, System.Windows.Forms.SystemInformation.CaptionButtonSize.Height ); }
  122. 		}
  123.  
  124. 		[ComVisible( true )]
  125. 		public int CaptionHeight
  126. 		{
  127. 			get { return System.Windows.Forms.SystemInformation.CaptionHeight; }
  128. 		}
  129.  
  130. 		[ComVisible( true )]
  131. 		public int CaretBlinkTime
  132. 		{
  133. 			get { return System.Windows.Forms.SystemInformation.CaretBlinkTime; }
  134. 		}
  135.  
  136. 		[ComVisible( true )]
  137. 		public int CaretWidth
  138. 		{
  139. 			get { return System.Windows.Forms.SystemInformation.CaretWidth; }
  140. 		}
  141.  
  142. 		[ComVisible( true )]
  143. 		public string ComputerName
  144. 		{
  145. 			get { return System.Windows.Forms.SystemInformation.ComputerName; }
  146. 		}
  147.  
  148. 		[ComVisible( true )]
  149. 		public string CursorSize
  150. 		{
  151. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.CursorSize.Width, System.Windows.Forms.SystemInformation.CursorSize.Height ); }
  152. 		}
  153.  
  154. 		[ComVisible( true )]
  155. 		public string DbcsEnabled
  156. 		{
  157. 			get { return ( System.Windows.Forms.SystemInformation.DbcsEnabled ? "True" : "False" ); }
  158. 		}
  159.  
  160. 		[ComVisible( true )]
  161. 		public string DebugOS
  162. 		{
  163. 			get { return ( System.Windows.Forms.SystemInformation.DebugOS ? "True" : "False" ); }
  164. 		}
  165.  
  166. 		[ComVisible( true )]
  167. 		public string DoubleClickSize
  168. 		{
  169. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.DoubleClickSize.Width, System.Windows.Forms.SystemInformation.DoubleClickSize.Height ); }
  170. 		}
  171.  
  172. 		[ComVisible( true )]
  173. 		public int DoubleClickTime
  174. 		{
  175. 			get { return System.Windows.Forms.SystemInformation.DoubleClickTime; }
  176. 		}
  177.  
  178. 		[ComVisible( true )]
  179. 		public string DragFullWindows
  180. 		{
  181. 			get { return ( System.Windows.Forms.SystemInformation.DragFullWindows ? "True" : "False" ); }
  182. 		}
  183.  
  184. 		[ComVisible( true )]
  185. 		public string DragSize
  186. 		{
  187. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.DragSize.Width, System.Windows.Forms.SystemInformation.DragSize.Height ); }
  188. 		}
  189.  
  190. 		[ComVisible( true )]
  191. 		public string FixedFrameBorderSize
  192. 		{
  193. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.FixedFrameBorderSize.Width, System.Windows.Forms.SystemInformation.FixedFrameBorderSize.Height ); }
  194. 		}
  195.  
  196. 		[ComVisible( true )]
  197. 		public int FontSmoothingContrast
  198. 		{
  199. 			get { return System.Windows.Forms.SystemInformation.FontSmoothingContrast; }
  200. 		}
  201.  
  202. 		[ComVisible( true )]
  203. 		public int FontSmoothingType
  204. 		{
  205. 			get { return System.Windows.Forms.SystemInformation.FontSmoothingType; }
  206. 		}
  207.  
  208. 		[ComVisible( true )]
  209. 		public string FrameBorderSize
  210. 		{
  211. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.FrameBorderSize.Width, System.Windows.Forms.SystemInformation.FrameBorderSize.Height ); }
  212. 		}
  213.  
  214. 		[ComVisible( true )]
  215. 		public string HighContrast
  216. 		{
  217. 			get { return ( System.Windows.Forms.SystemInformation.HighContrast ? "True" : "False" ); }
  218. 		}
  219.  
  220. 		[ComVisible( true )]
  221. 		public int HorizontalFocusThickness
  222. 		{
  223. 			get { return System.Windows.Forms.SystemInformation.HorizontalFocusThickness; }
  224. 		}
  225.  
  226. 		[ComVisible( true )]
  227. 		public int HorizontalResizeBorderThickness
  228. 		{
  229. 			get { return System.Windows.Forms.SystemInformation.HorizontalResizeBorderThickness; }
  230. 		}
  231.  
  232. 		[ComVisible( true )]
  233. 		public int HorizontalScrollBarArrowWidth
  234. 		{
  235. 			get { return System.Windows.Forms.SystemInformation.HorizontalScrollBarArrowWidth; }
  236. 		}
  237.  
  238. 		[ComVisible( true )]
  239. 		public int HorizontalScrollBarHeight
  240. 		{
  241. 			get { return System.Windows.Forms.SystemInformation.HorizontalScrollBarHeight; }
  242. 		}
  243.  
  244. 		[ComVisible( true )]
  245. 		public int HorizontalScrollBarThumbWidth
  246. 		{
  247. 			get { return System.Windows.Forms.SystemInformation.HorizontalScrollBarThumbWidth; }
  248. 		}
  249.  
  250. 		[ComVisible( true )]
  251. 		public int IconHorizontalSpacing
  252. 		{
  253. 			get { return System.Windows.Forms.SystemInformation.IconHorizontalSpacing; }
  254. 		}
  255.  
  256. 		[ComVisible( true )]
  257. 		public string IconSize
  258. 		{
  259. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.IconSize.Width, System.Windows.Forms.SystemInformation.IconSize.Height ); }
  260. 		}
  261.  
  262. 		[ComVisible( true )]
  263. 		public string IconSpacingSize
  264. 		{
  265. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.IconSpacingSize.Width, System.Windows.Forms.SystemInformation.IconSpacingSize.Height ); }
  266. 		}
  267.  
  268. 		[ComVisible( true )]
  269. 		public int IconVerticalSpacing
  270. 		{
  271. 			get { return System.Windows.Forms.SystemInformation.IconVerticalSpacing; }
  272. 		}
  273.  
  274. 		[ComVisible( true )]
  275. 		public string IsActiveWindowTrackingEnabled
  276. 		{
  277. 			get { return ( System.Windows.Forms.SystemInformation.IsActiveWindowTrackingEnabled ? "True" : "False" ); }
  278. 		}
  279.  
  280. 		[ComVisible( true )]
  281. 		public string IsComboBoxAnimationEnabled
  282. 		{
  283. 			get { return ( System.Windows.Forms.SystemInformation.IsComboBoxAnimationEnabled ? "True" : "False" ); }
  284. 		}
  285.  
  286. 		[ComVisible( true )]
  287. 		public string IsDropShadowEnabled
  288. 		{
  289. 			get { return ( System.Windows.Forms.SystemInformation.IsDropShadowEnabled ? "True" : "False" ); }
  290. 		}
  291.  
  292. 		[ComVisible( true )]
  293. 		public string IsFlatMenuEnabled
  294. 		{
  295. 			get { return ( System.Windows.Forms.SystemInformation.IsFlatMenuEnabled ? "True" : "False" ); }
  296. 		}
  297.  
  298. 		[ComVisible( true )]
  299. 		public string IsFontSmoothingEnabled
  300. 		{
  301. 			get { return ( System.Windows.Forms.SystemInformation.IsFontSmoothingEnabled ? "True" : "False" ); }
  302. 		}
  303.  
  304. 		[ComVisible( true )]
  305. 		public string IsHotTrackingEnabled
  306. 		{
  307. 			get { return ( System.Windows.Forms.SystemInformation.IsHotTrackingEnabled ? "True" : "False" ); }
  308. 		}
  309.  
  310. 		[ComVisible( true )]
  311. 		public string IsIconTitleWrappingEnabled
  312. 		{
  313. 			get { return ( System.Windows.Forms.SystemInformation.IsIconTitleWrappingEnabled ? "True" : "False" ); }
  314. 		}
  315.  
  316. 		[ComVisible( true )]
  317. 		public string IsKeyboardPreferred
  318. 		{
  319. 			get { return ( System.Windows.Forms.SystemInformation.IsKeyboardPreferred ? "True" : "False" ); }
  320. 		}
  321.  
  322. 		[ComVisible( true )]
  323. 		public string IsListBoxSmoothScrollingEnabled
  324. 		{
  325. 			get { return ( System.Windows.Forms.SystemInformation.IsListBoxSmoothScrollingEnabled ? "True" : "False" ); }
  326. 		}
  327.  
  328. 		[ComVisible( true )]
  329. 		public string IsMenuAnimationEnabled
  330. 		{
  331. 			get { return ( System.Windows.Forms.SystemInformation.IsMenuAnimationEnabled ? "True" : "False" ); }
  332. 		}
  333.  
  334. 		[ComVisible( true )]
  335. 		public string IsMenuFadeEnabled
  336. 		{
  337. 			get { return ( System.Windows.Forms.SystemInformation.IsMenuFadeEnabled ? "True" : "False" ); }
  338. 		}
  339.  
  340. 		[ComVisible( true )]
  341. 		public string IsMinimizeRestoreAnimationEnabled
  342. 		{
  343. 			get { return ( System.Windows.Forms.SystemInformation.IsMinimizeRestoreAnimationEnabled ? "True" : "False" ); }
  344. 		}
  345.  
  346. 		[ComVisible( true )]
  347. 		public string IsSelectionFadeEnabled
  348. 		{
  349. 			get { return ( System.Windows.Forms.SystemInformation.IsSelectionFadeEnabled ? "True" : "False" ); }
  350. 		}
  351.  
  352. 		[ComVisible( true )]
  353. 		public string IsSnapToDefaultEnabled
  354. 		{
  355. 			get { return ( System.Windows.Forms.SystemInformation.IsSnapToDefaultEnabled ? "True" : "False" ); }
  356. 		}
  357.  
  358. 		[ComVisible( true )]
  359. 		public string IsTitleBarGradientEnabled
  360. 		{
  361. 			get { return ( System.Windows.Forms.SystemInformation.IsTitleBarGradientEnabled ? "True" : "False" ); }
  362. 		}
  363.  
  364. 		[ComVisible( true )]
  365. 		public string IsToolTipAnimationEnabled
  366. 		{
  367. 			get { return ( System.Windows.Forms.SystemInformation.IsToolTipAnimationEnabled ? "True" : "False" ); }
  368. 		}
  369.  
  370. 		[ComVisible( true )]
  371. 		public int KanjiWindowHeight
  372. 		{
  373. 			get { return System.Windows.Forms.SystemInformation.KanjiWindowHeight; }
  374. 		}
  375.  
  376. 		[ComVisible( true )]
  377. 		public int KeyboardDelay
  378. 		{
  379. 			get { return System.Windows.Forms.SystemInformation.KeyboardDelay; }
  380. 		}
  381.  
  382. 		[ComVisible( true )]
  383. 		public int KeyboardSpeed
  384. 		{
  385. 			get { return System.Windows.Forms.SystemInformation.KeyboardSpeed; }
  386. 		}
  387.  
  388. 		[ComVisible( true )]
  389. 		public string MaxWindowTrackSize
  390. 		{
  391. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MaxWindowTrackSize.Width, System.Windows.Forms.SystemInformation.MaxWindowTrackSize.Height ); }
  392. 		}
  393.  
  394. 		[ComVisible( true )]
  395. 		public string MenuAccessKeysUnderlined
  396. 		{
  397. 			get { return ( System.Windows.Forms.SystemInformation.MenuAccessKeysUnderlined ? "True" : "False" ); }
  398. 		}
  399.  
  400. 		[ComVisible( true )]
  401. 		public string MenuBarButtonSize
  402. 		{
  403. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MenuBarButtonSize.Width, System.Windows.Forms.SystemInformation.MenuBarButtonSize.Height ); }
  404. 		}
  405.  
  406. 		[ComVisible( true )]
  407. 		public string MenuButtonSize
  408. 		{
  409. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MenuButtonSize.Width, System.Windows.Forms.SystemInformation.MenuButtonSize.Height ); }
  410. 		}
  411.  
  412. 		[ComVisible( true )]
  413. 		public string MenuCheckSize
  414. 		{
  415. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MenuCheckSize.Width, System.Windows.Forms.SystemInformation.MenuCheckSize.Height ); }
  416. 		}
  417.  
  418. 		[ComVisible( true )]
  419. 		public string MenuFont
  420. 		{
  421. 			get { return String.Format( "[Font:Name={0},Size={1},Units={2},GdiCharSet={3},GdiVerticalFont={4}]", System.Windows.Forms.SystemInformation.MenuFont.Name, System.Windows.Forms.SystemInformation.MenuFont.Size.ToString( ), System.Windows.Forms.SystemInformation.MenuFont.Unit.ToString( ), System.Windows.Forms.SystemInformation.MenuFont.GdiCharSet.ToString( ), ( System.Windows.Forms.SystemInformation.MenuFont.GdiVerticalFont ? "True" : "False" ) ); }
  422. 		}
  423.  
  424. 		[ComVisible( true )]
  425. 		public int MenuHeight
  426. 		{
  427. 			get { return System.Windows.Forms.SystemInformation.MenuHeight; }
  428. 		}
  429.  
  430. 		[ComVisible( true )]
  431. 		public int MenuShowDelay
  432. 		{
  433. 			get { return System.Windows.Forms.SystemInformation.MenuShowDelay; }
  434. 		}
  435.  
  436. 		[ComVisible( true )]
  437. 		public string MidEastEnabled
  438. 		{
  439. 			get { return ( System.Windows.Forms.SystemInformation.MidEastEnabled ? "True" : "False" ); }
  440. 		}
  441.  
  442. 		[ComVisible( true )]
  443. 		public string MinimizedWindowSize
  444. 		{
  445. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MinimizedWindowSize.Width, System.Windows.Forms.SystemInformation.MinimizedWindowSize.Height ); }
  446. 		}
  447.  
  448. 		[ComVisible( true )]
  449. 		public string MinimizedWindowSpacingSize
  450. 		{
  451. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MinimizedWindowSpacingSize.Width, System.Windows.Forms.SystemInformation.MinimizedWindowSpacingSize.Height ); }
  452. 		}
  453.  
  454. 		[ComVisible( true )]
  455. 		public string MinimumWindowSize
  456. 		{
  457. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MinimumWindowSize.Width, System.Windows.Forms.SystemInformation.MinimumWindowSize.Height ); }
  458. 		}
  459.  
  460. 		[ComVisible( true )]
  461. 		public string MinWindowTrackSize
  462. 		{
  463. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MinWindowTrackSize.Width, System.Windows.Forms.SystemInformation.MinWindowTrackSize.Height ); }
  464. 		}
  465.  
  466. 		[ComVisible( true )]
  467. 		public int MonitorCount
  468. 		{
  469. 			get { return System.Windows.Forms.SystemInformation.MonitorCount; }
  470. 		}
  471.  
  472. 		[ComVisible( true )]
  473. 		public string MonitorsSameDisplayFormat
  474. 		{
  475. 			get { return ( System.Windows.Forms.SystemInformation.MonitorsSameDisplayFormat ? "True" : "False" ); }
  476. 		}
  477.  
  478. 		[ComVisible( true )]
  479. 		public int MouseButtons
  480. 		{
  481. 			get { return System.Windows.Forms.SystemInformation.MouseButtons; }
  482. 		}
  483.  
  484. 		[ComVisible( true )]
  485. 		public string MouseButtonsSwapped
  486. 		{
  487. 			get { return ( System.Windows.Forms.SystemInformation.MouseButtonsSwapped ? "True" : "False" ); }
  488. 		}
  489.  
  490. 		[ComVisible( true )]
  491. 		public string MouseHoverSize
  492. 		{
  493. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MouseHoverSize.Width, System.Windows.Forms.SystemInformation.MouseHoverSize.Height ); }
  494. 		}
  495.  
  496. 		[ComVisible( true )]
  497. 		public int MouseHoverTime
  498. 		{
  499. 			get { return System.Windows.Forms.SystemInformation.MouseHoverTime; }
  500. 		}
  501.  
  502. 		[ComVisible( true )]
  503. 		public string MousePresent
  504. 		{
  505. 			get { return ( System.Windows.Forms.SystemInformation.MousePresent ? "True" : "False" ); }
  506. 		}
  507.  
  508. 		[ComVisible( true )]
  509. 		public int MouseSpeed
  510. 		{
  511. 			get { return System.Windows.Forms.SystemInformation.MouseSpeed; }
  512. 		}
  513.  
  514. 		[ComVisible( true )]
  515. 		public string MouseWheelPresent
  516. 		{
  517. 			get { return ( System.Windows.Forms.SystemInformation.MouseWheelPresent ? "True" : "False" ); }
  518. 		}
  519.  
  520. 		[ComVisible( true )]
  521. 		public int MouseWheelScrollDelta
  522. 		{
  523. 			get { return System.Windows.Forms.SystemInformation.MouseWheelScrollDelta; }
  524. 		}
  525.  
  526. 		[ComVisible( true )]
  527. 		public int MouseWheelScrollLines
  528. 		{
  529. 			get { return System.Windows.Forms.SystemInformation.MouseWheelScrollLines; }
  530. 		}
  531.  
  532. 		[ComVisible( true )]
  533. 		public string NativeMouseWheelSupport
  534. 		{
  535. 			get { return ( System.Windows.Forms.SystemInformation.NativeMouseWheelSupport ? "True" : "False" ); }
  536. 		}
  537.  
  538. 		[ComVisible( true )]
  539. 		public string Network
  540. 		{
  541. 			get { return ( System.Windows.Forms.SystemInformation.Network ? "True" : "False" ); }
  542. 		}
  543.  
  544. 		[ComVisible( true )]
  545. 		public string PenWindows
  546. 		{
  547. 			get { return ( System.Windows.Forms.SystemInformation.PenWindows ? "True" : "False" ); }
  548. 		}
  549.  
  550. 		[ComVisible( true )]
  551. 		public string PopupMenuAlignment
  552. 		{
  553. 			get { return Enum.GetName( typeof( LeftRightAlignment ), System.Windows.Forms.SystemInformation.PopupMenuAlignment ); }
  554. 		}
  555.  
  556. 		[ComVisible( true )]
  557. 		public string PowerStatus
  558. 		{
  559. 			get { return GetPowerStatus( ); }
  560. 		}
  561.  
  562. 		[ComVisible( true )]
  563. 		public string PrimaryMonitorMaximizedWindowSize
  564. 		{
  565. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.PrimaryMonitorMaximizedWindowSize.Width, System.Windows.Forms.SystemInformation.PrimaryMonitorMaximizedWindowSize.Height ); }
  566. 		}
  567.  
  568. 		[ComVisible( true )]
  569. 		public string PrimaryMonitorSize
  570. 		{
  571. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width, System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height ); }
  572. 		}
  573.  
  574. 		[ComVisible( true )]
  575. 		public string RightAlignedMenus
  576. 		{
  577. 			get { return ( System.Windows.Forms.SystemInformation.RightAlignedMenus ? "True" : "False" ); }
  578. 		}
  579.  
  580. 		[ComVisible( true )]
  581. 		public string ScreenOrientation
  582. 		{
  583. 			get { return Enum.GetName( typeof( ScreenOrientation ), System.Windows.Forms.SystemInformation.ScreenOrientation ); }
  584. 		}
  585.  
  586. 		[ComVisible( true )]
  587. 		public string Secure
  588. 		{
  589. 			get { return ( System.Windows.Forms.SystemInformation.Secure ? "True" : "False" ); }
  590. 		}
  591.  
  592. 		[ComVisible( true )]
  593. 		public string ShowSounds
  594. 		{
  595. 			get { return ( System.Windows.Forms.SystemInformation.ShowSounds ? "True" : "False" ); }
  596. 		}
  597.  
  598. 		[ComVisible( true )]
  599. 		public int SizingBorderWidth
  600. 		{
  601. 			get { return System.Windows.Forms.SystemInformation.SizingBorderWidth; }
  602. 		}
  603.  
  604. 		[ComVisible( true )]
  605. 		public string SmallCaptionButtonSize
  606. 		{
  607. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.SmallCaptionButtonSize.Width, System.Windows.Forms.SystemInformation.SmallCaptionButtonSize.Height ); }
  608. 		}
  609.  
  610. 		[ComVisible( true )]
  611. 		public string SmallIconSize
  612. 		{
  613. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.SmallIconSize.Width, System.Windows.Forms.SystemInformation.SmallIconSize.Height ); }
  614. 		}
  615.  
  616. 		[ComVisible( true )]
  617. 		public string TerminalServerSession
  618. 		{
  619. 			get { return ( System.Windows.Forms.SystemInformation.TerminalServerSession ? "True" : "False" ); }
  620. 		}
  621.  
  622. 		[ComVisible( true )]
  623. 		public string ToolWindowCaptionButtonSize
  624. 		{
  625. 			get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.ToolWindowCaptionButtonSize.Width, System.Windows.Forms.SystemInformation.ToolWindowCaptionButtonSize.Height ); }
  626. 		}
  627.  
  628. 		[ComVisible( true )]
  629. 		public int ToolWindowCaptionHeight
  630. 		{
  631. 			get { return System.Windows.Forms.SystemInformation.ToolWindowCaptionHeight; }
  632. 		}
  633.  
  634. 		[ComVisible( true )]
  635. 		public string UIEffectsEnabled
  636. 		{
  637. 			get { return ( System.Windows.Forms.SystemInformation.UIEffectsEnabled ? "True" : "False" ); }
  638. 		}
  639.  
  640. 		[ComVisible( true )]
  641. 		public string UserDomainName
  642. 		{
  643. 			get { return System.Windows.Forms.SystemInformation.UserDomainName; }
  644. 		}
  645.  
  646. 		[ComVisible( true )]
  647. 		public string UserInteractive
  648. 		{
  649. 			get { return ( System.Windows.Forms.SystemInformation.UserInteractive ? "True" : "False" ); }
  650. 		}
  651.  
  652. 		[ComVisible( true )]
  653. 		public string UserName
  654. 		{
  655. 			get { return System.Windows.Forms.SystemInformation.UserName; }
  656. 		}
  657.  
  658. 		[ComVisible( true )]
  659. 		public int VerticalFocusThickness
  660. 		{
  661. 			get { return System.Windows.Forms.SystemInformation.VerticalFocusThickness; }
  662. 		}
  663.  
  664.  
  665. 		[ComVisible( true )]
  666. 		public int VerticalResizeBorderThickness
  667. 		{
  668. 			get { return System.Windows.Forms.SystemInformation.VerticalResizeBorderThickness; }
  669. 		}
  670.  
  671.  
  672. 		[ComVisible( true )]
  673. 		public int VerticalScrollBarArrowHeight
  674. 		{
  675. 			get { return System.Windows.Forms.SystemInformation.VerticalScrollBarArrowHeight; }
  676. 		}
  677.  
  678.  
  679. 		[ComVisible( true )]
  680. 		public int VerticalScrollBarThumbHeight
  681. 		{
  682. 			get { return System.Windows.Forms.SystemInformation.VerticalScrollBarThumbHeight; }
  683. 		}
  684.  
  685.  
  686. 		[ComVisible( true )]
  687. 		public int VerticalScrollBarWidth
  688. 		{
  689. 			get { return System.Windows.Forms.SystemInformation.VerticalScrollBarWidth; }
  690. 		}
  691.  
  692. 		[ComVisible( true )]
  693. 		public string VirtualScreen
  694. 		{
  695. 			get { return String.Format( "{{X={0},Y={1},Width={2},Height={3}}}", System.Windows.Forms.SystemInformation.VirtualScreen.X, System.Windows.Forms.SystemInformation.VirtualScreen.Y, System.Windows.Forms.SystemInformation.VirtualScreen.Width, System.Windows.Forms.SystemInformation.VirtualScreen.Height ); }
  696. 		}
  697.  
  698. 		[ComVisible( true )]
  699. 		public string WorkingArea
  700. 		{
  701. 			get { return String.Format( "{{X={0},Y={1},Width={2},Height={3}}}", System.Windows.Forms.SystemInformation.WorkingArea.X, System.Windows.Forms.SystemInformation.WorkingArea.Y, System.Windows.Forms.SystemInformation.WorkingArea.Width, System.Windows.Forms.SystemInformation.WorkingArea.Height ); }
  702. 		}
  703.  
  704. 		static string GetPowerStatus( )
  705. 		{
  706. 			string powerstatus = String.Empty;
  707. 			object propval = typeof( SystemInformation ).GetProperty( "PowerStatus" ).GetValue( typeof( SystemInformation ), null );
  708. 			string bcs = typeof( PowerStatus ).GetProperty( "BatteryChargeStatus" ).GetValue( propval, null ).ToString( );
  709. 			string bfl = typeof( PowerStatus ).GetProperty( "BatteryFullLifetime" ).GetValue( propval, null ).ToString( );
  710. 			string blp = ( Convert.ToInt32( typeof( PowerStatus ).GetProperty( "BatteryLifePercent" ).GetValue( propval, null ) ) * 100 ).ToString( ) + "%";
  711. 			string blr = typeof( PowerStatus ).GetProperty( "BatteryLifeRemaining" ).GetValue( propval, null ).ToString( );
  712. 			string pls = typeof( PowerStatus ).GetProperty( "PowerLineStatus" ).GetValue( propval, null ).ToString( );
  713. 			powerstatus = String.Format( "{{BatteryChargeStatus={0}", bcs );
  714. 			powerstatus += String.Format( ",BatteryFullLifetime={0}", ( bfl == "-1" ? "Unknown" : bfl ) );
  715. 			powerstatus += String.Format( ",BatteryLifePercent={0}", blp );
  716. 			powerstatus += String.Format( ",BatteryLifeRemaining={0}", ( blr == "-1" ? "Unknown" : blr ) );
  717. 			powerstatus += String.Format( ",PowerLineStatus={0}}}", pls );
  718. 			return powerstatus;
  719. 		}
  720. 	}
  721. }
  722.  

page last modified: 2024-02-26; loaded in 0.0333 seconds