Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck if dll launched from another application is already open
    text
    copied!<p>I work with an application (lets say application A) that I write add on modifications for.</p> <p>The application A has functionality to allow scripts to call class librarys or exe files. It works by taking a parameter object created by the application A and passes it into the class library (lets call it Application B)</p> <p>Application A is pretty much a black box that I have no idea what the code looks like or does. I have a script format that takes a parameter object from application A (containing relevant information about the calling program, for example: current user, user language, item application B was launched from etc etc) and passes it into application B. This script functionality is set up using a Administrator panel that is part of application A.</p> <p>The launcher script must use <code>form.Show()</code> and not <code>form.ShowDialog()</code> to open application B as the user must be able to access application A while application B is open (Data checking and so forth).</p> <p>Now I want to be able to prevent application B from opening multiple times as is currently possible, because it has been launched using <code>form.Show()</code> and not <code>form.ShowDialog()</code> however I can't seem to find a suitable way to do this.</p> <p>I firstly tried checking the current processes but have found that application B is not listed here as it is launched by the application A.</p> <ol> <li>M3 Sales Automation is Application A</li> <li>New Customer is Application B</li> </ol> <p>This can be seen from the following screen shots from my task manager:</p> <p><img src="https://i.stack.imgur.com/scAFh.jpg" alt="Task Manager (Applications Tab)"> <img src="https://i.stack.imgur.com/6UQp8.jpg" alt="Task Manager (Processes Tab)"> Both M3 Sales Automation and New Customer are listed in the applications section, but only M3 Sales Automation is listed in the processes section.</p> <p>Initially I tried accessing the processes but found that as its not actually listed there I can't check that and had to look a little deeper. Now I did some more checking and found that the NewCustomer.dll is listed in the ProcessModules for the current process.</p> <p>I used the following code in the launcher script to get the information:</p> <pre><code> public void GetProcessModules() { ProcessModuleCollection modules = Process.GetCurrentProcess().Modules; string modulesOutput = string.Empty; foreach (ProcessModule pm in processModuleCollection) { modulesOutput += pm.ModuleName + ";\r\n"; } MessageBox.Show(modulesOutput, "Modules"); } </code></pre> <p>This outputted a long list of dll's that are part of application A. Now I thought that I could perphaps look to see if the NewCustomer.dll was listed more than once and if this occurred then prevent launch of the application as it would already be open. This was not the case however and the NewCustomer.dll is only listed once no matter how many times it is open.</p> <p>So now my next thought is to look and see if I can access what is shown in the Task Manager Applications Tab. If my program is listed there then I want to prevent it opening again.</p> <p>Does anyone have any Idea how to acheive this?</p> <p>I'm not even sure what I should be searching for as everytime I try to search I get answers talking about looking in the Processes which is not relevant here.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload