VB.NET中API下拉框存储中文失败求解答
VB,NET 新建一窗体一个按钮一个下拉框下拉框,GroupBox1中放入三行任何中文,API读写控件
Private 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 Int32, ByVal lpFileName As String) As Int32
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
Dim 存储 As String
Dim 读取 As Long
Dim 内容 As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
内容 = Str(256)
读取 = GetPrivateProfileString("任务目标", "场景", "", 内容, 256, Application.StartupPath & "\数据库.txt")
ComboBox1.Text = 内容
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
存储 = WritePrivateProfileString("任务目标", "场景", ComboBox1.Text, Application.StartupPath & "\数据库.txt")
End Sub
点击按钮发生英文能保存,中文点击一次下拉框中文内容会减少一个中文,直到最后变成问号。难道是VS2015和2017不支持API求教!!!
[此贴子已经被作者于2018-1-31 16:23编辑过]