国产精品久久久久久久久久久新郎_91久久精品国产_国内精品久久久久久_欧美激情第一页在线观看_国产欧美日韩丝袜精品一区_日韩精品成人一区二区在线观看_国产精品v片在线观看不卡_91精品国产综合久久香蕉最新版 _国产精品亚洲激情_色综合男人天堂

始創于2000年 股票代碼:831685
咨詢熱線:0371-60135900 注冊有禮 登錄
  • 掛牌上市企業
  • 60秒人工響應
  • 99.99%連通率
  • 7*24h人工
  • 故障100倍補償
您的位置: 網站首頁 > 幫助中心>文章內容

windows的磁盤操作之一——基本概念 (1)

發布時間:  2012/9/11 19:38:46

  最近項目中需要在windows系統下與磁盤打交道,用了一個禮拜時間,弄懂了一些基本的概念,記錄于此,并以項目中的部分代碼作為范例。
  首先說明一點,本文中使用的不是cmd命令行,基于以下幾點原因:
  1.在C/C++中調用系統命令會存在處理的種種不方便,需要大量額外的代碼去分析命令執行結果。
  2.windows命令行遠不如linux的shell來的強大。
  3.效率。
  當然,如果不考慮編碼,僅作為系統下一種應用工具的話,DiskPart是既安全又便利的選擇。
  我們先來看幾個主要的使用頻繁的函數。
  在windows下與磁盤打交道最主要的API就是DeviceIoControl了,以下是從MSDN中直接拷貝出來的對該函數的說明。此函數確實太重要也太強大了,建議大家耐著性子先將它的說明看完,當然,本文后續例子中會大量用到此函數,可隨時返回此節參閱。
  DeviceIoControl Function
  Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
  BOOL WINAPI DeviceIoControl(
  __in          HANDLE hDevice,
  __in          DWORD dwIoControlCode,
  __in          LPVOID lpInBuffer,
  __in          DWORD nInBufferSize,
  __out         LPVOID lpOutBuffer,
  __in          DWORD nOutBufferSize,
  __out         LPDWORD lpBytesReturned,
  __in          LPOVERLAPPED lpOverlapped
  );
  Parameters
  hDevice
  A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device handle, use the CreateFile function. For more information, see Remarks.
  dwIoControlCode
  The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
  For a list of the control codes, see Remarks. The documentation for each control code provides usage details for the lpInBuffer, nInBufferSize, lpOutBuffer, and nOutBufferSize parameters.
  lpInBuffer
  A pointer to the input buffer that contains the data required to perform the operation. The format of this data depends on the value of the dwIoControlCode parameter.
  This parameter can be NULL if dwIoControlCode specifies an operation that does not require input data.
  nInBufferSize
  The size of the input buffer, in bytes.
  lpOutBuffer
  A pointer to the output buffer that is to receive the data returned by the operation. The format of this data depends on the value of the dwIoControlCode parameter.
  This parameter can be NULL if dwIoControlCode specifies an operation that does not return data.
  nOutBufferSize
  The size of the output buffer, in bytes.
  lpBytesReturned
  A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.
  If the output buffer is too small to receive any data, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.
  If the output buffer is too small to hold all of the data but can hold some entries, some drivers will return as much data as fits. In this case, the call fails, GetLastError returns ERROR_MORE_DATA, and lpBytesReturned indicates the amount of data received. Your application should call DeviceIoControl again with the same operation, specifying a new starting point.
  If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.
  If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.
  lpOverlapped
  A pointer to an OVERLAPPED structure.
  If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.
  If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.
  For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been completed. Otherwise, the function does not return until the operation has been completed or an error occurs.
  Return Value
  If the operation completes successfully, the return value is nonzero.
  If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError.
  Remarks
  To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with a device. To specify a device name, use the following format:
  \\.\DeviceName
  DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the physical drives on a system.
  You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when opening a device handle:
  ·         The fdwCreate parameter must specify OPEN_EXISTING.
  ·         The hTemplateFile parameter must be NULL.
  ·         The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.
  Requirements
  Client
  Requires Windows Vista, Windows XP, Windows 2000 Professional, or Windows NT Workstation.
  Server
  Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server.
  Header
  Declared in Winbase.h; include Windows.h.
  Library
  Use Kernel32.lib.
  DLL
  Requires Kernel32.dll.
  該函數實現對設備的訪問,包括獲取信息,發送命令,交換數據等。可以利用該接口函數向指定的設備驅動發送正確的控制碼及數據,分析它的響應,執行程序設計人員想要的功能。磁盤操作只是它強大功能中的一小部分。
  該函數最重要的兩個參數是hDevice和dwIoControlCode.
  控制碼dwIoControlCode決定了操作類型,與磁盤相關的控制碼有
  IOCTL_DISK_CREATE_DISK    利用CREATE_DISK結構中的信息對指定磁盤和磁盤分區進行初始化。
  IOCTL_DISK_DELETE_DRIVE_LAYOUT    從主引導記錄中刪除引導信息,所以磁盤將會被從頭到尾的格式化。扇區0中的分區信息也就不復存在了。
  IOCTL_DISK_FORMAT_TRACKS    格式化指定的、連續的軟盤磁道。如果需要更多的功能請使用IOCTL_DISK_FORMAT_TRACKS_EX。
  IOCTL_DISK_FORMAT_TRACKS_EX    格式化指定的、連續的軟盤磁道。
  IOCTL_DISK_GET_CACHE_INFORMATION    返回磁盤的高速緩存配置數據
  IOCTL_DISK_GET_DRIVE_GEOMETRY_EX    返回物理磁盤的擴展信息。包括:類型、柱面數量、每柱面磁道數、每磁道扇區數和每扇區字節數等。
  IOCTL_DISK_GET_DRIVE_LAYOUT_EX    返回各分區的擴展信息以及這些分區的特性。更多信息請參照DRIVE_LAYOUT_INFORMATION_EX結構。
  IOCTL_DISK_GET_LENGTH_INFO    返回指定磁盤/卷/分區的大小信息
  IOCTL_DISK_GET_PARTITION_INFO_EX    返回指定分區的擴展信息。包括:分區類型、大小和種類。更多信息請參照PARTITION_INFORMATION_EX結構。
  IOCTL_DISK_GROW_PARTITION    擴大指定分區。
  IOCTL_DISK_IS_WRITABLE    確定指定磁盤是否可寫。
  IOCTL_DISK_PERFORMANCE    啟用并獲取磁盤性能統計
  IOCTL_DISK_PERFORMANCE_OFF    關閉磁盤性能統計
  IOCTL_DISK_REASSIGN_BLOCKS    使磁盤設備影射一塊區域做為它的備用存儲塊公用池(spare block pool)。
  IOCTL_DISK_SET_CACHE_INFORMATION    設置磁盤的配置信息
  IOCTL_DISK_SET_DRIVE_LAYOUT_EX    根據給定的磁盤信息對磁盤進行分區。
  IOCTL_DISK_SET_PARTITION_INFO_EX    設置指定分區的分區信息。包括AT和EFI (Extensible Firmware Interface)分區的布局信息。
  IOCTL_DISK_UPDATE_PROPERTIES    使緩沖的分區表無效并重新獲取一份。
  IOCTL_DISK_VERIFY    對指定磁盤進行邏輯格式化
  另一個參數hDevice指向要操作的設備句柄,調用函數CreateFile獲得。CreateFile函數原型為
  HANDLE WINAPI CreateFile(
  __in          LPCTSTR lpFileName,
  __in          DWORD dwDesiredAccess,
  __in          DWORD dwShareMode,
  __in          LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  __in          DWORD dwCreationDisposition,
  __in      

億恩科技地址(ADD):鄭州市黃河路129號天一大廈608室 郵編(ZIP):450008 傳真(FAX):0371-60123888
   聯系:億恩小凡
   QQ:89317007
   電話:0371-63322206


本文出自:億恩科技【m.czbl888.cn】

服務器租用/服務器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質保障!--億恩科技[ENKJ.COM]

  • 您可能在找
  • 億恩北京公司:
  • 經營性ICP/ISP證:京B2-20150015
  • 億恩鄭州公司:
  • 經營性ICP/ISP/IDC證:豫B1.B2-20060070
  • 億恩南昌公司:
  • 經營性ICP/ISP證:贛B2-20080012
  • 服務器/云主機 24小時售后服務電話:0371-60135900
  • 虛擬主機/智能建站 24小時售后服務電話:0371-60135900
  • 專注服務器托管17年
    掃掃關注-微信公眾號
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 億恩科技 版權所有  地址:鄭州市高新區翠竹街1號總部企業基地億恩大廈  法律顧問:河南亞太人律師事務所郝建鋒、杜慧月律師   京公網安備41019702002023號
      0
     
     
     
     

    0371-60135900
    7*24小時客服服務熱線

     
     
    国产精品久久久久久久久久久新郎_91久久精品国产_国内精品久久久久久_欧美激情第一页在线观看_国产欧美日韩丝袜精品一区_日韩精品成人一区二区在线观看_国产精品v片在线观看不卡_91精品国产综合久久香蕉最新版 _国产精品亚洲激情_色综合男人天堂
    日韩手机在线观看视频| 狠狠噜天天噜日日噜| 午夜免费看视频| 日本黄色福利视频| 精品国产av无码一区二区三区| 免费国产黄色网址| caoporm在线视频| 欧美 国产 精品| 99视频免费播放| 91动漫在线看| 中文字幕免费高| 两根大肉大捧一进一出好爽视频| www.国产福利| 亚洲成熟丰满熟妇高潮xxxxx| 香蕉精品视频在线| 日日噜噜夜夜狠狠| 男人的天堂狠狠干| 国内外成人激情免费视频| 欧美成人黄色网址| 欧美国产亚洲一区| 免费一级淫片aaa片毛片a级| 婷婷中文字幕在线观看| caoporn超碰97| 成人在线观看你懂的| 日韩中文字幕在线不卡| 污视频网址在线观看| 不要播放器的av网站| 国产精品自拍合集| 小说区视频区图片区| 天美星空大象mv在线观看视频| 日韩欧美不卡在线| 国产欧美自拍视频| 肉色超薄丝袜脚交| 99re精彩视频| 色悠悠久久综合网| 中文字幕无码不卡免费视频| 国产原创中文在线观看 | 国产日韩欧美大片| 久久久福利影院| 涩涩网站在线看| 日本中文字幕二区| 91激情视频在线| 亚洲 中文字幕 日韩 无码| 国产成人黄色片| 日韩精品―中文字幕| 日日摸天天爽天天爽视频| 亚洲成色www.777999| 亚洲高清视频免费| 国产尤物av一区二区三区| 欧美网站免费观看| 中文字幕网av| 福利在线小视频| ww国产内射精品后入国产| 日本激情视频在线| 自拍一级黄色片| 国产二区视频在线| 天天爽天天爽夜夜爽| 中文字幕av久久| 精品欧美一区免费观看α√| 最新中文字幕免费视频| 国产麻豆电影在线观看| 欧美网站免费观看| 欧美xxxxxbbbbb| 日韩欧美一区二| 999久久久精品视频| 欧美日韩不卡在线视频| 免费看a级黄色片| 最新黄色av网站| 激情婷婷综合网| 日韩中文字幕在线不卡| 成人黄色一区二区| 黄色三级中文字幕| 亚洲欧美国产中文| 欧美午夜性视频| 午夜av中文字幕| 国产亚洲天堂网| 99视频精品全部免费看 | 在线免费av播放| 日本大片免费看| 一区二区三区 欧美| av片在线免费| 香蕉视频999| 日日橹狠狠爱欧美超碰| 99精品一级欧美片免费播放| 99视频精品免费| 91丨porny丨探花| 亚洲天堂av一区二区三区| 久久精品.com| 日本男女交配视频| www,av在线| 欧美一级裸体视频| 欧美黑人经典片免费观看| 国产精品美女在线播放| 国产一级特黄a大片免费| 97在线国产视频| 免费观看中文字幕| 日本黄色的视频| 亚洲精品一二三四五区| 国产素人在线观看| 欧美视频在线第一页| 伊人国产精品视频| 婷婷免费在线观看| 免费看a级黄色片| 黄色免费观看视频网站| 国产精品一线二线三线| 精品久久久无码人妻字幂| 加勒比av中文字幕| 亚洲视频在线a| 日韩免费毛片视频| 五十路熟女丰满大屁股| 免费在线看黄色片| 成人手机在线播放| 免费国产成人看片在线| 手机在线观看日韩av| 毛片毛片毛片毛| 伊人色在线观看| 在线观看国产福利| 女同激情久久av久久| gogogo高清免费观看在线视频| 精品久久久久久中文字幕2017| 六月丁香婷婷在线| 国产亚洲天堂网| 热久久精品国产| 无码日韩人妻精品久久蜜桃| 人妻丰满熟妇av无码区app| 免费无码av片在线观看| 国产超级av在线| av片中文字幕| 天天操天天摸天天爽| 蜜桃免费在线视频| 成人性生交免费看| 亚洲免费黄色录像| 国产奶头好大揉着好爽视频| aaaaaaaa毛片| www.69av| 自拍日韩亚洲一区在线| 久久精品免费一区二区| www.com毛片| 亚洲欧美另类动漫| 色噜噜狠狠一区二区三区狼国成人| 日本中文字幕精品—区二区| 99精品999| 小泽玛利亚av在线| 午夜免费福利小电影| 日本福利视频在线| 日本女优爱爱视频| 欧美一级xxxx| 日本一区二区免费高清视频| 成人黄色片免费| 欧美日韩成人免费视频| 男人透女人免费视频| 亚洲视频第二页| 亚洲小视频在线播放| 777av视频| 91淫黄看大片| 天堂在线精品视频| 大荫蒂性生交片| 日韩欧美视频网站| 亚洲综合av在线播放| 久久久久久综合网| 国产一级不卡视频| 欧美网站免费观看| 性猛交ⅹ×××乱大交| 三年中文高清在线观看第6集| 久艹在线免费观看| 国产美女三级视频| 亚洲综合激情五月| 99精品人妻少妇一区二区| 手机av在线网| 农民人伦一区二区三区| 亚洲一区二区三区四区五区xx| 欧美精品色视频| 国产精品自拍片| 亚洲天堂2018av| 日韩一级性生活片| 91视频这里只有精品| 97在线国产视频| 男人的天堂最新网址| 一本久道高清无码视频| 在线观看岛国av| 国产女大学生av| 一级黄色免费在线观看| 91传媒久久久| 三上悠亚免费在线观看| 黄色av免费在线播放| 国产av熟女一区二区三区 | 欧美国产在线一区| av之家在线观看| www.五月天色| 男人天堂999| 久久久久久久久网| 黄色片在线免费| 久久精品无码中文字幕| 亚洲免费一级视频| 久久成人免费观看| 国产成人免费高清视频| 国产精品区在线| aaa毛片在线观看| 亚洲爆乳无码精品aaa片蜜桃| 日日噜噜夜夜狠狠|