注释:// private member that holds a reference to 注释:// the path of our ini file private strini as string
注释:// win api declares private declare function writeprivateprofilestring _ lib "kernel32" alias "writeprivateprofilestringa" _ (byval lpapplicationname as string, _ byval lpkeyname as any, _ byval lpstring as any, _ byval lpfilename as string) as long
private declare function getprivateprofilestring _ lib "kernel32" alias "getprivateprofilestringa" _ (byval lpapplicationname as string, _ byval lpkeyname as any, _ byval lpdefault as string, _ byval lpreturnedstring as string, _ byval nsize as long, _ byval lpfilename as string) as long
private function makepath(byval strdrv as string, _ byval strdir as string) as string
注释:// makes an ini file: guarantees a sub dir do while right$(strdrv, 1) = "" strdrv = left$(strdrv, len(strdrv) - 1) loop
do while left$(strdir, 1) = "" strdir = mid$(strdir, 2) loop
注释:// return the path makepath = strdrv & "" & strdir end function
public sub createini(strdrv as string, strdir as string)
注释:// make a new ini file strini = makepath(strdrv, strdir) end sub
public sub writefile(strsection as string, _ strkey as string, _ strvalue as string)
注释:// write to strini writeprivateprofilestring strsection, _ strkey, strvalue, strini end sub
public function getfile(strsection as string, _ strkey as string) as string
public property let inifile(byval new_inipath as string)
注释:// sets the new ini path strini = new_inipath
end property
public property get inifile() as string
注释:// returns the current ini path inifile = strini
end property
注释:--------cinifile.cls 使用举例----------------
dim myinifile as new cinifile
注释:---指定访问的ini文件 if len(app.path) > 3 then 注释:under disk root dir , eg: "c:" myinifile.inifile = app.path & "setting.ini" else myinifile.inifile = app.path & "setting.ini" end if