read configuration from own exefile

Everything else that doesn't fall into one of the other PB categories.
brainbuster
New User
New User
Posts: 6
Joined: Wed Mar 16, 2005 1:47 pm

read configuration from own exefile

Post by brainbuster »

Hi

I want to make my executable read a string from itself.

the string is added like this:"CONFstringCONF" to the end of the exe by another program.
i did this often on VB6 but got no clue how to do it in PB
in vb the function looked like this:

Code: Select all

Function readsett(configname)
On Error Resume Next
  Dim FileNumber As Integer
    Dim SplitConfig() As String
    Dim ReadString As String
    Dim FileNameConfig As String
FileNumber = FreeFile

    Open App.Path & "\" & App.EXEName & ".exe" For Binary Shared As #FileNumber
        ReadString = Space$(100001)
        Get #FileNumber, LOF(FileNumber) - 100000, ReadString
        SplitConfig = Split(ReadString, configname)
        readsett = SplitConfig(1)
    Close #FileNumber
End Function
it reads the whole data into a string and searches it for "CONF" to get the string between CONF.

Is there any quick way of doing this in PB? i'm sure it is possible.

thx for any help :roll:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: read configuration from own exefile

Post by PB »

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Locked