Page 1 of 1
[WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Fri Dec 20, 2024 9:10 am
by boddhi
I searched the forum for similar code but couldn't find it.
So, hoping it's not redundant and for all intents and purposes.
Note: Closing the PB application closes all open "File Properties" dialogs.
Tested on PB 6.12 x64 - Win10 x64
Code: Select all
EnableExplicit
;
Procedure ShowFileProperties(filename.s)
Protected.SHELLEXECUTEINFO SHEX
With SHEX
\cbSize = SizeOf(SHELLEXECUTEINFO)
\fMask = #SEE_MASK_INVOKEIDLIST
\hwnd = 0
\lpVerb = @"properties"
\lpFile = @fileName
\lpParameters = 0
\lpDirectory = 0
\nShow = #SW_SHOWNORMAL
\hInstApp = 0
\lpIDList = 0
\lpClass = 0
\hkeyClass = 0
\dwHotKey = 0
\hIcon = 0
\hProcess = 0
EndWith
If ShellExecuteEx_(@SHEX) = 0
MessageRequester("File properties","Error "+Str(GetLastError_()) + Chr(10) + "Unable to open file properties")
EndIf
EndProcedure
;
Define.l Event
If OpenWindow(0, 0, 0, 222, 70, "File properties", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 200, 20, "File #1 properties")
ButtonGadget(1, 10, 40, 200, 20, "File #2 properties")
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow : Break
Case #PB_Event_Gadget
Select EventGadget()
Case 0 : ShowFileProperties(#PB_Compiler_Home+"Examples\Sources\Data\PureBasic.bmp")
Case 1 : ShowFileProperties(#PB_Compiler_Home+"Examples\Sources\Data\PureBasicLogo.bmp")
EndSelect
EndSelect
ForEver
EndIf
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Fri Dec 20, 2024 11:05 am
by Axolotl
@boddhi,
thanks for sharing.
BTW: What do you use for searching?
I used my favorite way and tried this: SHELLEXECUTEINFO site:purebasic.fr/english
and found that:
Show file Properties/Info dialog?
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Fri Dec 20, 2024 12:53 pm
by boddhi
Hello Axolotl,
I tried with keywords "windows file properties dialog site:
www.purebasic.fr".
I never specify (perhaps wrongly) the language of the forum in order to retrieve results from the French (I'm French) and German forums.
My searches have returned many pages of results and I didn't see the post you've mentioned.
I finally try in other way, found a source in other language coding and adapted it.
Sorry for the redundant post and this less complete code.
Happy holidays to you, PB team and all.

Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Fri Dec 20, 2024 9:34 pm
by Shardik
There were also at least two other examples posted which display the "File properties" dialog:
- German forum by
PBZecke from 2006
- English forum by
nco2k from 2011
I only had to search for them in my huge collection of examples from the English and German PureBasic forums. I collected interesting examples for Linux, MacOS, Windows and Cross-platform from 2005 to 2013. After 2013 I unfortunately didn't have the time anymore to test and save every interesting example code in both forums.
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Sat Dec 21, 2024 1:28 pm
by blueb
Shardik..
I have a pretty big collection also.
My 'Handy Stuff' folders property box says:
Size on Disk: 10.0 GB
Contains: 90,163 files and 10,274 folders
I'm sure a lot of it may be outdated... but still very, very handy.
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Sun Dec 22, 2024 12:07 am
by BarryG
@boddhi: The only problem is the Properties window closes if your app closes. Any way to prevent that?
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Sun Dec 29, 2024 9:06 pm
by Kwai chang caine
Works here
Interesting, thanks for sharing

Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Mon Dec 30, 2024 4:44 pm
by Quin
Tested and working on Windows 10 21H2. Thanks for sharing!
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Mon Dec 30, 2024 6:37 pm
by Jacobus
Another possibility
Code: Select all
Procedure FileProperty(File$)
verb$ = "properties"
SEI.SHELLEXECUTEINFO
SEI\cbSize = SizeOf(SHELLEXECUTEINFO)
SEI\fMask = #SEE_MASK_NOCLOSEPROCESS | #SEE_MASK_INVOKEIDLIST | #SEE_MASK_FLAG_NO_UI
SEI\lpVerb = @verb$
SEI\lpFile = @File$
ShellExecuteEx_(@SEI)
EndProcedure
Define.l Event
If OpenWindow(0, 0, 0, 222, 70, "File properties", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0,10,10,200,50,"Select a file to know its properties")
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow : Break
Case #PB_Event_Gadget
Select EventGadget()
Case 0
File$ = OpenFileRequester("Select a file","c:\","*.*",WindowID(0))
If File$
FileProperty(File$)
EndIf
EndSelect
EndSelect
ForEver
EndIf
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Tue Jan 14, 2025 2:10 pm
by boddhi
Hello everybody,
Happy New Year to all and lots of programming fun!
BarryG wrote:
@boddhi: The only problem is the Properties window closes if your app closes. Any way to prevent that?
boddhi wrote:
Note: Closing the PB application closes all open "File Properties" dialogs.
I had clarified this point on my post and, alas, I don't have a solution. I'm not an API expert and I've tried every possible constant... always with the same result. (To tell the truth, personally, I don't mind as long as I run this code in one of my applications and there's no need for the ‘Properties’ windows to remain open when this app is closed).
I have, however, tested all the other codes whose links were provided by our friends, and they all behave in the same way. Once again, I'm not a specialist, but I can suppose that all instances created are fundamentally attached to the application that launched them, and that closing it necessarily means closing said instances. But maybe I'm wrong...
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Wed Jan 15, 2025 9:21 pm
by robertfern
I do have the Macintosh version to open file info windows, if you are interested?
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Thu Jan 16, 2025 10:49 pm
by Quin
robertfern wrote: Wed Jan 15, 2025 9:21 pm
I do have the Macintosh version to open file info windows, if you are interested?
I would definitely be interested, I was wondering how to do this just a week or so ago..
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Thu Jan 16, 2025 11:16 pm
by Shardik
Quin wrote: Thu Jan 16, 2025 10:49 pm
robertfern wrote: Wed Jan 15, 2025 9:21 pm
I do have the Macintosh version to open file info windows, if you are interested?
I would definitely be interested, I was wondering how to do this just a week or so ago..
I already posted
two examples about 10 years ago.
Re: [WINDOWS ONLY] Launch Windows "File properties" dialog
Posted: Thu Jan 16, 2025 11:21 pm
by robertfern
Shardik had already had a version for mac on this topic
viewtopic.php?p=467833#p467833
it is the second example in his post.
It can also be done by running an AppleScript
Code is from Piero.
Code: Select all
EnableExplicit
Structure daResults : Out.s : Err.s : ExC.w : EndStructure
Global Sh.daResults
Procedure shShell(ShellCommand$, AddLF = #False)
Protected Err$, tmper$, Output$, shell, Exc.w =-1 ; exit code -1 on failed launch
shell = RunProgram("/bin/sh","","",
#PB_Program_Open | #PB_Program_Write | #PB_Program_Read | #PB_Program_Error)
If shell
WriteProgramStringN(shell,ShellCommand$)
WriteProgramData(shell,#PB_Program_Eof,0)
While ProgramRunning(shell)
If AvailableProgramOutput(shell)
Output$ + ReadProgramString(shell)
If AddLF : Output$ + "\n" : EndIf
EndIf
tmper$ = ReadProgramError(shell)
If tmper$ : Err$ + tmper$ + "\n" : EndIf
Wend
Exc = ProgramExitCode(shell) : CloseProgram(shell)
EndIf
Sh\Out = Output$ : Sh\Err = Err$ : Sh\ExC = Exc
EndProcedure
; Translates AppleScript code on clipboard to obtain a PB string like below
; AppleScript MUST use TABS to indent. Better compile your AppleScript code, before copying it…
Define MyAScr.s = ~"osascript\n"+
~"tell application \"Finder\"\n"+
~"set mySelection to selection\n"+
~"repeat with i in mySelection\n"+
~"set i to contents of i\n"+
~"open information window of i\n"+
~"end repeat\n"+
~"end tell\n"+
~"return"
shShell(MyAScr, #True) ; Eventual AppleScript returned output will be in Sh\Out
Debug Sh\Out
Debug Sh\ExC