开发者

Show running instance in single instance application

开发者 https://www.devze.com 2022-12-10 09:12 出处:网络
I am building an application with C#. 开发者_C百科 I managed to turn this into a single instance application by checking if the same process is already running.

I am building an application with C#. 开发者_C百科

I managed to turn this into a single instance application by checking if the same process is already running.

Process[] pname = Process.GetProcessesByName("SwapCardDesktop");
        if (pname.Length < 2)
        {
            // Launch Application
        }

I intend to have another functionality in here which brings up the running instance when tried to launch again.

I tried calling ShowWindowAsync() if application is already running,

ShowWindowAsync(hWnd, 9);

But this fails to bring up the application when minimized to tray.

Any suggestions on this?


Duplicated of: What is the correct way to create a single-instance application?

That points to: http://sanity-free.org/143/csharp_dotnet_single_instance_application.html

0

精彩评论

暂无评论...
验证码 换一张
取 消