private bool GetVersionInfoForCodePage(IntPtr memIntPtr, string codepage)
        {
            string format = @"\\StringFileInfo\\{0}\\{1}";

            this.companyName      = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "CompanyName" }));
            this.fileDescription  = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "FileDescription" }));
            this.fileVersion      = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "FileVersion" }));
            this.internalName     = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "InternalName" }));
            this.legalCopyright   = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "LegalCopyright" }));
            this.originalFilename = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "OriginalFilename" }));
            this.productName      = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "ProductName" }));
            this.productVersion   = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "ProductVersion" }));
            this.comments         = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "Comments" }));
            this.legalTrademarks  = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "LegalTrademarks" }));
            this.privateBuild     = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "PrivateBuild" }));
            this.specialBuild     = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "SpecialBuild" }));
            this.language         = GetFileVersionLanguage(memIntPtr);
            Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO fixedFileInfo = GetFixedFileInfo(memIntPtr);
            this.fileMajor      = HIWORD(fixedFileInfo.dwFileVersionMS);
            this.fileMinor      = LOWORD(fixedFileInfo.dwFileVersionMS);
            this.fileBuild      = HIWORD(fixedFileInfo.dwFileVersionLS);
            this.filePrivate    = LOWORD(fixedFileInfo.dwFileVersionLS);
            this.productMajor   = HIWORD(fixedFileInfo.dwProductVersionMS);
            this.productMinor   = LOWORD(fixedFileInfo.dwProductVersionMS);
            this.productBuild   = HIWORD(fixedFileInfo.dwProductVersionLS);
            this.productPrivate = LOWORD(fixedFileInfo.dwProductVersionLS);
            this.fileFlags      = fixedFileInfo.dwFileFlags;
            return(this.fileVersion != string.Empty);
        }
 private static Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO GetFixedFileInfo(IntPtr memPtr)
 {
     int num;
     IntPtr zero = IntPtr.Zero;
     if (Microsoft.Win32.UnsafeNativeMethods.VerQueryValue(new HandleRef(null, memPtr), @"\", ref zero, out num))
     {
         Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO structure = new Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO();
         Marshal.PtrToStructure(zero, structure);
         return structure;
     }
     return new Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO();
 }
        private static Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO GetFixedFileInfo(IntPtr memPtr)
        {
            int    num;
            IntPtr zero = IntPtr.Zero;

            if (Microsoft.Win32.UnsafeNativeMethods.VerQueryValue(new HandleRef(null, memPtr), @"\", ref zero, out num))
            {
                Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO structure = new Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO();
                Marshal.PtrToStructure(zero, structure);
                return(structure);
            }
            return(new Microsoft.Win32.NativeMethods.VS_FIXEDFILEINFO());
        }