diff --git a/bulls-and-cows-cpp/SetUserLocale.cpp b/bulls-and-cows-cpp/SetUserLocale.cpp new file mode 100644 index 0000000..136bb5e --- /dev/null +++ b/bulls-and-cows-cpp/SetUserLocale.cpp @@ -0,0 +1,22 @@ +// SetUserLocale.cpp +// +#include +#include + +bool SetUserLocale(void) +{ + bool ret = false; + wchar_t localeName[LOCALE_NAME_MAX_LENGTH]{ 0 }; + if (GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH)) + { + _wsetlocale(LC_ALL, localeName); + ret = true; + } + else + { + DWORD ec = GetLastError(); + std::wcout << L"GetUserDefaultLocaleName() failed! Error: " << ec << std::endl; + ret = false; + } + return ret; +} diff --git a/bulls-and-cows-cpp/SetUserLocale.h b/bulls-and-cows-cpp/SetUserLocale.h new file mode 100644 index 0000000..24dfe1b --- /dev/null +++ b/bulls-and-cows-cpp/SetUserLocale.h @@ -0,0 +1,7 @@ +// SetUserLocale.h +// +#pragma once +#ifndef SETUSERLOCALE_H +#define SETUSERLOCALE_H +bool SetUserLocale(void); +#endif // SETUSERLOCALE_H diff --git a/bulls-and-cows-cpp/bulls-and-cows-cpp.vcxproj b/bulls-and-cows-cpp/bulls-and-cows-cpp.vcxproj index 6859de3..095ecd2 100644 --- a/bulls-and-cows-cpp/bulls-and-cows-cpp.vcxproj +++ b/bulls-and-cows-cpp/bulls-and-cows-cpp.vcxproj @@ -131,20 +131,20 @@ - + - + diff --git a/bulls-and-cows-cpp/bulls-and-cows.cpp b/bulls-and-cows-cpp/bulls-and-cows.cpp index c7de317..e63d090 100644 --- a/bulls-and-cows-cpp/bulls-and-cows.cpp +++ b/bulls-and-cows-cpp/bulls-and-cows.cpp @@ -1,7 +1,7 @@ // Bulls and Cows the game // bulls-and-cows.cpp // -#include "..\..\..\MyFunctions\SetUserLocale.h" +#include "SetUserLocale.h" #include "CGame.h" int wmain(int argc, wchar_t* argv[])