You are here: PSPad forum > English discussion forum > PSPad file handling

PSPad file handling

#1 PSPad file handling

Posted by: pspad | Date: 2020-05-29 17:39 | IP: IP Logged

Behavior from the operating system side

There is few ways how to open file from Windows explorer or any File manager:

1. click on the file
OS will start application associated with file type, file is sent as parameter

2. registry integration (registration application to any extension)
If you select e.g. 5 files and let them open in some application, OS will start 5 times the application and each application will get one file as parameter

3. DLL registration in explorer
This is the most efective way, cause DLL will receive list of files. And rest depends of the DLL. In case of PSPad, DLL will start one PSPad and send all files as parameters into it at once.

Behavior from the PSPad side (one instance settings)

OS must know where the application is:
- in case of registry integration, the path is stored into registry when you confirm the PSPad settings dialog
- in case of DLL integration, only DLL extension is registered to Explorer context menu. When PSpad starts, it writes path into registry: \HKEY_CURRENT_USER\SOFTWARE\PSPad
DLL shell extension uses this path to start PSPad and send files as parameter

How to know if instance already running or not
When PSPad starts it try to create Mutex. From the OS side it's global object, what is released when application ends. Existence of the mutex means any instance of PSpad is running.

PSPad creates Mutex on start. If Mutex is sucessfully created, PSPad starts normally. If not sucessfull, it means Mutex exists and PSPad is already running. Now PSPad must get information of running instance. Again \HKEY_CURRENT_USER\SOFTWARE\PSPad registry record is used and there PSPad main window handle is stored.
When you know window handle, you can send a message to application and exactly this is used (send message) to send file/files into running instance. Start of the second instance doesn't continue and ends.
It's little complicated, cause application start take some time and in the start process isn't able to receive messages. So other instances must wait till the first instance is ready.

Explanation of the more PSPad version together

Registry integration
Confirming PSpad settings dialog the integration is written into registry and this record is used to start the first PSPad instance, e.g. when you click on the file.
When any PSpad instance is already running, all open files are send into this instance.

DLL integration
It doesn't matter what PSpad makes DLL integration. Important is the last PSPad you run, this PSPad writes it's path into registry and DLL will start it next time.

Options: Reply | Quote | Up ^


#2 Re: PSPad file handling

Posted by: warrenbuilt | Date: 2021-10-25 05:31 | IP: IP Logged

When PSPad starts it try to create Mutex. From the OS side it's global object, what is released when application ends. Existence of the mutex means any instance of PSpad is running.

Options: Reply | Quote | Up ^


#3 Re: PSPad file handling

Posted by: pspad | Date: 2021-10-25 05:48 | IP: IP Logged

Mutex is created on the begin of pspad start. It's released when pspad finishes. And exactly, it means that any instance is running.
Is there any problem?

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR