Hallo,
ich habe mir nach längerem suchen einen INI Code zusammengebastelt, der beim kompilieren keine Fehler macht, aber beim ausführen des Programms schon.
Vielleicht kann mir ja jemand helfen, denn ich komme nicht weiter
Der Code:
Public Function Leftt(ByVal sText As String, _
ByVal nLen As Integer) As String
If nLen > sText.Length Then nLen = sText.Length
Return (sText.Substring(0, nLen))
End Function
Public Declare Function INIAdd Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As String, ByVal lpString As String, ByVal lpFileName As _
String) As Long
Public Declare Function INIGetAPI Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As _
String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Function INIGet(ByVal Sektion As String, ByVal Titel As String, _
ByVal Vorgabe As String, ByVal INIFile As String, Optional ByVal nSize As _
Integer = 256) As String
Dim lResult As Long
Dim sValue As String
sValue = Space$(nSize)
lResult = INIGetAPI(Sektion, Titel, Vorgabe, sValue, nSize, INIFile)
INIGet = Leftt(sValue, lResult)
End Function
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
Pfad.Text = INIGet("AllgEinstellungen", "Pfad", "", _
Application.StartupPath + "\X.ini")
Bildname.Text = INIGet("AllgEinstellungen", "Bildname", "", _
Application.StartupPath + "\X.ini")
Mime.Text = INIGet("AllgEinstellungen", "Mime", "", _
Application.StartupPath + "\X.ini")
End Sub Hier die Errormeldung:
System.OverflowException: Die arithmetische Operation hat einen Überlauf _
verursacht.
bei ScreenShotR.Main.INIGet(String Sektion, String Titel, String Vorgabe, _
String INIFile, Int32 nSize) in D:\VB\ScreenShot_R\Main.vb:Zeile 32.
bei ScreenShotR.Main.Main_Load(Object sender, EventArgs e) in _
D:\VB\ScreenShot_R\Main.vb:Zeile 39.
bei System.EventHandler.Invoke(Object sender, EventArgs e)
bei System.Windows.Forms.Form.OnLoad(EventArgs e)
bei System.Windows.Forms.Form.OnCreateControl()
bei System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
bei System.Windows.Forms.Control.CreateControl()
bei System.Windows.Forms.Control.WmShowWindow(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bei System.Windows.Forms.ContainerControl.WndProc(Message& m)
bei System.Windows.Forms.Form.WmShowWindow(Message& m)
bei System.Windows.Forms.Form.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, _
IntPtr wparam, IntPtr lparam) MfG Chris |