Page 1 of 1

Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 4:30 pm
by SPH
Hi everybody, :)

I need your knowledge!
My encryption software makes ".mkey2" files
So I said windows it launches my encryptor when we double click on a .mkey2 file
What I would like is that my cryptor opens on the path of the double clicked file (ExplorerTreeGadget)!

Here is a short code that can be considered as my software:

Code: Select all

OpenWindow(0, 0, 0, 749, 515, "SPH", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

Global Repertoire$
calcul=0

ExplorerTreeGadget(1, 11, 73, 230, 280, Repertoire$, #PB_Explorer_NoFiles)
ExplorerListGadget(2, 247,73,490,280, "*.*", #PB_Explorer_NoFolders|#PB_Explorer_NoParentFolder)
SendMessage_(GadgetID(2),#LVM_SETCOLUMNWIDTH,0,188) ; largeur colonne
SendMessage_(GadgetID(2),#LVM_SETCOLUMNWIDTH,1,80) ; largeur colonne

FrameGadget(3, 11,  360, 726,33, "", #PB_Frame_Single)

;titre
TextGadget(4, 20, 370,90,20,"Password :")
;password
StringGadget(5, 80,  366, 570, 20, ""  )

;invisible
ButtonGadget(6, 656,  366, 30, 20, "Hide", #PB_Button_Toggle)


;cls
ButtonGadget(7, 693,  366, 40, 20, "Clear")

Procedure Afficher_fichiers()
  SetGadgetText(2, "")                    ; Vider la liste des fichiers
  Repertoire$ = GetGadgetText(1)          ; Voir quel est le répertoire sélectionné
  SetGadgetText(2, Repertoire$)           ; Remplir la liste avec le répertoire
EndProcedure

BindGadgetEvent(1, @Afficher_fichiers(), #PB_EventType_Change) ; #PB_EventType_LeftClick) 


Repeat
  Evenement = WindowEvent()
  If Evenement = #PB_Event_Gadget
    If EventGadget()=6 ; hide button
      If GetGadgetState(6)=1         
        StringGadget(5, 80,  366, 570, 20, GetGadgetText(5),#PB_String_Password)
      Else
        StringGadget(5, 80,  366, 570, 20, GetGadgetText(5))
      EndIf
      
      
    EndIf
    
   
    window_event = WaitWindowEvent(5) ;changing the progressbar's will always cause this to catch an event
    While window_event <> 0
      If window_event = #PB_Event_CloseWindow : Break 2: EndIf
      window_event = WindowEvent()
    Wend
   
  EndIf
Delay(5)
Until Evenement = #PB_Event_CloseWindow
End

;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;
Thx a lot 8)

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 4:34 pm
by Derren

Code: Select all

path.s = GetPathPart( ProgramFilename() )

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 4:44 pm
by SPH
... no, I do not think that's it.
Basically, my encryptor (a compiled .PB) is closed. When I double click on a ".mkey2" file in the windows browser, my software opens on the path (ExplorerTreeGadget) of the double clicked file!

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 5:07 pm
by oreopa

Code: Select all

; ENSURE WE CD TO PROGRAM DIR IN CASE OF INVOKATION FROM SHELL/OPEN WITH...
SetCurrentDirectory(GetPathPart(ProgramFilename()))
no?

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 5:08 pm
by Derren
Sorry, misunderstood.

Try

Code: Select all

GetPathPart(Programparameter())

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 5:20 pm
by Denis
SPH,

you want to open your app from windows shell when you click on your file ?

I don't know how to do but may be a key into the register base which associate your extension file and a parameter key to launche your app with the correct name.

Your app have to read parameter to separate file from folder.
You have to use an installer to write the right key to register base.

May be there are register base gurus here.

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 6:45 pm
by Little John
SPH wrote:My encryption software makes ".mkey2" files
So I said windows it launches my encryptor when we double click on a .mkey2 file
What I would like is that my cryptor opens on the path of the double clicked file (ExplorerTreeGadget)!
Your encryptor program can open the mkey2 file on which you clicked, because the path and name of that file is passed to your program as parameter (provided everything is configured correctly on your Windows system).

So I think this should work:
Derren wrote:Try

Code: Select all

GetPathPart(Programparameter())

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 7:27 pm
by SPH
Everyone is talking about "GetPathPart (Program Parameter ())" but have you tried to include it in my post 1 code?
Try and see if it works ... (I do not believe it)

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 8:03 pm
by Marc56us
So I said windows it launches my encryptor when we double click on a .mkey2 file
What I would like is that my cryptor opens on the path of the double clicked file (ExplorerTreeGadget)!

Code: Select all

...
Repertoire$ = GetPathPart( ProgramParameter( 0 ) ) )
ExplorerTreeGadget(1, 11, 73, 230, 280, Repertoire$, #PB_Explorer_NoFiles)
...

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 8:08 pm
by Little John
SPH wrote:but have you tried to include it in my post 1 code?
Try and see if it works ... (I do not believe it)
:lol: :lol: :lol:

A better question is: Have you tried to include it in your code :?:

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 9:11 pm
by SPH

Re: Open an exe (compiled .pb) with the right path ...

Posted: Thu Aug 15, 2019 10:36 pm
by Derren
Speechless. :shock:

Re: Open an exe (compiled .pb) with the right path ...

Posted: Fri Aug 16, 2019 7:33 am
by SPH
Derren wrote:Speechless. :shock:
Excuse me, but I think you gave me the answer. It's my fault if I did not know how to use it ... :oops: :oops: :oops: