-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadditional.cpp
79 lines (65 loc) · 1.97 KB
/
additional.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "additional.hpp"
static HINSTANCE g_hInstance=NULL;
static char temporaryBuffer[MAX_BUFFER_COUNT][MAX_TEMP_SIZE];
std::string winVersionString(void) {
std::string temp="Windows ";
char conv[8];
DWORD dwVersion = 0;
DWORD dwMajorVersion = 0;
DWORD dwMinorVersion = 0;
DWORD dwBuild = 0;
dwVersion=GetVersion();
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
ltoa(dwMajorVersion,conv,10);
temp=temp+conv+'.';
ltoa(dwMinorVersion,conv,10);
temp=temp+conv;
if(dwVersion<0x80000000) {
dwBuild = (DWORD)(HIWORD(dwVersion));
ltoa(dwBuild,conv,10);
temp=temp+'.'+conv;
}
return temp;
}
std::string makeUserAgent(char* userAgent) {
std::string temp=userAgent;
temp=temp+" ("+winVersionString()+")";
return temp;
}
std::string getCurrentDirectory(char* input) {
std::string currentDirectory="";
unsigned int pos=0;
for(int x=strlen(input)-1; x>=0; --x) {
if(input[x]=='\\') {
pos=x;
break;
}
}
for(unsigned int x=0; x<pos+1; ++x) {
currentDirectory=currentDirectory+input[x];
}
return currentDirectory;
}
std::string getCodePage(void) {
char langInfo[16];
GetLocaleInfoA(LOCALE_USER_DEFAULT,LOCALE_IDEFAULTANSICODEPAGE,langInfo,16);
return (std::string)langInfo;
}
std::string getLangName(void) {
char langInfo[16];
GetLocaleInfoA(LOCALE_USER_DEFAULT,LOCALE_SABBREVLANGNAME,langInfo,16);
return (std::string)langInfo;
}
void storeStringTableInstance(HINSTANCE hInstance) {
g_hInstance=hInstance;
return;
}
char* getStringFromTable(UINT stringID, unsigned short int whichBuffer) {
if(LoadString(g_hInstance,stringID,temporaryBuffer[whichBuffer],MAX_TEMP_SIZE)) {
return temporaryBuffer[whichBuffer];
}
else {
return NULL;
}
}