Results 1 to 5 of 5

Thread: Working/Start Directory

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    UK
    Posts
    13
    Hi all!
    I'm relatively new to VB and I've just started my first major application but I've run into a problem. Is there a way to find out the working directory, ie. the directory containing the application? I've tried using CurDir() but if the program isn't in the current directory then it doesn't work properly.

    Thanks in advance for any help,

    Greg Nolle.

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    A simple little function by the name of
    Code:
    App.Path

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I believe you are looking for App.Path

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

    Red face Another Approach I Found Somewhere.

    Public Const MAX_PATH = 206

    Public Declare Function GetModuleHandle Lib _
    "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) _
    As Long
    Public Declare Function GetModuleFileName Lib _
    "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, _
    ByVal lpFileName As String, ByVal nSize As Long) As Long

    'App.Path is not always reliable, especially on a network.
    'Try using GetModuleFileName API call to avoid the problem

    Dim lngFileHandle As Long
    Dim lngReturn As Long
    Dim strFilePath As String

    strFilePath = Space$(MAX_PATH)
    lngFileHandle = GetModuleHandle(App.EXEName)
    lngReturn = GetModuleFileName(lngFileHandle, strFilePath, MAX_PATH)
    MsgBox strFilePath
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    UK
    Posts
    13
    Thanks all of you for your help. App.Path worked perfectly since I don't need it to work on a network.

    Thanks again,

    Greg.

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