mirror of
https://gitflic.ru/project/w0lf/bulls-and-cows-cpp.git
synced 2026-03-28 16:02:46 +03:00
Added external SetUserLocale() function into project.
This commit is contained in:
22
bulls-and-cows-cpp/SetUserLocale.cpp
Normal file
22
bulls-and-cows-cpp/SetUserLocale.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// SetUserLocale.cpp
|
||||
//
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
|
||||
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;
|
||||
}
|
||||
7
bulls-and-cows-cpp/SetUserLocale.h
Normal file
7
bulls-and-cows-cpp/SetUserLocale.h
Normal file
@@ -0,0 +1,7 @@
|
||||
// SetUserLocale.h
|
||||
//
|
||||
#pragma once
|
||||
#ifndef SETUSERLOCALE_H
|
||||
#define SETUSERLOCALE_H
|
||||
bool SetUserLocale(void);
|
||||
#endif // SETUSERLOCALE_H
|
||||
@@ -131,20 +131,20 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\MyFunctions\SetUserLocale.cpp" />
|
||||
<ClCompile Include="bulls-and-cows.cpp" />
|
||||
<ClCompile Include="CGame.cpp" />
|
||||
<ClCompile Include="CPrint.cpp" />
|
||||
<ClCompile Include="CStep.cpp" />
|
||||
<ClCompile Include="CUserInput.cpp" />
|
||||
<ClCompile Include="SetUserLocale.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\MyFunctions\SetUserLocale.h" />
|
||||
<ClInclude Include="CGame.h" />
|
||||
<ClInclude Include="CPrint.h" />
|
||||
<ClInclude Include="CStep.h" />
|
||||
<ClInclude Include="CUserInput.h" />
|
||||
<ClInclude Include="defines.h" />
|
||||
<ClInclude Include="SetUserLocale.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LICENSE" />
|
||||
|
||||
@@ -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[])
|
||||
|
||||
Reference in New Issue
Block a user