Results 1 to 6 of 6

Thread: want to know the location of my application

  1. #1
    manishmenghani
    Guest
    I want to know on which location my application is running and I don't want to use application.path , i want is there any API that can tell the location ?

  2. #2
    He-M@n
    Guest

    Here is some code try it out

    Private Declare Function GetCurrentDirectory Lib "kernel32" Alias "GetCurrentDirectoryA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    Private Sub Form_Paint()
    Dim sSave As String
    'create a buffer
    sSave = String(255, 0)
    'retrieve the current directory
    GetCurrentDirectory 255, sSave
    MsgBox sSave
    End Sub

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    What's with the Form_Paint()
    event.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    He-M@n
    Guest

    Not important!

    Thats just an example.
    You can also take use of "form_load" or " command1_click" instead of "form_paint".

  5. #5
    Megatron
    Guest
    Originally posted by manishmenghani
    I want to know on which location my application is running and I don't want to use application.path , i want is there any API that can tell the location ?
    What's wrong with App.Path??

  6. #6
    Tygur
    Guest
    Using GetCurrentDirectory is not the same as using App.Path.

    App.Path always returns the directory your exe is located in.

    The GetCurrentDirectory API will return the current directory for the program.

    If you make a shortcut to your exe file and set the "Start in" directory to be something other than the directory your program is in, App.Path and GetCurrentDirectory will have different results when you run your program from the shortcut.

    By the way, you can use the CurDir function. It will do the same thing as the GetCurrentDirectory API. You might want to do that anyway, because He-M@n forgot to include code to get rid of the nulls at the end of the string returned by GetCurrentDirectory.

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