中文路径下使用WritePrivateProfileString时的问题
'API函数Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, _
ByVal lpFileName As String) As Int32
如果lpFileName中包含有中文,则连续读几次,lpFileName会发生改变,如下面的情况
Dim filename As String = "D:\测试中文路径\TestChinesePath\TestChinesePath\bin\Debug\test.ini"
Private Sub WriteBt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WriteBt.Click
这里的filename还是正确的
WritePrivateProfileString("config", "test1", "test1", filename)
从这里开始filename变成了"D:\测试中文路径\TestChinesePath\TestChinesePath\bin\Debug\te"
具体情况可能有所不同,但就是丢掉了一部分
WritePrivateProfileString("config", "test2", "test1", filename)
WritePrivateProfileString("config", "test3", "test1", filename)
WritePrivateProfileString("config", "test4", "test1", filename)
End Sub
如果把程序放在完全英文路径下就没问题,是不是WritePrivateProfileString函数不支持中文路径的