コード例 #1
0
        /// <summary>
        /// Convert the DRS_EXTENSIONS to DRS_EXTENSIONS_INT
        /// </summary>
        /// <param name="extensions">the general struct of DRS_EXTENSIONS</param>
        /// <returns>the struct of DRS_EXTENSIONS_INT</returns>
        public static DRS_EXTENSIONS_INT DecodeDrsExtensions(DRS_EXTENSIONS extensions)
        {
            //Size of extensions.cb
            int sizeOfCbField = sizeof(uint);

            byte[] extensionsIntBytes = new byte[Marshal.SizeOf(new DRS_EXTENSIONS_INT())];
            Buffer.BlockCopy(TypeMarshal.ToBytes <uint>(extensions.cb), 0, extensionsIntBytes, 0, sizeOfCbField);
            Buffer.BlockCopy(extensions.rgb, 0, extensionsIntBytes, sizeOfCbField, extensions.rgb.Length);
            return(TypeMarshal.ToStruct <DRS_EXTENSIONS_INT>(extensionsIntBytes));
        }
コード例 #2
0
        /// <summary>
        /// Convert the DRS_EXTENSIONS_INT to DRS_EXTENSIONS
        /// </summary>
        /// <param name="extensions">the struct of DRS_EXTENSIONS</param>
        /// <returns>the general struct of DRS_EXTENSIONS_INT</returns>
        public static DRS_EXTENSIONS EncodeDrsExtensions(DRS_EXTENSIONS_INT extensions)
        {
            byte[]         extensionsBytes = TypeMarshal.ToBytes <DRS_EXTENSIONS_INT>(extensions);
            DRS_EXTENSIONS drsExtensions   = new DRS_EXTENSIONS();

            drsExtensions.cb  = extensions.cb;
            drsExtensions.rgb = new byte[drsExtensions.cb];
            Buffer.BlockCopy(extensionsBytes, Marshal.SizeOf(drsExtensions.cb),
                             drsExtensions.rgb, 0, drsExtensions.rgb.Length);
            return(drsExtensions);
        }