by Anonymous (267 Submissions)
Category: Windows System Services
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Sat 16th January 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Use GetModuleFileName API call to find the location your executable, since App.Path can return erroneous results.
API Declarations
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
'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
No comments have been posted about Use GetModuleFileName API call to find the location your executable, since App.Path can return erro. Why not be the first to post a comment about Use GetModuleFileName API call to find the location your executable, since App.Path can return erro.