wcslen
returns the number of wchar_t
elements in aBuffer
before a null terminator (in your case, this is 10).
But WriteFile
wants the number of BYTES. You need to do this instead:
WriteFile(file, aBuffer, wcslen(aBuffer) * sizeof(wchar_t), &writtenByte, NULL);
Also note that string literals are automatically null-terminated in C. So your string literal L"1234567890\0"
is actually 12 characters long ("1234567890\0\0"). Rewrite it as just L"1234567890"
instead.