Results 1 to 3 of 3

Thread: Get Directory

  1. #1

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Arrow

    Ok, try to stay with me...
    I want to load INI files into a Text Box, but how can I make it so when I write the INI's Path it will be in a different directory than my exe? For example... C:\MyApp\Files\MyFile.ini
    I want to know this because when the user installs the exe, I don't know where they are ganna install the app. I remember seeing this somewhare and it was about one line code...
    Thnaks!
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    you want it all in the appPath

    Dim AppPath$

    If Right(App.Path, 1) <> "\" Then
    AppPath = App.Path & "\"
    Else
    AppPath = App.Path

    End If

    save your file to AppPath & filename.ext

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    Here is how to read and write an INI:

    Code:
    Public Declare Function GetPrivateProfileString 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 Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    
    
    Public Function readini(strsection As String, strkey As String, strfullpath As String) As String
       Dim strbuffer As String
       Let strbuffer$ = String$(750, Chr$(0&))
       Let readini$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
    End Function
    
    Public Sub writeini(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
        Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
    End Sub
    
    Usage:
    
    Call writeini("MyINI.ini", "Directory", "" & App.Path & "", "C:\MyINI.ini")
    
    Text1.text = readini("MyINI.ini", "Directory", "C:\MyINI.ini")

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