migration
This commit is contained in:
51
semester-4/ОС/lb-3/src/locale/app/main.cpp
Normal file
51
semester-4/ОС/lb-3/src/locale/app/main.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "../locale.h"
|
||||
#include <locale.h>
|
||||
#include <windows.h>
|
||||
|
||||
void print_res_str(HINSTANCE hLib, size_t id) {
|
||||
wchar_t buffer[256] = {0};
|
||||
if (LoadStringW(hLib, id, buffer, sizeof(buffer) / sizeof(wchar_t)))
|
||||
wprintf(L"%ls\n", buffer);
|
||||
else
|
||||
fprintf(stderr, "Error: Can't load string from dll\n");
|
||||
}
|
||||
|
||||
int main() {
|
||||
setlocale(LC_ALL, "ukr");
|
||||
|
||||
printf("Choose language to use\n");
|
||||
printf("\t1 - ua\n");
|
||||
printf("\t2 - en\n");
|
||||
printf("choice: ");
|
||||
|
||||
int lang = getchar() - '0';
|
||||
|
||||
HMODULE hLib = 0;
|
||||
|
||||
if (lang == 1)
|
||||
hLib = LoadLibrary("locale-ua.dll");
|
||||
else if (lang == 2)
|
||||
hLib = LoadLibrary("locale-en.dll");
|
||||
else
|
||||
fprintf(stderr, "Error: No such language\n");
|
||||
|
||||
if (!hLib) {
|
||||
fprintf(stderr, "Error: Can't load dll\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Surname:\t");
|
||||
print_res_str(hLib, ID_SURNAME);
|
||||
|
||||
printf("Faculty:\t");
|
||||
print_res_str(hLib, ID_FACULTY);
|
||||
|
||||
printf("Group:\t\t");
|
||||
print_res_str(hLib, ID_GROUP);
|
||||
|
||||
printf("Discipline:\t");
|
||||
print_res_str(hLib, ID_DISCIPLINE);
|
||||
|
||||
FreeLibrary(hLib);
|
||||
return 0;
|
||||
}
|
35
semester-4/ОС/lb-3/src/locale/en/locale.cpp
Normal file
35
semester-4/ОС/lb-3/src/locale/en/locale.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
||||
switch (fdwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
fprintf(stderr,
|
||||
"DLL loaded into process. hinstDLL = %p, lpvReserved = %p\n",
|
||||
hInstDLL, lpvReserved);
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
fprintf(stderr,
|
||||
"New thread created in the process using the DLL. "
|
||||
"hinstDLL = %p, lpvReserved = %p\n",
|
||||
hInstDLL, lpvReserved);
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
fprintf(stderr,
|
||||
"Thread using the DLL is terminating. hinstDLL = %p, "
|
||||
"lpvReserved = %p\n",
|
||||
hInstDLL, lpvReserved);
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
fprintf(stderr,
|
||||
"DLL unloaded from process. hinstDLL = %p, lpvReserved = "
|
||||
"%p\n",
|
||||
hInstDLL, lpvReserved);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
12
semester-4/ОС/lb-3/src/locale/en/locale.rc
Normal file
12
semester-4/ОС/lb-3/src/locale/en/locale.rc
Normal file
@ -0,0 +1,12 @@
|
||||
#include "../locale.h"
|
||||
#include <windows.h>
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ID_SURNAME "Sytnyk"
|
||||
ID_FACULTY "Computer science"
|
||||
ID_GROUP "PZPI-23-2"
|
||||
ID_DISCIPLINE "Operating Systems"
|
||||
END
|
9
semester-4/ОС/lb-3/src/locale/locale.h
Normal file
9
semester-4/ОС/lb-3/src/locale/locale.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef LOCALE
|
||||
#define LOCALE
|
||||
|
||||
#define ID_SURNAME 100
|
||||
#define ID_FACULTY 101
|
||||
#define ID_GROUP 102
|
||||
#define ID_DISCIPLINE 103
|
||||
|
||||
#endif
|
35
semester-4/ОС/lb-3/src/locale/ua/locale.cpp
Normal file
35
semester-4/ОС/lb-3/src/locale/ua/locale.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
||||
switch (fdwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
fprintf(stderr,
|
||||
"DLL loaded into process. hinstDLL = %p, lpvReserved = %p\n",
|
||||
hInstDLL, lpvReserved);
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
fprintf(stderr,
|
||||
"New thread created in the process using the DLL. "
|
||||
"hinstDLL = %p, lpvReserved = %p\n",
|
||||
hInstDLL, lpvReserved);
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
fprintf(stderr,
|
||||
"Thread using the DLL is terminating. hinstDLL = %p, "
|
||||
"lpvReserved = %p\n",
|
||||
hInstDLL, lpvReserved);
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
fprintf(stderr,
|
||||
"DLL unloaded from process. hinstDLL = %p, lpvReserved = "
|
||||
"%p\n",
|
||||
hInstDLL, lpvReserved);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
12
semester-4/ОС/lb-3/src/locale/ua/locale.rc
Normal file
12
semester-4/ОС/lb-3/src/locale/ua/locale.rc
Normal file
@ -0,0 +1,12 @@
|
||||
#include "../locale.h"
|
||||
#include <windows.h>
|
||||
|
||||
LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ID_SURNAME "Ситник"
|
||||
ID_FACULTY "Комп'ютерних наук"
|
||||
ID_GROUP "ПЗПІ-23-2"
|
||||
ID_DISCIPLINE "Операційні Системи"
|
||||
END
|
Reference in New Issue
Block a user