您的位置:首页 > 其它

读取 Win.ini 文件是的指定节中的键 (RMH)

2008-02-25 11:51 351 查看
lcSection = "Mail" && section name
lcKeys = getKeysString (lcSection)

CREATE CURSOR csWinIni (keyname C(30), keyvalue C(200))

lcKey = ""
FOR ii=1 TO Len(lcKeys)
ch = SUBSTR (lcKeys, ii,1)
IF ch = Chr(0)
lcValue = GetKeyValue(lcSection, lcKey)
INSERT INTO csWinIni VALUES (lcKey, lcValue)
lcKey = ""
ELSE
lcKey = lcKey + ch
ENDIF
ENDFOR

SELECT csWinIni
GO TOP
BROW NORMAL NOWAIT

FUNCTION getKeysString (lcSection)
* returns all key names found in this section
* delimited with zero character

* Notice that lpKeyName declared as INTEGER
* to emulate an empty key name

DECLARE INTEGER GetProfileString IN kernel32;
STRING lpAppName,;
INTEGER lpKeyName,;
STRING lpDefault,;
STRING @ lpReturnedString,;
INTEGER nSize

nSize = 1024
lpReturnedString = Repli (Chr(0), nSize)

lnResult = GetProfileString (lcSection, 0, "#empty#",;
@lpReturnedString, nSize)
RETURN Left(lpReturnedString, lnResult)

FUNCTION GetKeyValue (lcSection, lcKey)

* Notice that lpKeyName declared as STRING
* because here we have a string value
* supplied to this procedure

DECLARE INTEGER GetProfileString IN kernel32;
STRING lpAppName,;
STRING lpKeyName,;
STRING lpDefault,;
STRING @ lpReturnedString,;
INTEGER nSize

nSize = 4096
lpReturnedString = Repli (Chr(0), nSize)

lnResult = GetProfileString (lcSection, lcKey, "#empty#",;
@lpReturnedString, nSize)
RETURN Left(lpReturnedString, lnResult)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: