Write a unicode CString to a file using WriteFile API
问题 How can I write contents of a CString instance to a file opened by CreateFile using WriteFile Win32 API function? Please note MFC is not used, and CString is used by including "atlstr.h" edit: Can just I do WriteFile(handle, cstr, cstr.GetLength(), &dwWritten, NULL); or WriteFile(handle, cstr, cstr.GetLength() * sizeof(TCHAR), &dwWritten, NULL); ? 回答1: With ATL it's like this: CString sValue; CStringW sValueW(sValue); // NOTE: CT2CW() can be used instead CAtlFile File; ATLENSURE_SUCCEEDED