We have a module that uses CreateProcess() to invoke CMD.EXE and that can pass a MBCS command line to CMD.EXE that can contain 8-bit characters.
Before Windows 11, it appears that a CMD.EXE created in this way used the SetFileApisToANSI() and SetFileApisToOEM() setting to determine whether the command line should be treated as containing OEM or ANSI characters. Specifically, if SetFileApisToOEM() is in effect, a command line containing OEM characters was converted to ANSI before execution.
For example, I have linked a program that issues these two C command lines in a program that uses CreateProcess() to invoke CMD.EXE:
const char * p_ans = "C:\\WINDOWS\\SYSTEM32\\CMD.exe /c mkdir DIR_FileApiANS_\x9c"; // OEM £ character saved with ANSI file API
const char * p_oem = "C:\\WINDOWS\\SYSTEM32\\CMD.exe /c mkdir DIR_FileApiOEM_\x9c"; // OEM £ character saved with OEM file API
SetFileApisToOEM();
ExecCmd(p_oem);
SetFileApisToANSI();
ExecCmd(p_ans);
ExecCmd() uses CreateProcess() to invoke CMD.EXE.
With this in effect, on Windows 10:
SetFileApisToANSI:
SetFileApisToOEM:
On Windows 11, same program:
SetFileApisToANSI:
SetFileApisToOEM:
I can't attach a ZIP file, but here is a simple program with a Visual Studio project: https://www.dropbox.com/s/d21ewb7r09jdnr1/CmdWithFileApiAnsiOem.zip?dl=0