сряда, 14 януари 2009 г.

fileextd.lib for XP/2003

fileextd.lib дава набор от допълнителни функции който не са достъпни в стандартния пакет от функции за Windows XP/2003.



/************************************************************************
* *
* fileextd.h - This module defines some extensions to the the 32-Bit *
* Windows Base APIs based on file handles. *
* *
* Copyright (c) Microsoft Corp. All rights reserved. *
* *
************************************************************************/
#ifndef _FILEEXTD_
#define _FILEEXTD_

#ifdef __cplusplus
extern "C" {
#endif

typedef enum _FILE_INFO_BY_HANDLE_CLASS {
FileBasicInfo,
FileStandardInfo,
FileNameInfo,
FileRenameInfo,
FileDispositionInfo,
FileAllocationInfo,
FileEndOfFileInfo,
FileStreamInfo,
FileCompressionInfo,
FileAttributeTagInfo,
FileIdBothDirectoryInfo,
FileIdBothDirectoryRestartInfo,
MaximumFileInfoByHandleClass
} FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;

typedef struct _FILE_BASIC_INFO {
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
DWORD FileAttributes;
} FILE_BASIC_INFO, *PFILE_BASIC_INFO;

typedef struct _FILE_STANDARD_INFO {
LARGE_INTEGER AllocationSize;
LARGE_INTEGER EndOfFile;
DWORD NumberOfLinks;
BOOLEAN DeletePending;
BOOLEAN Directory;
} FILE_STANDARD_INFO, *PFILE_STANDARD_INFO;

typedef struct _FILE_NAME_INFO {
DWORD FileNameLength;
WCHAR FileName[1];
} FILE_NAME_INFO, *PFILE_NAME_INFO;

typedef struct _FILE_RENAME_INFO {
BOOLEAN ReplaceIfExists;
HANDLE RootDirectory;
DWORD FileNameLength;
WCHAR FileName[1];
} FILE_RENAME_INFO, *PFILE_RENAME_INFO;

typedef struct _FILE_ALLOCATION_INFO {
LARGE_INTEGER AllocationSize;
} FILE_ALLOCATION_INFO, *PFILE_ALLOCATION_INFO;

typedef struct _FILE_END_OF_FILE_INFO {
LARGE_INTEGER EndOfFile;
} FILE_END_OF_FILE_INFO, *PFILE_END_OF_FILE_INFO;

typedef struct _FILE_STREAM_INFO {
DWORD NextEntryOffset;
DWORD StreamNameLength;
LARGE_INTEGER StreamSize;
LARGE_INTEGER StreamAllocationSize;
WCHAR StreamName[1];
} FILE_STREAM_INFO, *PFILE_STREAM_INFO;

typedef struct _FILE_COMPRESSION_INFO {
LARGE_INTEGER CompressedFileSize;
WORD CompressionFormat;
UCHAR CompressionUnitShift;
UCHAR ChunkShift;
UCHAR ClusterShift;
UCHAR Reserved[3];
} FILE_COMPRESSION_INFO, *PFILE_COMPRESSION_INFO;

typedef struct _FILE_ATTRIBUTE_TAG_INFO {
DWORD FileAttributes;
DWORD ReparseTag;
} FILE_ATTRIBUTE_TAG_INFO, *PFILE_ATTRIBUTE_TAG_INFO;

typedef struct _FILE_DISPOSITION_INFO {
BOOLEAN DeleteFile;
} FILE_DISPOSITION_INFO, *PFILE_DISPOSITION_INFO;

typedef struct _FILE_ID_BOTH_DIR_INFO {
DWORD NextEntryOffset;
DWORD FileIndex;
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
LARGE_INTEGER EndOfFile;
LARGE_INTEGER AllocationSize;
DWORD FileAttributes;
DWORD FileNameLength;
DWORD EaSize;
CCHAR ShortNameLength;
WCHAR ShortName[12];
LARGE_INTEGER FileId;
WCHAR FileName[1];
} FILE_ID_BOTH_DIR_INFO, *PFILE_ID_BOTH_DIR_INFO;

BOOL
WINAPI
SetFileInformationByHandle(
__in HANDLE hFile,
__in FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
__in LPVOID lpFileInformation,
__in DWORD dwBufferSize
);

BOOL
WINAPI
GetFileInformationByHandleEx(
__in HANDLE hFile,
__in FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
__out LPVOID lpFileInformation,
__in DWORD dwBufferSize
);

typedef enum _FILE_ID_TYPE {
FileIdType,
MaximumFileIdType
} FILE_ID_TYPE, *PFILE_ID_TYPE;

typedef struct FILE_ID_DESCRIPTOR {
DWORD dwSize; // Size of the struct
FILE_ID_TYPE Type; // Describes the type of identifier passed in.
union {
LARGE_INTEGER FileId;
GUID ObjectId;
};
} FILE_ID_DESCRIPTOR, *LPFILE_ID_DESCRIPTOR;

__out
HANDLE
WINAPI
OpenFileById (
__in HANDLE hVolumeHint,
__in LPFILE_ID_DESCRIPTOR lpFileId,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__in DWORD dwFlagsAndAttributes
);
#endif

#ifdef __cplusplus
}
#endif
Предоставените функции "OpenFileById ", "GetFileInformationByHandleEx", "SetFileInformationByHandle" , "GetFileInformationByHandleEx" са много удобни и спестяват много усилия при по-сложни операции върху файлове. Повече информация за използването може да бъде намерена в MSDN.

А fileextd.lib може да потърсите в интернет или да го вземете от тук.

Линквате към него и може да използвате тези фукции.

Няма коментари:

Публикуване на коментар