How to get selected Open With file & path sent to program
How to get selected Open With file & path sent to program
For Example:
When I use Windows Explorer to select an rtf file, it automatically opens that selected file in the default rtf running program.
When I use Windows Explorer to select an rtf file, and select Open With, it lets me select an alternate program to open that rtf file, and then opens it in that program.
What I wanted to be able to do, like it is processed above. Is to use Windows Explorer to select a file, and then use 'Open With' to send that selected file to be processed by my PB program. I can easily create the "Open With" part via registry, or by selecting that program through the open With Selection, and both run my PB program fine.
But the selected file name is not transfered to my program to be processed, like it is with the previous examples.
It just runs my program.
How would I be able to get the selected file name and path to be sent to my PB program to be processed?
I appreciate any help and ideas on how to do this.
Thanks
When I use Windows Explorer to select an rtf file, it automatically opens that selected file in the default rtf running program.
When I use Windows Explorer to select an rtf file, and select Open With, it lets me select an alternate program to open that rtf file, and then opens it in that program.
What I wanted to be able to do, like it is processed above. Is to use Windows Explorer to select a file, and then use 'Open With' to send that selected file to be processed by my PB program. I can easily create the "Open With" part via registry, or by selecting that program through the open With Selection, and both run my PB program fine.
But the selected file name is not transfered to my program to be processed, like it is with the previous examples.
It just runs my program.
How would I be able to get the selected file name and path to be sent to my PB program to be processed?
I appreciate any help and ideas on how to do this.
Thanks
Re: How to get selected Open With file & path sent to program
Hi,
You may try to use ProgramParameter() in your PB program to get the full file name.
Allen
You may try to use ProgramParameter() in your PB program to get the full file name.
Allen
Re: How to get selected Open With file & path sent to program
I think also(to test on the pb IDE : Compiler menu -> Compiler options -> Compile/Execute -> Executable parameter -> type the test arguments string)
It might be ok on all OSs...
Code: Select all
Define argument.s
Repeat
argument = ProgramParameter()
Debug argument
Until argument = ""
It might be ok on all OSs...
Re: How to get selected Open With file & path sent to program
Hi,
On Windows you definitely want to check ProgramParameter(0) to get the path sent to program.
If you need to support multiple paths sent at the same time, use CountProgramParameters() and check from from index 0 to index (Count-1).
If you ever want to do this on Mac, it's more complicated, you need to use PB_Gadget_SetOpenFinderFiles(), see here:
viewtopic.php?f=19&t=50795&start=15#p391349
On Windows you definitely want to check ProgramParameter(0) to get the path sent to program.
If you need to support multiple paths sent at the same time, use CountProgramParameters() and check from from index 0 to index (Count-1).
If you ever want to do this on Mac, it's more complicated, you need to use PB_Gadget_SetOpenFinderFiles(), see here:
viewtopic.php?f=19&t=50795&start=15#p391349
Re: How to get selected Open With file & path sent to program
Rebuild quoted parameters passed from explorer.
Code: Select all
Define Count
For Count = 0 To CountProgramParameters() - 1
If FindString(ProgramParameter(Count), space(1))
Args + chr(34) + ProgramParameter(Count) + chr(34) + space(1)
Else
Args + ProgramParameter(Count) + space(1)
EndIf
Next
Re: How to get selected Open With file & path sent to program
Code: Select all
If Chr(34) = #DQUOTE$
Debug "Thats right!"
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to get selected Open With file & path sent to program
I really appreciated all the good suggestions and help and interesting ways to approach this.
Because in my case, I just needed to get the first combined parameter of the file path and file name.
I just used the following:
Yrreti
Because in my case, I just needed to get the first combined parameter of the file path and file name.
I just used the following:
Thanks very much for all your help.; FirstParm$ = Running data that was passed to my running program
;eg: "D:\MyPB_pgms\___PageSelPgm\Page list.cfg" I selected Page list.cfg and used Windows Explorer Open With my program.
FirstParm$ = ProgramParameter(0) ;first parameter position is at 0
;Note: you can't pass any spaces in params.
;So you have to replace all spaces with another character to pass. (such as spaces in paths and file names)
;I used the ~ character), and then replaced back to a space after you receive it.
;Using the following works fine every time.
FirstParm$=ReplaceString(FirstParm$,"~"," ",1)
;to test to see if it worked.
;FirstParm$ ="D:\MyPB_pgms\___PageSelPgm\Page list.cfg"
If Trim(FirstParm$)<>""
MessageRequester("*--------------------- got start parm ----------------------- *",FirstParm$,#PB_MessageRequester_Ok)
EndIf
Yrreti
Re: How to get selected Open With file & path sent to program
When I read that, I assume you want to trigger and display the actual Explorer "Open With" dialog?yrreti wrote: Fri Sep 16, 2022 11:33 pmWhat I wanted to be able to do, like it is processed above. Is to use Windows Explorer to select a file, and then use 'Open With' to send that selected file to be processed by my PB program
Re: How to get selected Open With file & path sent to program
First of all, I want to apologize. When I wrote that last part late yesterday, I guess I was half asleep after a long day.
I woke up at 3 am this morning, and suddenly realized what I had entered and wanted to correct that entry because it didn't
make sense. I copied code in there that wasn't suppose to be there.
I found that code from another program I wrote long ago, where I needed to
to another program that I wrote to act upon. I had replaced the spaces in that phrase with the ~ character so it would work without
having to retrieve and add the sections together again, and replaced the ~ character back to spaces after it received the phrase.
But then I realized that when selecting a file
My program and FirstParm$ = ProgramParameter(0),
for some reason I realized that I don't have to worry about the spaces, as it works even with spaces in the path name and the file name.
Explorer's Open With must take care of that issue.
I just used the MessageRequester code part just to see and verify the end result of ProgramParameter(0), before adding that code
with out the MessageRequester part back into my program.
At any rate, it seems to work for me every time, but I appreciate all the good info added regarding how to possibly do this.
This forum is a great forum, and has always been so helpful.
Thanks for all your help.
yrreti
I woke up at 3 am this morning, and suddenly realized what I had entered and wanted to correct that entry because it didn't
make sense. I copied code in there that wasn't suppose to be there.
I found that code from another program I wrote long ago, where I needed to
send a phrase which contained spaces
to another program that I wrote to act upon. I had replaced the spaces in that phrase with the ~ character so it would work without
having to retrieve and add the sections together again, and replaced the ~ character back to spaces after it received the phrase.
But then I realized that when selecting a file
and using Windows Explorer Open With
My program and FirstParm$ = ProgramParameter(0),
for some reason I realized that I don't have to worry about the spaces, as it works even with spaces in the path name and the file name.
Explorer's Open With must take care of that issue.
I just used the MessageRequester code part just to see and verify the end result of ProgramParameter(0), before adding that code
with out the MessageRequester part back into my program.
At any rate, it seems to work for me every time, but I appreciate all the good info added regarding how to possibly do this.
This forum is a great forum, and has always been so helpful.
Thanks for all your help.
yrreti