FileVersionInfo.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. //
  2. // System.Diagnostics.FileVersionInfo.cs
  3. //
  4. // Authors:
  5. // Dick Porter ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc.
  8. //
  9. using System;
  10. using System.Runtime.CompilerServices;
  11. namespace System.Diagnostics {
  12. public sealed class FileVersionInfo {
  13. /* There is no public constructor for this class, it
  14. * is initialised by the runtime. All the private
  15. * variables here are looked up by name, so dont
  16. * change them without also changing the runtime
  17. */
  18. private string comments;
  19. private string companyname;
  20. private string filedescription;
  21. private string filename;
  22. private string fileversion;
  23. private string internalname;
  24. private string language;
  25. private string legalcopyright;
  26. private string legaltrademarks;
  27. private string originalfilename;
  28. private string privatebuild;
  29. private string productname;
  30. private string productversion;
  31. private string specialbuild;
  32. private bool isdebug;
  33. private bool ispatched;
  34. private bool isprerelease;
  35. private bool isprivatebuild;
  36. private bool isspecialbuild;
  37. private int filemajorpart;
  38. private int fileminorpart;
  39. private int filebuildpart;
  40. private int fileprivatepart;
  41. private int productmajorpart;
  42. private int productminorpart;
  43. private int productbuildpart;
  44. private int productprivatepart;
  45. private FileVersionInfo() {
  46. /* This is here just to shut the compiler up */
  47. comments=null;
  48. companyname=null;
  49. filedescription=null;
  50. filename=null;
  51. fileversion=null;
  52. internalname=null;
  53. language=null;
  54. legalcopyright=null;
  55. legaltrademarks=null;
  56. originalfilename=null;
  57. privatebuild=null;
  58. productname=null;
  59. productversion=null;
  60. specialbuild=null;
  61. isdebug=false;
  62. ispatched=false;
  63. isprerelease=false;
  64. isprivatebuild=false;
  65. isspecialbuild=false;
  66. filemajorpart=0;
  67. fileminorpart=0;
  68. filebuildpart=0;
  69. fileprivatepart=0;
  70. productmajorpart=0;
  71. productminorpart=0;
  72. productbuildpart=0;
  73. productprivatepart=0;
  74. }
  75. public string Comments {
  76. get {
  77. return(comments);
  78. }
  79. }
  80. public string CompanyName {
  81. get {
  82. return(companyname);
  83. }
  84. }
  85. public int FileBuildPart {
  86. get {
  87. return(filebuildpart);
  88. }
  89. }
  90. public string FileDescription {
  91. get {
  92. return(filedescription);
  93. }
  94. }
  95. public int FileMajorPart {
  96. get {
  97. return(filemajorpart);
  98. }
  99. }
  100. public int FileMinorPart {
  101. get {
  102. return(fileminorpart);
  103. }
  104. }
  105. public string FileName {
  106. get {
  107. return(filename);
  108. }
  109. }
  110. public int FilePrivatePart {
  111. get {
  112. return(fileprivatepart);
  113. }
  114. }
  115. public string FileVersion {
  116. get {
  117. return(fileversion);
  118. }
  119. }
  120. public string InternalName {
  121. get {
  122. return(internalname);
  123. }
  124. }
  125. public bool IsDebug {
  126. get {
  127. return(isdebug);
  128. }
  129. }
  130. public bool IsPatched {
  131. get {
  132. return(ispatched);
  133. }
  134. }
  135. public bool IsPreRelease {
  136. get {
  137. return(isprerelease);
  138. }
  139. }
  140. public bool IsPrivateBuild {
  141. get {
  142. return(isprivatebuild);
  143. }
  144. }
  145. public bool IsSpecialBuild {
  146. get {
  147. return(isspecialbuild);
  148. }
  149. }
  150. public string Language {
  151. get {
  152. return(language);
  153. }
  154. }
  155. public string LegalCopyright {
  156. get {
  157. return(legalcopyright);
  158. }
  159. }
  160. public string LegalTrademarks {
  161. get {
  162. return(legaltrademarks);
  163. }
  164. }
  165. public string OriginalFilename {
  166. get {
  167. return(originalfilename);
  168. }
  169. }
  170. public string PrivateBuild {
  171. get {
  172. return(privatebuild);
  173. }
  174. }
  175. public int ProductBuildPart {
  176. get {
  177. return(productbuildpart);
  178. }
  179. }
  180. public int ProductMajorPart {
  181. get {
  182. return(productmajorpart);
  183. }
  184. }
  185. public int ProductMinorPart {
  186. get {
  187. return(productminorpart);
  188. }
  189. }
  190. public string ProductName {
  191. get {
  192. return(productname);
  193. }
  194. }
  195. public int ProductPrivatePart {
  196. get {
  197. return(productprivatepart);
  198. }
  199. }
  200. public string ProductVersion {
  201. get {
  202. return(productversion);
  203. }
  204. }
  205. public string SpecialBuild {
  206. get {
  207. return(specialbuild);
  208. }
  209. }
  210. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  211. private extern void GetVersionInfo_internal(string fileName);
  212. public static FileVersionInfo GetVersionInfo(string fileName) {
  213. FileVersionInfo fvi=new FileVersionInfo();
  214. fvi.GetVersionInfo_internal(fileName);
  215. return(fvi);
  216. }
  217. public override string ToString() {
  218. string str;
  219. str="File: " + filename + "\n";
  220. str+="InternalName: " + internalname + "\n";
  221. str+="OriginalFilename: " + originalfilename + "\n";
  222. str+="FileVersion: " + fileversion + "\n";
  223. str+="FileDescription: " + filedescription + "\n";
  224. str+="Product: " + productname + "\n";
  225. str+="ProductVersion: " + productversion + "\n";
  226. str+="Debug: " + isdebug + "\n";
  227. str+="Patched: " + ispatched + "\n";
  228. str+="PreRelease: " + isprerelease + "\n";
  229. str+="PrivateBuild: " + isprivatebuild + "\n";
  230. str+="SpecialBuild: " + isspecialbuild + "\n";
  231. str+="Language " + language + "\n";
  232. return(str);
  233. }
  234. }
  235. }