Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | library dbini32; |
2 | |||
3 | uses |
||
4 | SysUtils, |
||
5 | Classes, |
||
6 | IniFiles, |
||
7 | Windows; |
||
8 | |||
9 | {$R *.res} |
||
10 | |||
11 | var |
||
12 | ini: TMemIniFile = nil; |
||
13 | iniModified: boolean = false; |
||
14 | |||
15 | procedure UnloadINI; cdecl; |
||
16 | begin |
||
17 | if iniModified then ini.UpdateFile; |
||
18 | FreeAndNil(ini); |
||
19 | end; |
||
20 | |||
21 | procedure LoadINI(filename: PAnsiChar); cdecl; |
||
22 | begin |
||
23 | if Assigned(ini) then UnloadINI; |
||
24 | ini := TMemIniFile.Create(filename); |
||
25 | iniModified := false; |
||
26 | end; |
||
27 | |||
28 | function ReadFloat(section, name: PAnsiChar; default: single): DWORD; cdecl; |
||
29 | var |
||
30 | s: single; |
||
31 | begin |
||
32 | s := ini.ReadFloat(section, name, default); |
||
33 | result := DWORD(Pointer(s)); |
||
34 | end; |
||
35 | |||
36 | procedure WriteFloat(section, name: PAnsiChar; value: single); cdecl; |
||
37 | begin |
||
38 | ini.WriteFloat(section, name, value); |
||
39 | iniModified := true; |
||
40 | end; |
||
41 | |||
42 | function ReadInt(section, name: PAnsiChar; default: integer): integer; cdecl; |
||
43 | begin |
||
44 | result := ini.ReadInteger(section, name, default); |
||
45 | end; |
||
46 | |||
47 | procedure WriteInt(section, name: PAnsiChar; value: integer); cdecl; |
||
48 | begin |
||
49 | ini.WriteInteger(section, name, value); |
||
50 | iniModified := true; |
||
51 | end; |
||
52 | |||
53 | exports |
||
54 | LoadINI name 'LoadINI', |
||
55 | ReadFloat name 'ReadFloat', |
||
56 | ReadInt name 'ReadInt', |
||
57 | WriteFloat name 'WriteFloat', |
||
58 | WriteInt name 'WriteInt', |
||
59 | UnloadINI name 'UnloadINI'; |
||
60 | |||
61 | begin |
||
62 | DecimalSeparator := '.'; |
||
63 | end. |