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
Printable View
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
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.
Good luck!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
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.Quote:
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 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.
Oh yeah, of course, I should have mentioned that.