-
Поиск (перебор) файлов и папок:
The FindFirstFile function searches a directory for a file whose name matches the specified filename. FindFirstFile examines subdirectory names as well as filenames.
HANDLE FindFirstFile(
LPCTSTR lpFileName, // pointer to name of file to search for
LPWIN32_FIND_DATA lpFindFileData // pointer to returned information );
The WIN32_FIND_DATA structure describes a file found by the FindFirstFile or FindNextFile function.
typedef struct _WIN32_FIND_DATA { // wfd
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
TCHAR cFileName[ MAX_PATH ];
TCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATA;
The FindNextFile function continues a file search from a previous call to the FindFirstFile function.
BOOL FindNextFile(
HANDLE hFindFile, // handle to search
LPWIN32_FIND_DATA lpFindFileData // pointer to structure for data on found file
);
The FindClose function closes the specified search handle. The FindFirstFile and FindNextFile functions use the search handle to locate files with names that match a given name.
BOOL FindClose(
HANDLE hFindFile // file search handle );
The GetFileAttributes function returns attributes for a specified file or directory.
DWORD GetFileAttributes(
LPCTSTR lpFileName // address of the name of a file or directory );
-
Операции над устройством:
The DeviceIoControl function sends a control code directly to a specified device driver, causing the corresponding device to perform the specified operation.
BOOL DeviceIoControl(
HANDLE hDevice, // handle to device of interest
DWORD dwIoControlCode, // control code of operation to perform
LPVOID lpInBuffer, // pointer to buffer to supply input data
DWORD nInBufferSize, // size of input buffer
LPVOID lpOutBuffer, // pointer to buffer to receive output data
DWORD nOutBufferSize, // size of output buffer
LPDWORD lpBytesReturned, // pointer to variable to receive output byte count
LPOVERLAPPED lpOverlapped // pointer to overlapped structure for asynchronous operation );
The IOCTL_DISK_GET_PARTITION_INFO DeviceIoControl operation returns information about the type, size, and nature of a disk partition.
dwIoControlCode = IOCTL_DISK_GET_PARTITION_INFO ; // operation code
lpInBuffer = NULL; // address of input buffer; not used; must be NULL
nInBufferSize = 0; // size of input buffer; not used; must be zero
lpOutBuffer; // address of output buffer
nOutBufferSize; // size of output buffer
lpBytesReturned; // address of actual bytes of output
The IOCTL_DISK_GET_DRIVE_GEOMETRY DeviceIoControl operation returns information about the physical disk's geometry: type, number of cylinders, tracks per cylinder, sectors per track, and bytes per sector.
dwIoControlCode = IOCTL_DISK_GET_DRIVE_GEOMETRY; // operation code
lpInBuffer = NULL; // address of input buffer; not used; must be NULL
nInBufferSize = 0; // size of input buffer; not used; must be zero
lpOutBuffer ; // address of output buffer
nOutBufferSize ; // size of output buffer
lpBytesReturned ; // address of actual bytes of output
