[VFP] 讀ini檔案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
********************
****讀取ini file****
********************
function getinit(mfilename,msection,mentry)
local lcinifile,lcvalue,lcbuffer,luentryvalue,lnnumbytes

*-- DECLARE DLL statements for reading/writing to private INI files
declare integer GetPrivateProfileString in Win32API ;
string cSection, string cKey, string cDefault, string @cBuffer, ;
integer nBufferSize, string cINIFile

local minivalue, mresult, mbuffersize
mbuffersize = 255
minivalue = spac(mbuffersize)
mresult=getprivateprofilestring(msection,mentry,"*NULL*",@minivalue,mbuffersize,mfilename)
minivalue=substr(minivalue,1,mresult)
if minivalue="*NULL*"
minivalue=.null.
endif
return minivalue
endfun

demo config ini file

1
2
[section]
entryName=return value