Read the ini file in .NET

zhaozj2021-02-16  40

Reading the INI file in .NET is consistent, the only note is that the LONG type variable in the API declaration is changed to the int32 type in .NET

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" "WritePrivateProfileStringa" (byval lpapplicationname as string, byval lpstring as string, byval lpfilename as string) AS INT32

Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strIni As String strIni = New String ( "", 100) GetPrivateProfileString ( "AppName", "KeyA", "", strIni , 100, "c: /a.ini") WritePrivateProfileString ("Appname", "Keyb", "MyValue", "c: /a.ini") MSGBOX (STRINI) End Sub

This code is debugged in .NET WIN2000

转载请注明原文地址:https://www.9cbs.com/read-27496.html

New Post(0)