Results 1 to 6 of 6

Thread: [2008] Help updating some things

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    34

    [2008] Help updating some things

    Well, thanks to you guys i got my first program up and running, but i want to make a few changes... First of all... I want the program to load previously saved options... so When you save the 4 checkboxes and re-open the program... the most recent ones are still marked... Second.. Not all people have there .ini file always in the C:\Program Files\Silkroad\ So if there is a way to change that so people can select there silkroad directory that would be awesome as well. and i think thats it for now... anyway, heres the code.
    Code:
    Public Class Form1
        Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As String, ByVal lsString As String, ByVal lplFilename As String) As Integer
    
        Sub SaveINISetting(ByVal Filename As String, ByVal Key As String, ByVal Setting As String, ByVal Value As Object)
            WritePrivateProfileString(Key, Setting, Value, Filename)
        End Sub
    
        Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
            SaveINISetting("C:\Program Files\Silkroad\C19H28O2.ini", "Options", "Zoomhack", zoom.CheckState)
            SaveINISetting("C:\Program Files\Silkroad\C19H28O2.ini", "Options", "NudePatch", nude.CheckState)
            SaveINISetting("C:\Program Files\Silkroad\C19H28O2.ini", "Options", "NoDC", disc.CheckState)
            SaveINISetting("C:\Program Files\Silkroad\C19H28O2.ini", "Options", "ChatFilter", chat.CheckState)
            MsgBox("Config successfully saved!")
        End Sub
    
        Private Sub launch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles launch.Click
            Dim ofd As New OpenFileDialog
            ofd.Filter = "EXE File (*.exe)|*.exe"
            ofd.Title = "Select Loader.exe"
            ofd.ShowDialog()
            If ofd.FileName <> "" Then
                Process.Start(ofd.FileName)
            Else
                'User cancelled the dialog
            End If
        End Sub
    
        Private Sub leave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles leave.Click
            Me.Close()
        End Sub
    
        Private Sub link_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles link.LinkClicked
            Process.Start("http://www.7knights.co.nr")
        End Sub
    
        Private Sub info_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles info.Click
            MsgBox("Point your browser to C19H28O2's Loader.exe  V-2.0")
        End Sub
    End Class
    Heres the project if you want it...
    http://rapidshare.com/files/79548144/7K_Launcher.rar

  2. #2
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Lancashire UK
    Posts
    375

    Re: [2008] Help updating some things

    If your only saving the state of four check boxes it would be pretty straightforward to use My.Settings instead on an ini file.
    If my post helps , please feel free to rate it

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    34

    Re: [2008] Help updating some things

    the ini file has to be there... what changes would i have to make so that when you start up my program, that it would read the ini... and have the box checked if an option = 1?

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    34

    Re: [2008] Help updating some things

    *bump*

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    34

    Re: [2008] Help updating some things

    rawr i need help... im stuck and cant go any farther

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: [2008] Help updating some things

    vb.net Code:
    1. Public Class Form1
    2.  
    3.    Public Declare Ansi Function GetPrivateProfileInt _
    4.       Lib "kernel32.dll" Alias "GetPrivateProfileIntA" _
    5.       (ByVal lpApplicationName As String, _
    6.       ByVal lpKeyName As String, ByVal nDefault As Integer, _
    7.       ByVal lpFileName As String) As Integer
    8.  
    9.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    10.       checkbox1.value = CBool(GetPrivateProfileInt("Options", "Zoomhack", _
    11.                false, my.application.info.directorypath & "\C19H28O2.ini"))
    12.       'etc
    13.    End Sub
    14.  
    15.    Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
    16.         SaveINISetting(my.application.info.directorypath & "\C19H28O2.ini", "Options", "Zoomhack", zoom.CheckState)
    17.         SaveINISetting(my.application.info.directorypath & "\C19H28O2.ini", "Options", "NudePatch", nude.CheckState)
    18.         SaveINISetting(my.application.info.directorypath & "\C19H28O2.ini", "Options", "NoDC", disc.CheckState)
    19.         SaveINISetting(my.application.info.directorypath & "\C19H28O2.ini", "Options", "ChatFilter", chat.CheckState)
    20.         MsgBox("Config successfully saved!")
    21.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width