Note: createfile is different from fopen. When opening a file, it does not distinguish text or binary readfile or writefile. Both operations are performed on binary data. Handle winapi createfile (_ in lpctstr lpfilename, // file path _ in DWORD dwdesiredaccess, // access permission, generic_read | generic_write _ in DWORD dw1_mode, // sharing mode, null | file_1__read | file_1__write _ in 1_lpsecurityattributes, // Security Attribute _ in DWORD dwcreationdisposition, // create a configuration, create_always | create_n EW | open_always | open_existing _ in DWORD dwflagsandattributes, // extended attribute, null | file_attribute_hidden | file_attribute_readonly _ in handle htemplatefile // specify a file handle, the new file copies the extended attributes from the file. Null); bool winapi readfile (_ in handle hfile, // file handle _ out lpvoid lpbuffer, // buffer _ in DWORD nnumberofbytestoread for receiving data, // number of bytes to be read _ out lpdword lpnumberofbytesread, // actual number of bytes read _ in lpoverlapped // overlapped structure, which is generally set to null ); bool winapi writefile (_ in handle hfile, // file handle _ in lpcvoid lpbuffer, // data to be written _ in DWORD nnumberofbytestowrite, // number of bytes to write _ out lpdword lpnumberofb Yteswritten, // Number of actually written bytes _ in lpoverlapped // overlapped structure, generally set to null); DWORD winapi getfilesize (_ in handle hfile, // file handle _ out lpdword lpfilesizehigh // return value of high-order, which is generally set to null); Read File: void read (const wchar_t * strpath) {handle hfile = :: createfile (strpath, generic_read, 0, null, open_existing, null, null); If (hfile! = Invalid_handle_value) {DWORD nfilesize =: getfilesize (hfile, null); char * lpbuffer = new char [nfilesize]; DWORD nnumberofbytesread; bool Bret =: readfile (hfile, lpbuffer, nfilesize, & nnumberofbytesread, null); // todo... delete [] lpbuffer; closehandle (hfile) ;}} Write File: void write (const wchar_t * strpath, const wchar_t * strcontent, const int ncontentsize) {handle hfile = :: createfile (strpath, gener Ic_write, 0, null, create_always, null, null); If (hfile! = Invalid_handle_value) {DWORD nnumberofbyteswritten;: writefile (hfile, strcontent, ncontentsize, & encoding, null); // todo... closehandle (hfile );}}