青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

CreateFile函數祥解

CreateFile函數祥解2006-9-18 18:48:00
CreateFile

The CreateFile function creates or opens the following objects and returns a handle that can be used to access
the object:
 files
 pipes
 mailslots
 communications resources
 disk devices(Windows NT only)
 consoles
 directories(open only)

CreateFile函數創建或打開下列對象,并返回一個可以用來訪問這些對象的句柄。
 文件
 pipes
 郵槽
 通信資源
 磁盤驅動器(僅適用于windowsNT)
 控制臺
 文件夾(僅用于打開)

HANDLE CreateFile(
 LPCTSTR lpFileName,    //指向文件名的指針
 DWORD dwDesiredAccess,    //訪問模式(寫/讀)
 DWORD dwShareMode,    //共享模式
 LPSECURITY_ATTRIBUTES lpSecurityAttributes, //指向安全屬性的指針
 DWORD dwCreationDisposition,   //如何創建
 DWORD dwFlagsAndAttributes,   //文件屬性
 HANDLE hTemplateFile    //用于復制文件句柄
);

Parametes
參數列表

lpFileName
 Pointer to a null-terminated string that specifies the name of the object(file, pipe, mailslot,
 communications resource, disk device, console, or directory) to create or open.
 指向一個空結尾字符串。該參數指定了用于創建或打開句柄的對象。

 if *lpFileName is a path, there is a default string size limit of MAX_PATH characters, This limit is
 related to how the CreateFile function parses paths.
 如果lpFileName的對象是一個路徑,則有一個最大字符數的限制。不能超過常量(MAX_PATH).這個限制指示了
 CreateFile函數如何解析路徑.

dwDesiredAccess
 Specifies the type of access to the object. An application can obtain read access, write access,
 read-write access, or device query access, This parameter can be any combination of the following
 values
 指定對象的訪問方式,程序可以獲得讀訪問權,寫訪問權,讀寫訪問權或者是詢問設備("device query") 訪問權.
 這個參數可以是下列值的任意組合
 
 Value(值)  Meaning(含義)
 0   Specifies device query access to the object. An application can query device
    attributes without accessing the device.
    指定詢問訪問權.程序可以在不直接訪問設備的情況下查詢設備的屬性.

 GENERIC_READ  Specifies read access to the object, Data can be read from the file and the
    file pointer can be moved. Combine with GENERIC_WRITE for read-write access.
    指定讀訪問權.可以從文件中讀取數據,并且移動文件指針.可以和GENERIC_WRITE組合
    成為"讀寫訪問權".

 GENERIC_WRITE  specifies write access to the object. Data can be written to the file and the
    file pointer can be moved. Combine with GENERIC_READ fro read-write access
    指定寫訪問權.可以從文件中寫入數據,并且移動文件指針.可以和GENERIC_READ組合
    成為"讀寫訪問權".

dwShareMode
 Set of bit flags that specifies how the object can be shared, If dwShareMode is 0, the object cannot
 be shared. Subsequent open operations on the object will fail, until the handle is closed.
 設置位標志指明對象如休共享.如果參數是0, 對象不能夠共享. 后續的打開對象的操作將會失敗,直到該對象的句
 柄關閉.

 To share the object, use a combination of one or more of the following values:
 使用一個或多個下列值的組合來共享一個對象.
 Value(值)  Meaning(含義)
 FILE_SHARE_DELETE WindowsNT: Subsequent open operations on the object will succeed only if
    delete access is requested.
    WINDOWS NT:后續的僅僅請求刪除訪問權的打開操作將會成功.

 FILE_SHARE_READ  Subsequent open operations on the object will successd only if read access
    is requested.
    后續的僅僅請求讀訪問權的打開操作將會成功.

 FILE_SHARE_WRITE Subsequent open operations on the object will succeed only if write access
    is requested.
    后續的僅僅請求寫訪問權的打開操作將會成功.

