|
ご指導ありがとうございます
教えていただいたHPを見ましたが すみません。不勉強で理解できませんでした。
そこで Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" ( ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Const DEF_STR As String = vbNullString Dim buffer As String = New String(" ", 255) 'Spaceが1024文字 Dim iniFileName As String = "C:\Users\Owner\Documents\test.ini" 'INIファイル名 Dim ret As Integer = GetPrivateProfileString("SAMPLE", "key2", DEF_STR, buffer, 256, iniFileName)
Dim strVal As String = buffer.Substring(0, buffer.IndexOf(vbNullChar)) Label1.Text = strVal
End Sub
で test.ini
[SAMPLE] key1=12534 key2=C:\Users\Owner\Documents\test.ini漢字
を読めば
C:\Users\Owner\Documents\test.ini貍「蟄・
になってしまいます 何処がおかしいでしょうか?
|