dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Mar 10, 2001

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


GetAppFilename - Return the application's file name and path

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

' return the application's filename
'
' it is similar to App.Path+App.ExeName, but it also
' works when the program is run on a remote workstation
' (in that case App.Path sometimes fails)
'
' In interpreted mode it returns the VB5 or VB6 executable filename

Function GetAppFilename() As String
    Dim hModule As Long
    Dim buffer As String * 256
    
    ' get the handle of the running application
    hModule = GetModuleHandle(App.EXEName)
    ' get the filename corresponding to that handle
    GetModuleFileName hModule, buffer, Len(buffer)
    GetAppFilename = Left$(buffer, InStr(buffer & vbNullChar, vbNullChar) - 1)
End Function
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date