Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
Enum Equates Singular
IDC_Button = 500
IDC_TextBox
End Enum
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Find Associated EXE",300,300,300,100, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button,"Find EXE", 50,10,100,20
Control Add TextBox, hDlg, %IDC_TextBox, "txt", 50,40,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local temp$
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Button
Control Get Text hDlg, %IDC_TextBox To temp$
temp$ = GetOpenApp(temp$)
? IIf$( Len(temp$)>32, temp$, "Associated EXE Unknown")
End Select
End Select
End Function
Function GetOpenApp(temp$) As String
Local fName, TargetEXE As WStringZ * %Max_Path, iResult As Long
fName = "xxxxxx." + temp$
Open fName For Output As #1
Close #1
iResult = FindExecutable (fName, ByVal 0, TargetEXE)
Kill fName
If iResult > 32 Then Function = TargetExe
End Function
'gbs_01453
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm