Mira este ejemplo sacado de la Api-Guide
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 GetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Integer
Const GWW_HINSTANCE = (-6)
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail:
[email protected]
Dim ModuleName As String, FileName As String, hInst As Long
'create a buffer
ModuleName = String$(128, Chr$(0))
'get the hInstance application:
hInst = GetWindowWord(Me.hwnd, GWW_HINSTANCE)
'get the ModuleFileName:
'enter the following two lines as one, single line:
ModuleName = Left$(ModuleName, GetModuleFileName(hInst, ModuleName, Len(ModuleName)))
'set graphics mode to persistent
Me.AutoRedraw = True
'show the module filename
Me.Print "Module Filename: " + ModuleName
End Sub