Article ID: 150211
Article Last Modified on 7/15/2004
If App.FileDescription = "EXE" Then
MsgBox "I am an EXE"
ElseIf App.FileDescription = "DLL" Then
MsgBox "I am a DLL"
End If
#If EXE Then
Msgbox "I am an EXE"
#Else
MsgBox "I am a DLL"
#EndIf
EXE=1
EXE=0
Private Declare Function GetModuleFileName Lib "kernel32" Alias _
"GetModuleFileNameA" (ByVal hModule As Long, _
ByVal lpFileName As String, ByVal nSize As Long) As Long
Option Compare Text
Private Sub Form_Click()
Dim sFilePath As String * 255
Dim sVarFilePath As String
Dim sFileExt As String
GetModuleFileName App.hInstance, sFilePath, Len(sFilePath)
'Trim out the trailing characters
sVarFilePath = Trim(sFilePath)
'Capture the file extension
sFileExt = Mid(sVarFilePath, Len(sVarFilePath) - 3, 3)
'Make the comparison
If sFileExt = "EXE" Then
MsgBox "I am an EXE"
Else
MsgBox "I am a DLL"
End If
End Sub
Additional query words: kbVBp400 kbVBp500 kbVBp600 kbVBp kbdsd kbDSupport KBWIN32SDK KBAPI
Keywords: kbhowto KB150211