当前位置: 首页>>代码示例>>C#>>正文


C# IntPtr.ToStructure方法代码示例

本文整理汇总了C#中System.IntPtr.ToStructure方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.ToStructure方法的具体用法?C# IntPtr.ToStructure怎么用?C# IntPtr.ToStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IntPtr的用法示例。


在下文中一共展示了IntPtr.ToStructure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VolumeGetVolumeDiskExtents

        /// <summary>
        /// <see cref="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365194(v=vs.85).aspx" />
        /// </summary>
        public VOLUME_DISK_EXTENTS VolumeGetVolumeDiskExtents()
        {
            // Fetch in increments of 32 bytes, as one extent (the most common case) is one extent pr. volume.
            byte[] data = DeviceIoControlHelper.InvokeIoControlUnknownSize(Handle, IOControlCode.VolumeGetVolumeDiskExtents, 32);

            // Build the VOLUME_DISK_EXTENTS structure
            VOLUME_DISK_EXTENTS res = new VOLUME_DISK_EXTENTS();

            res.NumberOfDiskExtents = BitConverter.ToUInt32(data, 0);
            res.Extents = new DISK_EXTENT[res.NumberOfDiskExtents];

            using (UnmanagedMemory dataPtr = new UnmanagedMemory(data))
            {
                // TODO: This code needs to be tested for volumes with more than one extent.
                for (int i = 0; i < res.NumberOfDiskExtents; i++)
                {
                    IntPtr currentDataPtr = new IntPtr(dataPtr.Handle.ToInt64() + 8 + i * MarshalHelper.SizeOf<DISK_EXTENT>());
                    DISK_EXTENT extent = currentDataPtr.ToStructure<DISK_EXTENT>();

                    res.Extents[i] = extent;
                }
            }

            return res;
        }
开发者ID:LordMike,项目名称:DeviceIOControlLib,代码行数:28,代码来源:VolumeDeviceWrapper.cs

示例2: ComFunctionInfo

        public ComFunctionInfo(ComTypeInfo parent, IntPtr pFuncDesc)
            : base(parent)
        {
            _pFuncDesc = pFuncDesc;
            _funcDesc = pFuncDesc.ToStructure < System.Runtime.InteropServices.ComTypes.FUNCDESC>();
            _comTypeInfo.GetITypeInfo().GetDocumentation(_funcDesc.memid, out _name, out _description, out _helpContext, out _helpFile);

            if (_description == null) _description = String.Empty;
            if (_helpFile == null) _helpFile = String.Empty;

            LoadParameters();
        }
开发者ID:JWSingleton,项目名称:SolidEdgeSpy,代码行数:12,代码来源:ComMemberInfo.cs

示例3: DiskGetDriveGeometryEx

        /// <summary><see cref="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365171(v=vs.85).aspx"/></summary>
        public DISK_GEOMETRY_EX DiskGetDriveGeometryEx()
        {
            byte[] data = DeviceIoControlHelper.InvokeIoControlUnknownSize(Handle, IOControlCode.DiskGetDriveGeometryEx, 256);

            DISK_GEOMETRY_EX res;

            using (UnmanagedMemory mem = new UnmanagedMemory(data))
            {
                res.Geometry = mem.Handle.ToStructure<DISK_GEOMETRY>();
                res.DiskSize = BitConverter.ToInt64(data, (int)MarshalHelper.SizeOf<DISK_GEOMETRY>());

                IntPtr tmpPtr = new IntPtr(mem.Handle.ToInt64() + MarshalHelper.SizeOf<DISK_GEOMETRY>() + sizeof(long));
                res.PartitionInformation = tmpPtr.ToStructure<DISK_PARTITION_INFO>();

                tmpPtr = new IntPtr(tmpPtr.ToInt64() + res.PartitionInformation.SizeOfPartitionInfo);
                res.DiskInt13Info = tmpPtr.ToStructure<DISK_EX_INT13_INFO>();
            }

            return res;
        }
开发者ID:LordMike,项目名称:DeviceIOControlLib,代码行数:21,代码来源:DiskDeviceWrapper.cs

示例4: ComTypeInfo

 public ComTypeInfo(ComTypeLibrary comTypeLibrary, ITypeInfo typeInfo, IntPtr pTypeAttr)
 {
     _comTypeLibrary = comTypeLibrary;
     _typeInfo = typeInfo;
     _pTypeAttr = pTypeAttr;
     _typeAttr = _pTypeAttr.ToStructure<System.Runtime.InteropServices.ComTypes.TYPEATTR>();
     _typeInfo.GetDocumentation(-1, out _name, out _description, out _helpContext, out _helpFile);
 }
开发者ID:JWSingleton,项目名称:SolidEdgeSpy,代码行数:8,代码来源:ComTypeInfo.cs


注:本文中的System.IntPtr.ToStructure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。