1.CreateFile函数
https://www.cctry.com/thread-298293-1-1.html
1.1 语法格式:
HANDLE WINAPI CreateFile(
_In_ LPCTSTR lpFileName,
_In_ DWORD dwDesiredAccess,
_In_ DWORD dwShareMode,
_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
_In_ DWORD dwCreationDisposition,
_In_ DWORD dwFlagsAndAttributes,
_In_opt_ HANDLE hTemplateFile
);
2.关闭文件句柄:CloseHandle函数
函数声明:
BOOL CloseHandle(HANDLE hObject);
HANDLE creat_file = CreateFile(_T("d:\\12345.png"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (creat_file != INVALID_HANDLE_VALUE) //判断CreateFile函数是否执行成功,失败则返回INVALID_HANDLE_VALUE
{
MessageBox(NULL, _T("打开成功!"), _T("Tip"), MB_OK);
}
else
{
MessageBox(NULL, _T("打开失败!"), _T("Tip"), MB_OK);
}
CloseHandle(creat_file); //关闭文件