mirror of
https://github.com/Gamer2020/PokemonGameEditor.git
synced 2026-09-12 04:25:10 -05:00
Seems that when I added the code that outputed when an offset was missing I broke added programs. Should be working again.
59 lines
2.3 KiB
VB.net
59 lines
2.3 KiB
VB.net
Module INI
|
|
Private Declare Ansi Function GetPrivateProfileString _
|
|
Lib "kernel32.dll" Alias "GetPrivateProfileStringA" _
|
|
(ByVal lpApplicationName As String, _
|
|
ByVal lpKeyName As String, ByVal lpDefault As String, _
|
|
ByVal lpReturnedString As System.Text.StringBuilder, _
|
|
ByVal nSize As Integer, ByVal lpFileName As String) _
|
|
As Integer
|
|
Private Declare Ansi Function WritePrivateProfileString _
|
|
Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _
|
|
(ByVal lpApplicationName As String, _
|
|
ByVal lpKeyName As String, ByVal lpString As String, _
|
|
ByVal lpFileName As String) As Integer
|
|
Private Declare Ansi Function GetPrivateProfileInt _
|
|
Lib "kernel32.dll" Alias "GetPrivateProfileIntA" _
|
|
(ByVal lpApplicationName As String, _
|
|
ByVal lpKeyName As String, ByVal nDefault As Integer, _
|
|
ByVal lpFileName As String) As Integer
|
|
Private Declare Ansi Function FlushPrivateProfileString _
|
|
Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _
|
|
(ByVal lpApplicationName As Integer, _
|
|
ByVal lpKeyName As Integer, ByVal lpString As Integer, _
|
|
ByVal lpFileName As String) As Integer
|
|
|
|
Public Function GetString(ByVal strFilename As String, ByVal Section As String,
|
|
ByVal Key As String, ByVal [Default] As String) As String
|
|
|
|
GetString = ""
|
|
|
|
Dim intCharCount As Integer
|
|
Dim objResult As New System.Text.StringBuilder(256)
|
|
intCharCount = GetPrivateProfileString(Section, Key,
|
|
[Default], objResult, objResult.Capacity, strFilename)
|
|
If intCharCount > 0 Then GetString =
|
|
Left(objResult.ToString, intCharCount)
|
|
|
|
|
|
'This should probably be commented out if used for another program!
|
|
If LoadedROM <> "" Then
|
|
If GetString = "" And GetINIFileLocation() = strFilename Then
|
|
OutPutError("Error! " & Key & " is missing for ROM " & Section & "!")
|
|
End If
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Function WriteString(ByVal strFilename As String, ByVal Section As String, _
|
|
ByVal Key As String, ByVal Value As String)
|
|
WritePrivateProfileString(Section, Key, Value, strFilename)
|
|
Flush(strFilename)
|
|
WriteString = ""
|
|
End Function
|
|
|
|
Private Sub Flush(ByVal thing As String)
|
|
FlushPrivateProfileString(0, 0, 0, thing)
|
|
End Sub
|
|
|
|
End Module
|