ini 檔案的讀寫

2021-05-25 04:39:30 字數 757 閱讀 6270

'strfilename=ini檔名

'strsection=[節名稱]

'strkey=鍵名

'strvalue=鍵值

public function iniwritekey(strfilename as string, strsection as string, strkey as string, strvalue as string) as boolean

'    iniwritekey = writeprivateprofilesection(strsection, strkey, strfilename)

iniwritekey = writeprivateprofilestring(strsection, strkey, strvalue, strfilename)

end function

public function inireadkey(strfilename as string, strsection as string, strkey as string) as string

dim key as string * 255 '返回的鍵值,失敗時返回字串 "false"

dim c as integer

c = getprivateprofilestring(strsection, strkey, "false", key, len(key), strfilename)

inireadkey = replace(key, chr(0), "")

end function

INI檔案讀寫

一 有必要了解ini檔案的結構 注釋 小節名 關鍵字 值 ini檔案允許有多個小節,每個小節又允許有多個關鍵字,後面是該關鍵字的值。值的型別有三種 字串 整型數值和布林值。其中字串存貯在ini檔案中時沒有引號,布林真值用1表示,布林假值用0表示。注釋以分號 開頭。二 定義 1 在inte ce的us...

讀寫ini檔案

using system using system.io using system.text using system.configuration using system.runtime.interopservices using system.collections.specialized us...

讀寫ini檔案

using system using system.io using system.text using system.configuration using system.runtime.interopservices using system.collections.specialized us...