Added external SetUserLocale() function into project.

This commit is contained in:
2024-07-26 21:06:11 +03:00
parent b0607e3a05
commit f52d7bd6a3
4 changed files with 32 additions and 3 deletions

View 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;
}

View File

@@ -0,0 +1,7 @@
// SetUserLocale.h
//
#pragma once
#ifndef SETUSERLOCALE_H
#define SETUSERLOCALE_H
bool SetUserLocale(void);
#endif // SETUSERLOCALE_H

View File

@@ -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" />

View File

@@ -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[])