📄 file.c
字号:
#include <api.h>
#include <stdio.h>
#include <windows.h>
//创建目录
BOOL WINAPI CreateDirectoryA(
LPCSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
){
printf("CreateDirectoryA %s, %X\n", lpPathName, lpSecurityAttributes );
return FALSE;
}
//for unicode
BOOL WINAPI CreateDirectoryW(
LPCTSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
){
printf("CreateDirectoryW %s, %X\n", lpPathName, lpSecurityAttributes );
return FALSE;
}
//
HANDLE WINAPI CreateFileA(
LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
){
printf("CreateFileA %s, %X\n", lpFileName, lpSecurityAttributes );
return FALSE;
}
//创建并打开文件
HANDLE WINAPI CreateFileW(
LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
){
printf("CreateFileW %s, %X\n", lpFileName, lpSecurityAttributes );
return FALSE;
}
//锁定文件内容
BOOL WINAPI LockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToLockLow,
DWORD nNumberOfBytesToLockHigh
){
printf("LockFile 0x%X, 0x%X, 0x%X, 0x%X, 0x%X\n", hFile,
dwFileOffsetLow, dwFileOffsetHigh, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh );
return FALSE;
}
//解锁文件内容
BOOL WINAPI UnlockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToUnlockLow,
DWORD nNumberOfBytesToUnlockHigh
){
printf("UnlockFile 0x%X, 0x%X, 0x%X, 0x%X, 0x%X\n", hFile,
dwFileOffsetLow, dwFileOffsetHigh, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh );
return FALSE;
}
//读文件
BOOL WINAPI ReadFile(
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped
){
printf("ReadFile 0x%X, %d, 0x%X, 0x%X, 0x%X\n", hFile,
lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped );
int ret = KReadFile( hFile, lpBuffer, nNumberOfBytesToRead );
*lpNumberOfBytesRead = ret;
return (ret>0);
}
//写文件
BOOL WINAPI WriteFile(
HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverlapped
){
printf("WriteFile 0x%X, %d, 0x%X, 0x%X, 0x%X\n", hFile,
lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped );
int ret = KWriteFile( hFile, lpBuffer, nNumberOfBytesToWrite );
lpNumberOfBytesWritten = ret;
return (ret>0);
}
//移动一个文件位置
BOOL WINAPI MoveFileA(
LPCSTR lpExistingFileName,
LPCSTR lpNewFileName
){
printf("MoveFile %s, %s\n", lpExistingFileName, lpNewFileName );
return FALSE;
}
BOOL WINAPI MoveFileW(
LPCWSTR lpExistingFileName,
LPCWSTR lpNewFileName
){
printf("MoveFile %s, %s\n", lpExistingFileName, lpNewFileName );
return FALSE;
}
//设置文件指针
DWORD WINAPI SetFilePointer(
HANDLE hFile,
LONG lDistanceToMove,
LONG *lpDistanceToMoveHigh,
DWORD dwMoveMethod //FILE_BEGIN, FILE_CURRENT, FILE_END
){
printf("SetFilePointer 0x%X, %d, 0x%X, %d\n", hFile, lDistanceToMove,
lpDistanceToMoveHigh, dwMoveMethod );
long ret = KSeekFile( hFile, lDistanceToMove, dwMoveMethod );
return ret;
}
//获得路径全名
DWORD WINAPI GetFullPathNameA(
LPCSTR lpFileName,
DWORD nBufferLength,
LPSTR lpBuffer,
LPSTR* lpFilePart // final file name
){
printf("GetFullPathNameA %s, %d, 0x%X, 0x%X\n", lpFileName,
nBufferLength, lpBuffer, lpFilePart );
return 0;
}
DWORD WINAPI GetFullPathNameW(
LPCWSTR lpFileName,
DWORD nBufferLength,
LPSTR lpBuffer,
LPSTR* lpFilePart // final file name
){
printf("GetFullPathNameW %s, %d, 0x%X, 0x%X\n", lpFileName,
nBufferLength, lpBuffer, lpFilePart );
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -