Shortcut File Name From Which EXE Started

Category: Application Features

Date: 02-16-2022

Return to Index


 
#Include "win32api.inc"
%STARTF_TITLESHORTCUT = 800 'Program was started through a shortcut. The lpTitle contains the shortcut path.
 
Function PBMain() As Long
   ? StartFileName
End Function
 
Function StartFileName() As String
   Local StartupInformation As STARTUPINFO, sMessage As String
   Function = "Not a shortcut"
   StartupInformation.cb = SizeOf(StartupInformation)
   GetStartupInfo(StartupInformation)
   If StartupInformation.dwFlags And %STARTF_TITLESHORTCUT Then
      If LCase$(Right$(StartupInformation.@lpTitle, 4)) = ".lnkThen
         Function = StartupInformation.@lpTitle
      End If
   End If
End Function
 
'gbs_01385
'Date: 10-17-2014               


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm