ProcessStartInfo.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // System.Diagnostics.ProcessStartInfo.cs
  3. //
  4. // Authors:
  5. // Dick Porter ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2002 Ximian, Inc. http://www.ximian.com
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using Microsoft.Win32;
  31. using System.Collections;
  32. using System.Collections.ObjectModel;
  33. using System.Collections.Specialized;
  34. using System.ComponentModel;
  35. using System.IO;
  36. using System.Security;
  37. using System.Security.Permissions;
  38. using System.Text;
  39. using System.Runtime.InteropServices;
  40. namespace System.Diagnostics
  41. {
  42. [StructLayout (LayoutKind.Sequential)]
  43. public sealed partial class ProcessStartInfo
  44. {
  45. internal bool HaveEnvVars {
  46. get { return (environmentVariables != null); }
  47. }
  48. Collection<string> _argumentList;
  49. public Collection<string> ArgumentList {
  50. get {
  51. if (_argumentList == null) {
  52. _argumentList = new Collection<string>();
  53. }
  54. return _argumentList;
  55. }
  56. }
  57. public Encoding StandardInputEncoding { get; set; }
  58. static readonly string [] empty = new string [0];
  59. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
  60. public string[] Verbs {
  61. get {
  62. #if MOBILE
  63. return empty;
  64. #else
  65. switch (System.Environment.OSVersion.Platform) {
  66. case (PlatformID)4:
  67. case (PlatformID)6:
  68. case (PlatformID)128:
  69. return empty; // no verb on non-Windows
  70. default:
  71. string ext = String.IsNullOrEmpty (fileName) ? null : Path.GetExtension (fileName);
  72. if (ext == null)
  73. return empty;
  74. RegistryKey rk = null, rk2 = null, rk3 = null;
  75. try {
  76. rk = Registry.ClassesRoot.OpenSubKey (ext);
  77. string k = rk != null ? rk.GetValue (null) as string : null;
  78. rk2 = k != null ? Registry.ClassesRoot.OpenSubKey (k) : null;
  79. rk3 = rk2 != null ? rk2.OpenSubKey ("shell") : null;
  80. return rk3 != null ? rk3.GetSubKeyNames () : null;
  81. } finally {
  82. if (rk3 != null)
  83. rk3.Close ();
  84. if (rk2 != null)
  85. rk2.Close ();
  86. if (rk != null)
  87. rk.Close ();
  88. }
  89. }
  90. #endif
  91. }
  92. }
  93. }
  94. }