コード例 #1
0
    /// <summary>Gets a byte array with the "VERS" resource contained by this instance.</summary>
    /// <returns>The "VERS" resource.</returns>
    public byte[] GetBytes()
    {
        byte[] tmpShort = BitConverter.GetBytes(RegionCode).Reverse().ToArray();
        byte[] tmpStr   = PascalString.GetBytes(VersionString);
        byte[] tmpMsg   = PascalString.GetBytes(VersionMessage);
        byte[] vers     = new byte[6 + tmpStr.Length + tmpMsg.Length];

        vers[0] = NumberToBCD(MajorVersion);
        vers[1] = NumberToBCD(MinorVersion);
        vers[2] = (byte)DevStage;
        vers[3] = NumberToBCD(PreReleaseVersion);
        Array.Copy(tmpShort, 0, vers, 4, 2);
        Array.Copy(tmpStr, 0, vers, 6, tmpStr.Length);
        Array.Copy(tmpMsg, 0, vers, 6 + tmpStr.Length, tmpMsg.Length);

        return(vers);
    }
コード例 #2
0
    /// <summary>Initializes a new instance of the <see cref="T:Resources.Version" /> class.</summary>
    /// <param name="resource">Byte array containing the "VERS" resource.</param>
    public Version(byte[] resource)
    {
        byte[] tmpShort = new byte[2];

        MajorVersion      = BCDToNumber(resource[0]);
        MinorVersion      = BCDToNumber(resource[1]);
        DevStage          = (DevelopmentStage)resource[2];
        PreReleaseVersion = BCDToNumber(resource[3]);
        Array.Copy(resource, 4, tmpShort, 0, 2);
        RegionCode = BitConverter.ToUInt16(tmpShort.Reverse().ToArray(), 0);
        byte[] tmpStr = new byte[resource[6] + 1];
        Array.Copy(resource, 6, tmpStr, 0, tmpStr.Length);
        VersionString = PascalString.GetString(tmpStr);
        byte[] tmpMsg = new byte[resource[6 + tmpStr.Length] + 1];
        Array.Copy(resource, 6 + tmpStr.Length, tmpMsg, 0, tmpMsg.Length);
        VersionMessage = PascalString.GetString(tmpMsg);
    }