-
Notifications
You must be signed in to change notification settings - Fork 0
/
properties.hpp
41 lines (38 loc) · 992 Bytes
/
properties.hpp
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
#pragma once
class Properties
{
public:
char fname[MAX_PATH];
Properties(char *file = NULL)
{
if (file == NULL)
{
int fs = ::GetModuleFileName(NULL, fname, MAX_PATH);
//*((int*)(fname+fs-3)) = MAKEFOURCC('i','n','i',0);
strcpy(fname+fs-3, "ini");
}
else
{
strncpy_s(fname, file, MAX_PATH);
}
}
int GetString(char *section, char *property, char *returned, int maxsize, char *def = NULL)
{
char *d = "";
if (def == NULL) def = d;
return ::GetPrivateProfileString(section, property, def, returned, maxsize, fname);
}
int GetInt(char *section, char *property, int def = 0)
{
return ::GetPrivateProfileInt(section, property, def, fname);
}
void SetString(char *section, char *property, char *value)
{
::WritePrivateProfileString(section, property, value, fname);
}
void SetInt(char *section, char *property, int value)
{
char buf[40];
SetString(section, property, itoa(value, buf, 10));
}
};