Results 1 to 6 of 6

Thread: Callers EXEname in DLL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Stockholm, Sweden
    Posts
    83
    How do I get the EXEname in a DLL from the one calling it ?
    I want it to be able to do a log in the Event Log
    Yesterday, all my troubles seemed so far away...
    Help, I need somebody, Help...
    Now MCSD and still locking for intresting job in the south parts of Stockholm, Sweden.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Simply call the GetModuleFileName. This API function returns the path and name for the file that created the calling process when you pass NULL as the module handle.
    Code:
    Private Declare Function GetModuleFileName _
     Lib "kernel32" Alias "GetModuleFileNameA" ( _
     ByVal hModule As Long, _
     ByVal lpFileName As String, _
     ByVal nSize As Long) As Long
    
    Private Function GetCallerName() As String
        Dim sAppPath As String
        Const MAX_PATH = 260
    
        sAppPath = Space$(MAX_PATH)
        GetModuleFileName 0&, sAppPath, MAX_PATH
        sAppPath = Left$(sAppPath, InStr(sAppPath, vbNullChar) - 1)
        GetCallerName = sAppPath
    End Function
    Good luck!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Stockholm, Sweden
    Posts
    83
    Thanks Joacim, you always has an answer.

    I get VB6.EXE in the IDE but the rigth name then it is compiled ! Thanks again.
    Yesterday, all my troubles seemed so far away...
    Help, I need somebody, Help...
    Now MCSD and still locking for intresting job in the south parts of Stockholm, Sweden.

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by AKA
    Thanks Joacim, you always has an answer.

    I get VB6.EXE in the IDE but the rigth name then it is compiled ! Thanks again.
    I'm not sure I understood that last part but your welcome.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Stockholm, Sweden
    Posts
    83
    I meant the folowing :
    In the IDE I get VB6.EXE as the file doing the call from GetModuleFileName but then I compile my program I get my own program name.
    Yesterday, all my troubles seemed so far away...
    Help, I need somebody, Help...
    Now MCSD and still locking for intresting job in the south parts of Stockholm, Sweden.

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Oh yeah, of course, I should have mentioned that.

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