Public declare function writeprivateprofilestring lib "Kernel32" alias "writeprivateprofilestringa" (byval lpapplicationname as string, byval lpkeyname as any, byval lpstring as any, byval lpfilename as string) as longpublic declare function getprivateprofilestring lib "Kernel32" alias "Expiration" (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 longprivate const mc_strinifilename as string = "myini. ini "Public sub writeini (appname as string, keyname as string, valuenew as string) 'dim X as long dim strinifile as string if right (App. path, 1) = "\" then strinifile = app. path & mc_strinifilename else strinifile = app. path & "\" & mc_strinifilename end if x = writeprivateprofilestring (appname, keyname, valuenew, strinifile) debug. print xend subpublic function getini (appname as string, keyname as string) as string 'dim strdefault as string dim lngbufflen as long dim strresu as string dim X as long dim strinifile as string if right (App. path, 1) = "\" then strinifile = app. path & mc_strinifilename else strinifile = app. path & "\" & mc_strinifilename end if strresu = string (1025, vbnullchar): lngbufflen = 1025 strdefault = "" X = getprivateprofilestring (appname, keyname, strdefault, strresu, lbufflen, Len, strinifile) debug. print x debug. print strresu getini = left (strresu, x) end Function
Version 5.00 begin VB. form form1 caption = "form1" clientheight = 2085 clientleft = 60 clienttop = 345 clientwidth = 4680 linktopic = "form1" scaleheight = 2085 scalewidth = 4680 startupposition = 3' window default begin VB. textbox text3 Height = 495 left = 1560 tabindex = 4 Top = 1440 width = 1215 end begin VB. textbox text2 Height = 495 left = 1560 tabindex = 3 Top = 720 width = 1215 end begin VB. textbox text1 Height = 495 left = 1560 tabindex = 2 Top = 0 width = 1215 end begin VB. commandbutton command2 caption = "read key value" Height = 495 left = 3240 tabindex = 1 Top = 1440 width = 1215 end begin VB. commandbutton command1 caption = "write key value" Height = 495 left = 3240 tabindex = 0 Top = 720 width = 1215 end begin VB. label label3 caption = "value" Height = 495 left = 120 tabindex = 7 Top = 1440 width = 1215 end begin VB. label label2 caption = "key name" Height = 495 left = 120 tabindex = 6 Top = 720 width = 1215 end begin VB. label label1 caption = "segment name" Height = 495 left = 120 tabindex = 5 Top = 0 width = 1215 endendattribute vb_name = "form1" attribute vb_globalnamespace = falseattribute vb_creatable = falseattribute plaintext = trueattribute vb_exposed = falseprivate sub commandementclick () 'writeini text1.text, text2.text, text3.text end subprivate sub command2_click () 'text3.text = getini (text1.text, text2.text) end sub