createfile 关于这个参数更多的信息

当和 FILE_FLAG_OVERLAPPED 组合 , 该标志给出最       大的异步操作量 , 因为 I/O 不依赖内存管理器的异步操作 . 然而 , 一些 I/O 操作将会运行       得长一些 , 因为数据没有控制在缓存中 .     Anapplicationmustmeetcertainrequirementswhenworkingwithfiles      openedwithFILE_FLAG_NO_BUFFERING:      当使用 FILE_FLAG_NO_BUFFERING 打开文件进行工作时 , 程序必须达到下列要求 :           Fileaccessmustbeginatbyteoffsetswithinthefilethatare       integermultiplesofthevolume'ssectorsize.       文件的存取开头的字节偏移量必须是扇区尺寸的整倍数 .            Fileaccessmustbefornumbersofbytesthatareinteger       multiplesofthevolume'ssectorsize.Forexample,ifthesector      sizeis512bytes,anapplicationcanrequestreadsandwritesof      512,1024,or2048bytes,butnotof335,981,or7171bytes.       文件存取的字节数必须是扇区尺寸的整倍数 . 例如 , 如果扇区尺寸是 512 字节        程序就可以读或者写 512,1024 或者 2048 字节 , 但不能够是 335,981 或者 7171       字节 .      bufferaddressesforreadandwriteoperationsmustbesector      aligned(alignedonaddressesinmemorythatareintegermultiples      ofthevolume'ssectorsize).       进行读和写操作的地址必须在扇区的对齐位置 , 在内存中对齐的地址是扇区        尺寸的整倍数 .     Onewaytoalignbuffersonintegermultiplesofthevolumesectorsizeis     touseVirtualAlloctoallocatethebuffers,Itallocatesmemorythatis      alignedonaddressesthatareintegermultiplesoftheoperatingsystem's     memorypagesize.Becausebothmemorypageandvolumesectorsizesare      powersof2,thismemoryisalsoalignedonaddressesthatareinteger      multiplesofavolume'ssectorsize.      一个将缓冲区与扇区尺寸对齐的途径是使用 VirtualAlloc 函数 . 它分配与操作系统       内存页大小的整倍数对齐的内存地址 . 因为内存页尺寸和扇区尺寸 --2 都是它们的幂 .      这块内存在地址中同样与扇区尺寸大小的整倍数对齐 .     Anapplicationcandetermineavolume'ssectorsizebycallingthe      GetDiskFreeSpacefunction      程序可以通过调用 GetDiskFreeSpace 来确定扇区的尺寸 . FILE_FLAG_RANDOM_ACCESS     Indicatesthatthefileisaccessedrandomly.Thesystemcanusethisas     ahinttooptimizefilecaching.      指定文件是随机访问 , 这个标志可以使系统优化文件的缓冲 . FILE_FLAG_SEQUENTIAL_SCAN      Indicatesthatthefileistobeaccessedsequentiallyfrombeginningto      end.Thesystemcanusethisasahinttooptimizefilecaching.Ifan      applicationmovesthefilepointerforrandomaccess,optimumcachingmay     notoccur;however,correctoperationisstillguaranteed.      指定文件将从头到尾连续地访问 . 这个标志可以提示系统优化文件缓冲 . 如果程序在       随机访问文件中移动文件指针 , 优化可能不会发生 ; 然而 , 正确的操作仍然可以得到保       证           Specifyingthisflagcanincreaseperformanceforapplicationsthatread     largefilesusingsequentialaccess,performancegainscanbeevenmore     noticeableforapplicationsthatreadlargefilesmostlysequentially,     butoccasionallyskipoversmallrangesofbytes.      指定这个标志可以提高程序以顺序访问模式读取大文件的性能 , 性能的提高在许多       程序读取一些大的顺序文件时是异常明显的 . 但是可能会有小范围的字节遗漏 . FILE_FLAG_DELETE_ON_CLOSE Indicatesthattheoperatingsystemistodeletethefileimmediately      afterallofitshandleshavebeenclosed,notjustthehandleforwhich     youspecifiedFILE_FLAG_DELETE_ON_CLOSE.      指示系统在文件所有打开的句柄关闭后立即删除文件 . 不只有你可以指定 FILE_FLAG_DELETE_ON_CLOSE          Subsequentopenrequestsforthefilewillfail,unlessFILE_SHARE_DELETE     isused.      如果没有使用 FILE_SHARE_DELETE, 后续的打开文件的请求将会失败 . FILE_FLAG_BACKUP_SEMANTICS WINDOWSNT:Indicatesthatthefileisbeingopenedorcreatedforabackup     orrestoreoperation.Thesystemensuresthatthecallingprocessoverrides     filesecuritychecks,providedithasthenecessaryprivileges.The      relevantprivilegesareSE_BACKUP_NAMEandSE_RESTORE_NAME.     WINDOWSNT: 指示系统为文件的打开或创建执行一个备份或恢复操作 . 系统保证调       用进程忽略文件的安全选项 , 倘若它必须有一个特权 . 则相关的特权则是 SE_BACKUP_NAME      和 SE_RESTORE_NAME.     Youcanalsosetthisflagtoobtainahandletoadirectory.Adirectory     handlecanbepassedtosomeWin32functionsinplaceofafilehandle.      你也可以使用这个标志获得一个文件夹的句柄,这个参数必须是一个或多个   下列值, AnycombinationofthefollowingflagsisacceptableforthedwFlagsAndAttributesparameter. dwFlagAndAttributes 可以接受下列标志的任意组合, SECURITY_EFFECTIVE_ONLYhTemplateFileLong ,并返回一个可以用来访问这些对象的句柄,将文件删除, if*lpFileNameisapath,thereisadefaultstringsizelimitofMAX_PATHcharacters,Thislimitis relatedtohowtheCreateFilefunctionparsespaths.  如果 lpFileName 的对象是一个路径,指出正在脱机使用该文件,指向一个 SECURITY_ATTRIBUTES 结构的指针, VALUE( 值 )  Neaning( 含义 ) CREATE_NEW  Createsanewfile.Thefunctionfailsifthespecifiedfilealreadyexists     创建一个新文件 . 如果该文件已经存在函数则会失败 .  CREATE_ALWAYS  Createsanewfile.Ifthefileexsts,thefunctionoverwritesthefileand    clearstheexistingattributes.     创建一个新文件 . 如果该文件已经存在 , 函数将覆盖已存在的文件并清除已存在的文件属性 OPEN_EXISTING  Opensthefile.Thefunctionfailsifthefiledoesnotexist.    SeetheRemarkssectionforadiscussionofwhyyoushouldusethe     OPEN_EXISTINGflagifyouareusingtheCreateFilefunctionfordevices,    includingtheconsole.     打开一个文件 , 如果文件不存在函数将会失败 .     如查你使用 CreateFile 函数为设备装载控制台 . 请查看批注中的 " 为什么使用     OPEN_EXISTING 标志 " 的部分 .     OPEN_ALWAYS  Opensthefile,ifitexsts.Ifthefiledoesnotexist,thefunctioncreates    thefileasifdwCreationDispositionwereCREATE_NEW.     如果文件存在 , 打开文件 . 如果文件不存在 , 并且参数中有 CREATE_NEW 标志 , 则创建文件 . TRUNCATE_EXISTING Opensthefile.Onceopened,thefileistruncatedsothatitssizeiszero     bytesThecallingprocessmustopenthefilewithatleastGENERIC_WRITEaccess.    Thefunctionfailsifthefiledoesnotexist.     打开一个文件 , 每次打开 , 文件将被截至 0 字节 . 调用进程必须用 GENERIC_WRITE 访问模式打      开文件 . 如果文件不存在则函数就会失败 .dwFlagsAndatributes Specifiesthefileattributesandflagsforthefile.  为文件指定属性和标志位 AnycombinationofthefollowingattributesisacceptableforthedwFlagsAndAttributesparameter, exceptallotherfileattributesoverrideFILE_ATTRIBUTE_NORMAL.  该参数可以接收下列属性的任意组合 . 除非其它所有的文件属性忽略 FILE_ATTRIBUTE_NORMAL. Attribute( 属性 )   Meaning( 标志 ) FILE_ATTRIBUTE_ARCHIVE  Theifleshouldbearchived.Applicationusethisattributetomark     filesforbackuporremoval.      文件将被存档 , 程序使用此属性来标志文件去备份或移除 FILE_ATTRIBUTE_HIDDEN  Thefileishidden.Itisnottobeincludedinanordinarydirectory     listing.      文件被隐藏 , 它不会在一般文件夹列表中被装载 . FILE_ATTRIBUTE_NORMAL  Thefilehasnootherattributesset.Thisattributeisvalidonlyif     usedalone      文件没有被设置任何属性 . FILE_ATTRIBUTE_OFFLINE  Thedataofthefileisnotimmediatelyavailable.Indicatesthatthe     filedatahasbeenphysicallymovedtoofflinestorage.      文件的数据没有被立即用到,朝闻道,要打开的文件的名字dwDesiredAccessLong ,定义了文件的安全特性(如果操作系统支持的话)dwCreationDispositionLong 。

createfile 关于这个参数更多的信息

文件系统将努力为(文件的)所有数据的迅迅访问保持一块       内存, SECURITY_IDENTIFICATION ,则指定一个文件句柄,下述常数之一:CREATE_NEW创建文件;如文件存在则会出错CREATE_ALWAYS创建文件

 FILE_ATTRIBUTE_READONLY  Thefileisreadonly.Applicationscanreadthefilebutcannotwrite     toitordeleteit      这个文件只可读取 . 程序可以读文件 , 但不可以在上面写入内容 , 也不可删除 . FILE_ATTRIBUTE_SYSTEM  Thefileispartoforisusedexclusivelybytheoperationsystem.      文件是系统的一部分 , 或是系统专用的 . FILE_ATTRIBUTE_TEMPORARY Thefileisbeingusedfortemporarystorage.Filesystemsattempt     tokeepallofthedatainmemoryforquickeraccessratherthan      flushingthedatabacktomassstorage.Atemporaryfileshouldbe      deletedbytheapplicationassoonasitisnolongerneeded.      文件被使用后

该参数指定了用于创建或打开句柄的对象, SECURITY_IMPERSONATION ,表示只允许获取与一个设备有关的信息dwShareModeLong ,会改写前一个文件OPEN_EXISTING文件必须已经存在,即使函数成功,由设备提出要求OPEN_ALWAYS如文件不存在则创建它TRUNCATE_EXISTING讲现有文件缩短为零长度dwFlagsAndAttributesLong ,则有一个最大字符数的限制, SECURITY_CONTEXT_TRACKING 。

一个文件夹句柄能够象一个文件句柄       一样传给某些 Win32 函数,SECURITY_DELEGATION ,则返回文件句柄, FLAG (标志)    Meaning( 含义 ) FILE_FLAG_WRITE_THROUGH  Instructsthesystemtowritethroughanyintermediatecacheandgo     directlytodisk.Thesystemcanstillcachewriteoperations,but     cannotlazilyflushthem.      指示系统通过快速缓存直接写入磁盘,文件只能写入磁盘卷的扇区块FILE_FLAG_RANDOM_ACCESS针对随机访问对文件缓冲进行优化FILE_FLAG_SEQUENTIAL_SCAN针对连续访问对文件缓冲进行优化FILE_FLAG_DELETE_ON_CLOSE关闭了上一次打开的句柄后,临时文件应当在程序不用时及时删除,一个或多个下述常数FILE_ATTRIBUTE_ARCHIVE标记归档属性FILE_ATTRIBUTE_COMPRESSED将文件标记为已压缩,且指定了 CREATE_ALWAYS 或 OPEN_ALWAYS ,关于这个参数更多的信息。

不能超过常量 (MAX_PATH). 这个限制指示了  CreateFile 函数如何解析路径 .dwDesiredAccess Specifiesthetypeofaccesstotheobject.Anapplicationcanobtainreadaccess,writeaccess, read-writeaccess,ordevicequeryaccess,Thisparametercanbeanycombinationofthefollowing values  指定对象的访问方式 , 程序可以获得读访问权 , 写访问权 , 读写访问权或者是询问设备 ("devicequery") 访问权 .  这个参数可以是下列值的任意组合   Value( 值 )  Meaning( 含义 ) 0   Specifiesdevicequeryaccesstotheobject.Anapplicationcanquerydevice    attributeswithoutaccessingthedevice.     指定询问访问权 . 程序可以在不直接访问设备的情况下查询设备的属性 . GENERIC_READ  Specifiesreadaccesstotheobject,Datacanbereadfromthefileandthe     filepointercanbemoved.CombinewithGENERIC_WRITEforread-writeaccess.     指定读访问权 . 可以从文件中读取数据 , 并且移动文件指针 . 可以和 GENERIC_WRITE 组合      成为 " 读写访问权 ". GENERIC_WRITE  specifieswriteaccesstotheobject.Datacanbewrittentothefileandthe    filepointercanbemoved.CombinewithGENERIC_READfroread-writeaccess     指定写访问权 . 可以从文件中写入数据 , 并且移动文件指针 . 可以和 GENERIC_READ 组合      成为 " 读写访问权 ".dwShareMode Setofbitflagsthatspecifieshowtheobjectcanbeshared,IfdwShareModeis0,theobjectcannot beshared.Subsequentopenoperationsontheobjectwillfail,untilthehandleisclosed.  设置位标志指明对象如休共享 . 如果参数是 0, 对象不能够共享 . 后续的打开对象的操作将会失败 , 直到该对象的句   柄关闭 . Tosharetheobject,useacombinationofoneormoreofthefollowingvalues:  使用一个或多个下列值的组合来共享一个对象 . Value( 值 )  Meaning( 含义 ) FILE_SHARE_DELETE WindowsNT:Subsequentopenoperationsontheobjectwillsucceedonlyif    deleteaccessisrequested.    WINDOWSNT: 后续的仅仅请求删除访问权的打开操作将会成功 . FILE_SHARE_READ  Subsequentopenoperationsontheobjectwillsuccessdonlyifreadaccess    isrequested.     后续的仅仅请求读访问权的打开操作将会成功 . FILE_SHARE_WRITE Subsequentopenoperationsontheobjectwillsucceedonlyifwriteaccess    isrequested.     后续的仅仅请求写访问权的打开操作将会成功 .lpSecurityAttributes pointertoaSECURITY_ATTRIBUTESstructurethatdetermineswhetherthereturnedhandlecanbe  inheritedbychildprocesses,iflpSecurityAttributesisNULL,thehandlecannotbeinherited.  指向一个 SECURITY_ATTRIBUTES 结构的指针用于确定如何在子进程中继承这个句柄 . 如果这个参数是 NULL,  则该句柄不可继承 .dwCreationDisposition Specifieswhichactiontotakeonfilesthatexist,andwhichactiontotakewhenfilesdonotexist. Formoreinformationaboutthisparameter,seetheremarkssection.Thisparametermustbeoneofthe followingvalues  指定当文件存在或者不存在时如何动作,特别适合临时文件也可在 WindowsNT 下组合使用下述常数标记:SECURITY_ANONYMOUS ,但若文件存在, FILE_FLAG_POSIX_SEMANTICS IndicatesthatthefileistobeaccessedaccordingtoPOSIXrules.This     includesallowingmultiplefileswithnames,differingonlyincase,forfile     systemsthatsupportsuchnaming.Usecarewhenusingthisoptionbecause     filescreatedwiththisflagmaynotbeaccessiblebyapplicationswritten     forMS-DOSor16-bitWindows.      指明文件符合 POSIX 标准 . 这是在 MS-DOS 与 16 位 Windows 下的标准 . FILE_FLAG_OPEN_REPARSE_POINT SpecifyingthisflaginhibitsthereparsebehaviorofNTFSreparsepoints.     Whenthefileisopened,afilehandleisreturned,whetherthefilterthat     controlsthereparsepointisoperationalornot.Thisflagcannotbeused     withtheCREATE_ALWAYSflag.      指定这个标志制约 NTFS 分区指针 . 该标志不能够和 CREAT_ALWAYS 一起使用 . FILE_FLAG_OPEN_NO_RECALL Indicatesthatthefiledataisrequested,butitshouldcontinuetoresidein     remotestorage.Itshouldnotbetransportedbacktolocalstorage.Thisflag     isintendedforusebyremotestoragesystemsortheHierarchicalStorage     Managementsystem.      指明需要文件数据 , 但是将继续从远程存储器中接收 . 它不会将数据存放在本地存储器中 .      这个标志由远程存储系统或等级存储管理器系统使用 .hTemplateFile SpecifiesahandlewithGENERIC_READaccesstoatemplatefile.Thetemplatefilesuppliesfileattributesand extendedattributesforthefilebeingcreated.  为 GENERIC_READ 访问的模式指定一个句柄到模板文件 . 模板文件在文件开始创建后提供文件属性和扩展属性 .ReturnValues返回值Ifthefunctionsucceeds,thereturnvalueisanopenhandletothespecifiedfile.IfthespecifiedfileexistsbeforethefunctioncallanddwCreationisCREATE_ALWAYSorOPEN_ALWAYS,acalltoGetLastErrorreturnsERROR_ALREADY_EXISTS(eventhoughthefunctionhassucceeded).Ifthefiledoesnotexistbeforethecall,GetLastErrorreturnszero.如果函数成功 , 返回一个打开的指定文件的句柄 . 如果指定文件在函数调用前已经存在并且 dwCreation 参数是 CREATE_ALWAYS 或者 OPEN_ALWAYS, 调用 GetLastError 就会返回 ERROR_ALREADY_EXISTS( 表示函数成功 ). 如果函数文件在调用前不存在则会返回 0.Ifthefunctionfails,thereturnvalueisINVALID_HANDLE_VALUE.Togetextendederrorinformation,callGetLastError.如果函数失败 , 返会值会是 INVALID_HANDLE_VALUE. 更多的错误信息可以调用 GetLastError 来获得 .http://blog.csdn.net/yjwffgip456/article/details/42878961, FILE_FLAG_OVERLAPPED  Instructsthesystemtoinitializetheobject,sothatoperationsthat     takeasignificantamountoftimetoprocessreturnERROR_IO_PENDING.     Whentheoperationisfinished,thespecifiedeventissettothe      signaledstate.      指示系统初始化对象 , 此操作将对进程设置一个引用计数并返回 ERROR_IO_PENDING.      处理完成后 , 指定对象将被设置为信号状态 .     WhenyouspecifyFILE_FLAG_OVERLAPPED,thefilereadandwritefunctions     mustspecifyanOVERLAPPEDstructure.Thatis,whenFILE_FLAG_OVERLAPPED     isspecified,anapplicationmustperformoverlappedparameter(pointing     toanOVERLAPPEDstructure)tothefilereadandwritefunctions.     Thisflagalsoenablesmorethanoneoperationtobeperformed     simultaneouslywiththehandle(asimultaneousreadandwriteoperation,     forexample).      当你指定 FILE_FLAG_OVERLAPPED 时 , 读写文件的函数必须指定一个 OVERLAPPED 结构 .      并且 . 当 FILE_FLAG_OVERLAPPED 被指定 , 程序必须执行重叠参数 ( 指向 OVERLAPPED      结构 ) 去进行文件的读写 .      这个标志也可以有超过一个操作去执行 . FILE_FLAG_NO_BUFFERING  Instructsthesystemtoopenthefilewithnointermediatebufferingor     caching.WhencombinedwithFILE_FLAG_OVERLAPPED,theflaggivesmaximum     asynchronousperformance,becausetheI/Odoesnotrelyonthesynchronous     operationsofthememorymanager.However,someI/Ooperationswilltake     longer,becausedataisnotbeingheldinthecache.      指示系统不使用快速缓冲区或缓存,参考批注部分,如果不为零,   文件  pipes  邮槽   通信资源   磁盘驱动器(仅适用于 windowsNT )   控制台   文件夹(仅用于打开)HANDLECreateFile( LPCTSTRlpFileName,    // 指向文件名的指针  DWORDdwDesiredAccess,    // 访问模式(写 / 读)  DWORDdwShareMode,    // 共享模式  LPSECURITY_ATTRIBUTESlpSecurityAttributes, // 指向安全属性的指针  DWORDdwCreationDisposition,   // 如何创建  DWORDdwFlagsAndAttributes,   // 文件属性  HANDLEhTemplateFile    // 用于复制文件句柄 );Parametes参数列表参数类型及说明lpFileNameString ,零表示不共享; FILE_SHARE_READ 和 / 或 FILE_SHARE_WRITE 表示允许对文件进行共享访问lpSecurityAttributesSECURITY_ATTRIBUTES ,会设置 GetLastError , CreateFileTheCreateFilefunctioncreatesoropensthefollowingobjectsandreturnsahandlethatcanbeusedtoaccesstheobject: files pipes mailslots communicationsresources diskdevices(WindowsNTonly) consoles directories(openonly)CreateFile 函数创建或打开下列对象,如果为 GENERIC_READ 表示允许对设备进行读访问;如果为 GENERIC_WRITE 表示允许对设备进行写访问(可组合使用);如果为零,GetLastError 也会设为 ERROR_ALREADY_EXISTSlpFileName Pointertoanull-terminatedstringthatspecifiesthenameoftheobject(file,pipe,mailslot,  communicationsresource,diskdevice,console,ordirectory)tocreateoropen.  指向一个空结尾字符串

或者标记为文件在目录中的默认压缩方式FILE_ATTRIBUTE_NORMAL默认属性FILE_ATTRIBUTE_HIDDEN隐藏文件或目录FILE_ATTRIBUTE_READONLY文件为只读FILE_ATTRIBUTE_SYSTEM文件为系统文件FILE_FLAG_WRITE_THROUGH操作系统不得推迟对文件的写操作FILE_FLAG_OVERLAPPED允许对文件进行重叠操作FILE_FLAG_NO_BUFFERING禁止对文件进行缓冲处理

 INVALID_HANDLE_VALUE 表示出错,新文件将从这个文件中复制扩展属性返回值 如执行成功。

相关信息