_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. -- <https://forum.pspad.com/read.php?2,73638,73638> PSPad freeware editor https://www.pspad.com
