1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
wstring write_stuff = generate_string();
BOOL write_success ;
sizeof (wchar_t);
DWORD length = (DWORD)write_stuff.length() ;
DWORD array_each_bytes = (DWORD)sizeof (write_stuff[1] );
DWORD Bytes_that_need_to_write = (DWORD) length* array_each_bytes ;
DWORD End_of_file = Bytes_that_need_to_write ;
DWORD BytesWritten;
LockFile(create , 0, 0, End_of_file, 0);
write_success = WriteFile(
create,
write_stuff.c_str(),
Bytes_that_need_to_write,
&BytesWritten,
0 );
if (write_success == 0) // write fail
{
LPWSTR Error_message2 = 0;
DWORD err2 = GetLastError();
::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
err2,
0,
(LPWSTR)&Error_message2,
0,
NULL) ;
MessageBox(NULL,Error_message2 , L"Access Error_46", MB_OK|MB_ICONWARNING );
|