Results 1 to 3 of 3

Thread: Make an EXE get its own EXE name?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    2

    Make an EXE get its own EXE name?

    Ok, sounds simple.. use app.EXEname

    Trouble is that doesn't work if the user changes the exe file from what it was originaly. For instance, I compile an exe called blabla.exe, now thats fixed as app.EXEname, so if a user changes the exe name to albalb.exe - app.EXEname will still see it as blabla.exe

    Anyhows, I need my program to work with the exe when its run. The first thing the program needs to know is what its own name is.. can someone suggest how to do this?

    Many Thanks...

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    This returns the path + filename of the App. containing this function:

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

    Function ExeName() As String
    Dim Name As String
    Dim hWnd As Long

    Name = Space$(255)
    hWnd = GetModuleHandle(vbNullString)
    GetModuleFileName hWnd, Name, 255
    ExeName = Name

    End Function

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    2
    Thank you so much for your help, that worked perfect. Very much appreciated.

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