Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IPconfig
#5
put this in an ini file somewhere:
Code:
[IPCONFIG]
IP=127.0.0.1
PORT=4000

load up the client project.

Somewhere in modDatabase, add this:

Code:
Public Function GetVar(File As String, _
                       Header As String, _
                       Var As String) As String
Dim sSpaces  As String  ' Max string length
Dim szReturn As String  ' Return default value if not found
    szReturn = vbNullString
    sSpaces = Space$(5000)
    GetPrivateProfileString Header, Var, szReturn, sSpaces, Len(sSpaces), File
    GetVar = RTrim$(sSpaces)
    GetVar = Left$(GetVar, Len(GetVar) - 1)
End Function

Code:
Public Sub PutVar(File As String, _
                  Header As String, _
                  Var As String, _
                  Value As String)
    WritePrivateProfileString Header, Var, Value, File
End Sub

That will allow you to read and write to ini files.

In Sub TCPInit, replace this:

Code:
frmMirage.Socket.RemoteHost = GAME_IP
    frmMirage.Socket.RemotePort = GAME_PORT

With this:

Code:
Dim filename As String
    filename = App.Path & "\config.ini"

frmMirage.Socket.RemoteHost = GetVar(filename, "IPCONFIG", "IP")
    frmMirage.Socket.RemotePort = Val(GetVar(filename, "IPCONFIG", "PORT"))

Not tested, so tell me if you get any errors. When you make your IP Config form (If you make one), use the PutVar call to write to the ini file.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)