2004-04-01 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / class / corlib / System.Resources / Win32Resources.cs
index f627fc1ad05a96e5a11129d5a9ad587a848ea86d..86ac91517fa5a211bb363a9360714216e9c5a863 100644 (file)
@@ -233,6 +233,9 @@ internal class Win32VersionResource : Win32Resource {
        int file_subtype;
        long file_date;
 
+       int file_lang;
+       int file_codepage;
+
        Hashtable properties;
 
        public Win32VersionResource (int id, int language) : base (Win32ResourceType.RT_VERSION, id, language) {
@@ -247,6 +250,9 @@ internal class Win32VersionResource : Win32Resource {
                file_subtype = 0;
                file_date = 0;
 
+               file_lang = 0x7f;
+               file_codepage = 1200;
+
                properties = new Hashtable ();
 
                // Well known properties
@@ -265,7 +271,7 @@ internal class Win32VersionResource : Win32Resource {
                }
 
                set {
-                       int[] ver = new int [4] { 0, 0, 0, 0 };
+                       long[] ver = new long [4] { 0, 0, 0, 0 };
                        if (value != null) {
                                string[] parts = value.Split ('.');
                                
@@ -354,6 +360,33 @@ internal class Win32VersionResource : Win32Resource {
                }
        }
 
+       public virtual string InternalName {
+               get {
+                       return (string)properties ["InternalName"];
+               }
+               set {
+                       properties ["InternalName"] = value == String.Empty ? " " : value;
+               }
+       }
+
+       public virtual string FileDescription {
+               get {
+                       return (string)properties ["FileDescription"];
+               }
+               set {
+                       properties ["FileDescription"] = value == String.Empty ? " " : value;
+               }
+       }
+
+       public virtual int FileLanguage {
+               get {
+                       return file_lang;
+               }
+               set {
+                       file_lang = value;
+               }
+       }
+
        private void emit_padding (BinaryWriter w) {
                Stream ms = w.BaseStream;
 
@@ -373,9 +406,6 @@ internal class Win32VersionResource : Win32Resource {
        public override void WriteTo (Stream ms)
        {
                using (BinaryWriter w = new BinaryWriter (ms, Encoding.Unicode)) {
-                       short len;
-                       long pos;
-
                        //
                        // See the documentation for the VS_VERSIONINFO structure and
                        // its children on MSDN
@@ -430,8 +460,8 @@ internal class Win32VersionResource : Win32Resource {
                        if ((ms.Position % 4) != 0)
                                w.Write ((short)0);
 
-                       w.Write ((short)0x7f);
-                       w.Write ((short)1200);
+                       w.Write ((short)file_lang);
+                       w.Write ((short)file_codepage);
 
                        patch_length (w, var_pos);
 
@@ -451,7 +481,7 @@ internal class Win32VersionResource : Win32Resource {
                        w.Write ((short)0);
                        w.Write ((short)0);
                        w.Write ((short)1);
-                       w.Write ("007f04b0".ToCharArray ());
+                       w.Write (String.Format ("{0:x4}{1:x4}", file_lang, file_codepage).ToCharArray ());
 
                        emit_padding (w);
 
@@ -471,6 +501,8 @@ internal class Win32VersionResource : Win32Resource {
                                w.Write (value.ToCharArray ());
                                w.Write ((short)0);
 
+                               emit_padding (w);
+
                                patch_length (w, string_pos);
                        }