分类：电脑/网络-程序设计
问题：会vb的看看啊！我想用一个文本文件保存密码（先用明码不考虑保密性 
我想用一个文本文件保存密码（先用明码不考虑保密性），比如：有个文件叫做izhi.ini里面有[normal]password=helloworldfilesway=c:\windows\system32\sol.exe那我该怎么读取文件。有比如我要通过程序改写内容，有什么代码，
回答：用读写INI文件的函数。例，在Form上加两个Text控件。Text1用来显示password；Text2用来显示filesway。Form_Load的时候在界面上显示INI文件里的内容；Form_UnLoad的时候在INI文件里保存界面上的内容。把INI文件放到程序的目录下（第一次运行的时候没有也行）。写代码：'函数声明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 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'读INI文件Function getProfileString(ByVal section As String, ByVal key As String, ByVal def As String) As StringDim ret As Stringret = Space(256)GetPrivateProfileString section, key, def, ret, Len(ret), App.Path & "\peizhi.ini"getProfileString = Trim(ret)End Function'写INI文件Function writeProfileString(ByVal section As String, ByVal key As String, ByVal val As String)WritePrivateProfileString section, key, val, App.Path & "\peizhi.ini"End FunctionPrivate Sub Form_Load()Text1.Text = getProfileString("normal", "password", "")Text2.Text = getProfileString("normal", "filesway", "")End SubPrivate Sub Form_Unload(Cancel As Integer)writeProfileString "normal", "password", Text1.TextwriteProfileString "normal", "filesway", Text2.TextEnd Sub