lpSecurityAttributes
 pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be
 inherited by child processes, if lpSecurityAttributes is NULL, the handle cannot be inherited.
 指向一個 SECURITY_ATTRIBUTES 結構的指針用于確定如何在子進程中繼承這個句柄.如果這個參數是NULL,
 則該句柄不可繼承.

dwCreationDisposition
 Specifies which action to take on files that exist, and which action to take when files do not exist.
 For more information about this parameter, see the remarks section. This parameter must be one of the
 following values
 指定當文件存在或者不存在時如何動作。關于這個參數更多的信息,參考批注部分。這個參數必須是一個或多個
 下列值。

 VALUE(值)  Neaning(含義)
 CREATE_NEW  Creates a new file. The function fails if the specified file already exists
    創建一個新文件. 如果該文件已經存在函數則會失敗.
 
 CREATE_ALWAYS  Creates a new file. If the file exsts, the function overwrites the file and
    clears the existing attributes.
    創建一個新文件.如果該文件已經存在,函數將覆蓋已存在的文件并清除已存在的文件屬性

 OPEN_EXISTING  Opens the file. The function fails if the file does not exist.
    See the Remarks section for a discussion of why you should use the
    OPEN_EXISTING flag if you are using the CreateFile function for devices,
    including the console.
    打開一個文件,如果文件不存在函數將會失敗.
    如查你使用CreateFile函數為設備裝載控制臺.請查看批注中的"為什么使用
    OPEN_EXISTING標志"的部分.
    
 OPEN_ALWAYS  Opens the file, if it exsts. If the file does not exist, the function creates
    the file as if dwCreationDisposition were CREATE_NEW.
    如果文件存在,打開文件. 如果文件不存在,并且參數中有CREATE_NEW標志,則創建文件.

 TRUNCATE_EXISTING Opens the file. Once opened, the file is truncated so that its size is zero
    bytes The calling process must open the file with at least GENERIC_WRITE access.
    The function fails if the file does not exist.
    打開一個文件,每次打開,文件將被截至0字節.調用進程必須用GENERIC_WRITE訪問模式打
    開文件.如果文件不存在則函數就會失敗.

