US>" No processes are associated with this object." About error avoidance and resolution

Asked 2 years ago, Updated 2 years ago, 35 views

Currently, we are having trouble processing the window to prevent multiple boots.

By obtaining PIDs by process name and forcibly deleting windows with the same process name and different PIDs, I thought it would be possible to prevent multiple boots, so I looked it up.If you search for it, you will see a lot of similar processing, so when you refer to it, you will see the error in the title in the process.CloseMainWindow.

Strangely enough, it can be successful, so it's rather troublesome.

Thank you for your cooperation.

System.Diagnostics.ProcessThisProcess=System.Diagnostics.Process.GetCurrentProcess();
System.Diagnostics.Process[]hProcesses=System.Diagnostics.Process.GetProcessesByName(hThisProcess.ProcessName);
intiThisProcessId=hThisProcess.Id;
foreach(System.Diagnostics.Process in hProcesses){
    if(hProcess.Id!=iThisProcessId){
        if(!hProcess.CloseMainWindow()){
            hProcess.Kill(); 
        }
        else{
            Logger.Info("CloseMainWindow Success:"+hProcess.Id);
        }
    }
}

c#

2022-09-30 14:37

1 Answers

I'm doing something very dangerous...
Why don't we throw away all the current codes and check for multiple boot with Mutex?
Please refer to other tips.
http://dobon.net/vb/dotnet/process/checkprevinstance.html

Huh? Is it ASP.NET? If so, it's a confusing code...


2022-09-30 14:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.