Skip to content

Commit 21fcb99

Browse files
committed
ввод переменных
1 parent 544a276 commit 21fcb99

3 files changed

Lines changed: 42 additions & 19 deletions

File tree

GuiStep_0/GuiStep_0.cpp

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,47 @@
33
#include <conio.h>
44
#include "../HelloModule_ru_ru/resource.h"
55
#include <locale>
6+
67
int main()
78
{
8-
WCHAR userLanguagesMultiString[] = L"ru-RU\0\0";
9-
DWORD langCount = 0;
10-
HINSTANCE hinstLib;
11-
12-
bool info = GetUILanguageInfo(MUI_LANGUAGE_NAME, userLanguagesMultiString, NULL, 0, &langCount);
13-
if (info)
14-
{
15-
setlocale(LC_ALL, "");
16-
hinstLib = LoadLibrary(TEXT("HelloModule_ru_ru.dll"));
17-
} else
18-
hinstLib = LoadLibrary(TEXT("HelloModule_en_us.dll"));
19-
char qwe[100];
20-
LoadStringA(hinstLib, HELLO_MUI_STR_0, qwe, sizeof(qwe));
21-
22-
printf_s("%s", qwe);
23-
_getch();
24-
return 0;
9+
WCHAR userLanguagesMultiString[] = L"ru-RU\0\0";
10+
DWORD langCount = 0;
11+
HINSTANCE hinstLib;
12+
bool info = GetUILanguageInfo(MUI_LANGUAGE_NAME, userLanguagesMultiString, NULL, 0, &langCount);
13+
setlocale(LC_ALL, "RUS");
14+
15+
16+
hinstLib = LoadLibrary(TEXT("HelloModule.dll"));
17+
18+
wchar_t* desc = NULL;
19+
wchar_t qwe[100];
20+
LoadStringW(hinstLib, HELLO_MUI_STR_0, qwe, sizeof(qwe));
21+
22+
int age;
23+
printf_s("\nВведите возраст:\t");
24+
scanf_s("%d", &age);
25+
26+
wchar_t string[15];
27+
wprintf_s(L"\nВведите имя:\t");
28+
wscanf_s(L"%ls", &string);
29+
30+
DWORD_PTR pArgs[] = { (DWORD_PTR)string ,
31+
(DWORD_PTR)age };
32+
33+
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
34+
qwe,
35+
0,
36+
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
37+
(wchar_t*)&desc,
38+
0,
39+
(va_list*)pArgs);
40+
41+
wprintf(L"%s", desc);
42+
43+
LocalFree(desc);
44+
FreeLibrary(hinstLib);
45+
46+
_getch();
47+
return 0;
2548
}
2649

HelloModule_en_us/HelloModule.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ END
5252

5353
STRINGTABLE
5454
BEGIN
55-
HELLO_MUI_STR_0 "Kotik says meow"
55+
HELLO_MUI_STR_0 "for kotik like you, %1, %2!d! - is the best age"
5656
END
5757

5858
#endif // ������� (������) resources

HelloModule_ru_ru/HelloModule.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ END
5252

5353
STRINGTABLE
5454
BEGIN
55-
HELLO_MUI_STR_0 "����� ���������"
55+
HELLO_MUI_STR_0 "��� ������ ������, ��� ��, %1, %2!d! - �������� �������"
5656
END
5757

5858
#endif // ������� (������) resources

0 commit comments

Comments
 (0)