dwFlagsAndatributes
 Specifies the file attributes and flags for the file.
 為文件指定屬性和標志位

 Any combination of the following attributes is acceptable for the dwFlagsAndAttributes parameter,
 except all other file attributes override FILE_ATTRIBUTE_NORMAL.
 該參數可以接收下列屬性的任意組合.除非其它所有的文件屬性忽略FILE_ATTRIBUTE_NORMAL.
 Attribute(屬性)   Meaning(標志)
 FILE_ATTRIBUTE_ARCHIVE  The ifle should be archived. Application use this attribute to mark
     files for backup or removal.
     文件將被存檔,程序使用此屬性來標志文件去備份或移除

 FILE_ATTRIBUTE_HIDDEN  The file is hidden. It is not to be included in an ordinary directory
     listing.
     文件被隱藏,它不會在一般文件夾列表中被裝載.

 FILE_ATTRIBUTE_NORMAL  The file has no other attributes set. This attribute is valid only if
     used alone
     文件沒有被設置任何屬性.


 FILE_ATTRIBUTE_OFFLINE  The data of the file is not immediately available. Indicates that the
     file data has been physically moved to offline storage.
     文件的數據沒有被立即用到。指出正在脫機使用該文件。

 FILE_ATTRIBUTE_READONLY  The file is read only.Applications can read the file but cannot write
     to it or delete it
     這個文件只可讀取.程序可以讀文件,但不可以在上面寫入內容,也不可刪除.

 FILE_ATTRIBUTE_SYSTEM  The file is part of or is used exclusively by the operation system.
     文件是系統的一部分,或是系統專用的.

 FILE_ATTRIBUTE_TEMPORARY The file is being used for temporary storage. File systems attempt
     to keep all of the data in memory for quicker access rather than
     flushing the data back to mass storage. A temporary file should be
     deleted by the application as soon as it is no longer needed.
     文件被使用后,文件系統將努力為(文件的)所有數據的迅迅訪問保持一塊
     內存。臨時文件應當在程序不用時及時刪除。

 Any combination of the following flags is acceptable for the dwFlagsAndAttributes parameter.
 dwFlagAndAttributes可以接受下列標志的任意組合。

 FLAG(標志)   Meaning(含義)
 FILE_FLAG_WRITE_THROUGH  Instructs the system to write through any intermediate cache and go
     directly to disk. The system can still cache write operations, but
     cannot lazily flush them.
     指示系統通過快速緩存直接寫入磁盤,

 FILE_FLAG_OVERLAPPED  Instructs the system to initialize the object, so that operations that
     take a significant amount of time to process return ERROR_IO_PENDING.
     When the operation is finished, the specified event is set to the
     signaled state.
     指示系統初始化對象, 此操作將對進程設置一個引用計數并返回ERROR_IO_PENDING.
     處理完成后, 指定對象將被設置為信號狀態.

     When you specify FILE_FLAG_OVERLAPPED, the file read and write functions
     must specify an OVERLAPPED structure. That is, when FILE_FLAG_OVERLAPPED
     is specified, an application must perform overlapped parameter(pointing
     to an OVERLAPPED structure)to the file read and write functions.
     This flag also enables more than one operation to be performed
     simultaneously with the handle(a simultaneous read and write operation,
     for example).
     當你指定FILE_FLAG_OVERLAPPED時,讀寫文件的函數必須指定一個OVERLAPPED結構.
     并且. 當FILE_FLAG_OVERLAPPED被指定, 程序必須執行重疊參數(指向OVERLAPPED
     結構)去進行文件的讀寫.
     這個標志也可以有超過一個操作去執行.

 FILE_FLAG_NO_BUFFERING  Instructs the system to open the file with no intermediate buffering or
     caching.When combined with FILE_FLAG_OVERLAPPED, the flag gives maximum
     asynchronous performance, because the I/O does not rely on the synchronous
     operations of the memory manager. However, some I/O operations will take
     longer, because data is not being held in the cache.
     指示系統不使用快速緩沖區或緩存,當和FILE_FLAG_OVERLAPPED組合,該標志給出最
     大的異步操作量, 因為I/O不依賴內存管理器的異步操作.然而,一些I/O操作將會運行
     得長一些,因為數據沒有控制在緩存中.

     An application must meet certain requirements when working with files
     opened with FILE_FLAG_NO_BUFFERING:
     當使用FILE_FLAG_NO_BUFFERING打開文件進行工作時,程序必須達到下列要求:
     
      File access must begin at byte offsets within the file that are
      integer multiples of the volume's sector size.
      文件的存取開頭的字節偏移量必須是扇區尺寸的整倍數.
      
      File access must be for numbers of bytes that are integer
      multiples of the volume's sector size. For example, if the sector
      size is 512 bytes, an application can request reads and writes of
      512, 1024, or 2048 bytes, but not of 335, 981, or 7171bytes.
      文件存取的字節數必須是扇區尺寸的整倍數.例如,如果扇區尺寸是512字節
      程序就可以讀或者寫512,1024或者2048字節,但不能夠是335,981或者7171
      字節.

      buffer addresses for read and write operations must be sector
      aligned(aligned on addresses in memory that are integer multiples
      of the volume's sector size).
      進行讀和寫操作的地址必須在扇區的對齊位置,在內存中對齊的地址是扇區
      尺寸的整倍數.

     One way to align buffers on integer multiples of the volume sector size is
     to use VirtualAlloc to allocate the buffers, It allocates memory that is
     aligned on addresses that are integer multiples of the operating system's
     memory page size. Because both memory page and volume sector sizes are
     powers of 2, this memory is also aligned on addresses that are integer
     multiples of a volume's sector size.
     一個將緩沖區與扇區尺寸對齊的途徑是使用VirtualAlloc函數. 它分配與操作系統
     內存頁大小的整倍數對齊的內存地址.因為內存頁尺寸和扇區尺寸--2都是它們的冪.
     這塊內存在地址中同樣與扇區尺寸大小的整倍數對齊.

     An application can determine a volume's sector size by calling the
     GetDiskFreeSpace function
     程序可以通過調用GetDiskFreeSpace來確定扇區的尺寸.

 FILE_FLAG_RANDOM_ACCESS
     Indicates that the file is accessed randomly. The system can use this as
     a hint to optimize file caching.
     指定文件是隨機訪問,這個標志可以使系統優化文件的緩沖.


 FILE_FLAG_SEQUENTIAL_SCAN 
     Indicates that the file is to be accessed sequentially from beginning to
     end. The system can use this as a hint to optimize file caching. If an
     application moves the file pointer for random access, optimum caching may
     not occur; however, correct operation is still guaranteed.
     指定文件將從頭到尾連續地訪問.這個標志可以提示系統優化文件緩沖. 如果程序在
     隨機訪問文件中移動文件指針,優化可能不會發生;然而,正確的操作仍然可以得到保
     證
     
     Specifying this flag can increase performance for applications that read
     large files using sequential access, performance gains can be even more
     noticeable for applications that read large files mostly sequentially,
     but occasionally skip over small ranges of bytes.
     指定這個標志可以提高程序以順序訪問模式讀取大文件的性能, 性能的提高在許多
     程序讀取一些大的順序文件時是異常明顯的.但是可能會有小范圍的字節遺漏.


 FILE_FLAG_DELETE_ON_CLOSE Indicates that the operating system is to delete the file immediately
     after all of its handles have been closed, not just the handle for which
     you specified FILE_FLAG_DELETE_ON_CLOSE.
     指示系統在文件所有打開的句柄關閉后立即刪除文件.不只有你可以指定FILE_FLAG_DELETE_ON_CLOSE
     
     Subsequent open requests for the file will fail, unless FILE_SHARE_DELETE
     is used.
     如果沒有使用FILE_SHARE_DELETE,后續的打開文件的請求將會失敗.

 FILE_FLAG_BACKUP_SEMANTICS  WINDOWS NT:Indicates that the file is being opened or created for a backup
     or restore operation.The system ensures that the calling process overrides
     file security checks, provided it has the necessary privileges. The
     relevant privileges are SE_BACKUP_NAME and SE_RESTORE_NAME.
     WINDOWS NT:指示系統為文件的打開或創建執行一個備份或恢復操作. 系統保證調
     用進程忽略文件的安全選項,倘若它必須有一個特權.則相關的特權則是SE_BACKUP_NAME
     和SE_RESTORE_NAME.

     You can also set this flag to obtain a handle to a directory. A directory
     handle can be passed to some Win32 functions in place of a file handle.
     你也可以使用這個標志獲得一個文件夾的句柄,一個文件夾句柄能夠象一個文件句柄
     一樣傳給某些Win32函數。

 FILE_FLAG_POSIX_SEMANTICS Indicates that the file is to be accessed according to POSIX rules. This
     includes allowing multiple files with names, differing only in case, for file
     systems that support such naming. Use care when using this option because
     files created with this flag may not be accessible by applications written
     for MS-DOS or 16-bit Windows.
     指明文件符合POSIX標準.這是在MS-DOS與16位Windows下的標準.

 FILE_FLAG_OPEN_REPARSE_POINT Specifying this flag inhibits the reparse behavior of NTFS reparse points.
     When the file is opened, a file handle is returned, whether the filter that
     controls the reparse point is operational or not. This flag cannot be used
     with the CREATE_ALWAYS flag.
     指定這個標志制約NTFS分區指針.該標志不能夠和CREAT_ALWAYS一起使用.

 FILE_FLAG_OPEN_NO_RECALL Indicates that the file data is requested,but it should continue to reside in
     remote storage. It should not be transported back to local storage. This flag
     is intended for use by remote storage systems or the Hierarchical Storage
     Management system.
     指明需要文件數據,但是將繼續從遠程存儲器中接收.它不會將數據存放在本地存儲器中.
     這個標志由遠程存儲系統或等級存儲管理器系統使用.

hTemplateFile
 Specifies a handle with GENERIC_READ access to a template file. The template file supplies file attributes and
 extended attributes for the file being created.
 為GENERIC_READ訪問的模式指定一個句柄到模板文件.模板文件在文件開始創建后提供文件屬性和擴展屬性.

Return Values
返回值

If the function succeeds, the return value is an open handle to the specified file. If the specified file exists before
the function call and dwCreation is CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS
(even though the function has succeeded). If the file does not exist before the call, GetLastError returns zero.
如果函數成功,返回一個打開的指定文件的句柄.如果指定文件在函數調用前已經存在并且dwCreation參數是CREATE_ALWAYS 或者
OPEN_ALWAYS,調用GetLastError就會返回ERROR_ALREADY_EXISTS(表示函數成功). 如果函數文件在調用前不存在則會返回0.

If the function fails, the return value is INVALID_HANDLE_VALUE.To get extended error information, call GetLastError.
如果函數失敗,返會值會是INVALID_HANDLE_VALUE. 更多的錯誤信息可以調用GetLastError來獲得.

posted on 2008-09-11 09:44 wrh 閱讀(239) 評論(0)  編輯 收藏 引用

導航

<2010年10月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

統計

常用鏈接

留言簿(19)

隨筆檔案

文章檔案

收藏夾

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲免费在线播放| 亚洲日本欧美日韩高观看| 一区二区精品| 亚洲精品三级| 国产欧美日韩视频| 久久这里只有| 欧美片第1页综合| 欧美一区二区视频在线观看| 亚洲欧美中文在线视频| 在线成人h网| 亚洲字幕一区二区| 国模精品一区二区三区| 亚洲经典自拍| 国产乱码精品一区二区三区五月婷 | 日韩系列欧美系列| 亚洲欧美激情视频| 亚洲精品久久嫩草网站秘色 | 欧美成人精品激情在线观看| 亚洲久色影视| 久久噜噜噜精品国产亚洲综合| 99国内精品久久| 欧美一乱一性一交一视频| 夜夜嗨一区二区| 久久精品青青大伊人av| 性做久久久久久| 欧美视频免费看| 99精品国产高清一区二区| 黄网站免费久久| 亚洲欧美日韩精品综合在线观看| 亚洲精品久久视频| 猫咪成人在线观看| 欧美激情一区二区三区| 亚洲高清资源| 欧美激情精品久久久久久变态 | 欧美另类综合| 亚洲剧情一区二区| 亚洲香蕉伊综合在人在线视看| 老妇喷水一区二区三区| 亚洲国产日韩欧美一区二区三区| 国产一区二区三区四区hd| 久久久久久久一区二区三区| 久久久久久91香蕉国产| 合欧美一区二区三区| 激情久久一区| 国产精品免费看久久久香蕉| 久久av一区二区三区漫画| 欧美在线免费观看视频| 国产精品日韩精品| 亚洲天堂av在线免费| 久久久伊人欧美| 国产拍揄自揄精品视频麻豆| 欧美不卡在线视频| 久久综合伊人77777蜜臀| 国内偷自视频区视频综合| 久久精品盗摄| 在线视频亚洲| 欧美aⅴ一区二区三区视频| 亚洲欧洲日产国码二区| 欧美精品激情blacked18| 欧美一二三区精品| 亚洲欧美国产视频| 国产精品嫩草影院av蜜臀| 久久综合九色欧美综合狠狠| 亚洲一区二区三区高清不卡| 久久一本综合频道| 欧美在线播放一区二区| 最近中文字幕日韩精品| 在线精品观看| 国产亚洲激情| 国产欧美日韩激情| 国产精品亚洲产品| 国产精品电影观看| 欧美日韩在线一二三| 欧美日韩免费一区二区三区视频| 久久精品人人做人人爽| 久久久久久久久久久久久9999| 亚洲淫性视频| 日韩视频免费| 欧美影院在线| 夜夜夜久久久| 亚洲毛片一区| 亚洲免费在线播放| 久久久综合视频| 亚洲国产福利在线| 亚洲免费成人av| 欧美伊人精品成人久久综合97| 欧美一区二区在线| 欧美黑人在线播放| 国产视频丨精品|在线观看| 亚洲国产经典视频| 欧美一区二区三区精品| 免费视频久久| 久久www成人_看片免费不卡| 久久综合久久88| 国产农村妇女毛片精品久久莱园子| 国产伦精品一区二区三区视频黑人 | 中文日韩欧美| 欧美 日韩 国产一区二区在线视频 | 久久精品人人做人人综合 | 香蕉久久久久久久av网站| 欧美99在线视频观看| 欧美一区免费视频| 欧美少妇一区| 一本色道久久综合亚洲精品小说 | 久久久91精品国产一区二区精品| 久久在线视频| 亚洲高清视频中文字幕| 久久噜噜噜精品国产亚洲综合| 亚洲欧美综合一区| 在线中文字幕一区| 最新国产の精品合集bt伙计| 亚洲欧美在线一区二区| 欧美激情亚洲自拍| 性8sex亚洲区入口| 亚洲欧洲日产国产综合网| 国产午夜精品一区二区三区欧美| 欧美ed2k| 久久久久一区二区三区| 亚洲午夜电影网| 亚洲六月丁香色婷婷综合久久| 欧美88av| 久久夜色精品国产欧美乱极品| 午夜国产不卡在线观看视频| 亚洲毛片av| 一区二区三区在线视频观看| 欧美视频在线一区| 美女视频黄免费的久久| 亚洲无人区一区| 午夜精品短视频| 亚洲人成网站在线观看播放| 国产伦精品一区二区三区高清| 欧美1区2区3区| 一二三区精品| 一区二区三区欧美| 亚洲第一偷拍| 久久色中文字幕| 亚洲欧美精品| 亚洲男人的天堂在线| 亚洲激情专区| 国产日韩精品久久久| 欧美日韩国语| 久久久久久9| 久久久久久久久蜜桃| 香蕉久久a毛片| 中国亚洲黄色| 亚洲精品一区二区三区不| 亚洲第一在线视频| 看欧美日韩国产| 久久久91精品国产| 欧美一区二区三区久久精品茉莉花| 国内精品福利| 亚洲福利视频在线| 韩日精品视频| 国产亚洲欧洲| 国产在线不卡精品| 国产精品男女猛烈高潮激情| 欧美日韩麻豆| 欧美日韩在线电影| 欧美精品日韩综合在线| 午夜一区二区三视频在线观看| 午夜国产欧美理论在线播放| 亚洲综合视频网| 亚洲资源在线观看| 亚洲欧美视频在线观看视频| 亚洲欧美卡通另类91av| 欧美一区二区三区四区视频 | 国产精品入口尤物| 欧美激情一区二区| 欧美专区亚洲专区| 久久久999| 久久综合色综合88| 欧美日韩免费精品| 欧美日韩小视频| 国产精品电影网站| 在线成人h网| 99精品欧美一区二区三区综合在线| 亚洲精品日本| 亚洲国内在线| 欧美一区二区视频在线观看| 久久成人综合网| 欧美成人精品一区二区| 欧美成人一区二区| 亚洲一区高清| 久久精品主播| 欧美成年人网站| 欧美人与禽性xxxxx杂性| 国产亚洲视频在线观看| 在线播放中文字幕一区| 日韩视频在线观看一区二区| 亚洲免费影视| 91久久精品www人人做人人爽| 9国产精品视频| 久久gogo国模裸体人体| 欧美区在线观看| 在线观看不卡av| 一二三区精品| 久久综合图片| 玖玖综合伊人| 欧美在线三级| 欧美日韩一区在线|