1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
Imports System.Runtime.InteropServices.Marshal
Public Class DataControle
Private Declare Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedBuffer As IntPtr, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Function LireINI(ByVal Entete As String, ByVal Variable As String, ByVal FileINI As String) As String
Dim PtrCh As IntPtr
Dim Lng As Integer
Dim Chaine As String
Try
PtrCh = StringToHGlobalAnsi(New String(vbNullChar, 1024))
Lng = GetPrivateProfileString(Entete, Variable, "", PtrCh, 255, FileINI)
Chaine = PtrToStringAnsi(PtrCh, Lng)
FreeHGlobal(PtrCh)
Return Chaine
Catch ex As Exception
Return "Error in File INI " & vbCrLf & ex.Message
End Try
End Function
End Class |
Partager