Private Function GetExeNameFromShortCutPath(ByVal sShortCut As String, Optional bExt As Boolean = True) As String
' sShortCut cible (chemin)
' bExt retourner l'extension ?
GetExeNameFromShortCutPath = vbNullString
sShortCut = Trim$(LCase$(sShortCut))
' on traite SI c'est un exe
Dim iPos As Integer
iPos = InStrRev(sShortCut, ".exe")
If iPos > 0 Then
' on enlève la commande qui peut suivre
If Len(sShortCut) > iPos + 3 Then sShortCut = Left$(sShortCut, iPos + 3)
' extension?
If Not (bExt) Then sShortCut = Left$(sShortCut, Len(sShortCut) - 4)
' dernier slash
iPos = InStrRev(sShortCut, "\")
GetExeNameFromShortCutPath = IIf(iPos = 0, sShortCut, Right$(sShortCut, Len(sShortCut) - iPos))
End If
End Function
' GetExeNameFromShortCutPath("C:\Program Files\MSN Messenger\msnmsgr.exe -start") retourne "msnmsgr.exe"
' GetExeNameFromShortCutPath("C:\Program Files\MSN Messenger\msnmsgr.exe -start", False) retourne "msnmsgr"