Hello! For example, there is a program called: prog_1.1.exe

nt APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { if ( CreateMutex(NULL, FALSE, _T("prog_1.1.exe")) )//то есть уже запущено if ( GetLastError() == ERROR_ALREADY_EXISTS ) { //действия если запущена } while(true); } 

How to make it so that if I run a second copy of this file, then it should stop executing the first copy?

And the second question is how to run it on a computer connected to the network if there is a shared folder?

Could you give me an example? code ...

  • one
    The first way is to kill the process, but imho is better to signal the first instance that it needs to complete, to replace the mutex with the event, first try to open it, if it works, then install it, the first process in turn waiting for the installation of the event, ends correctly. - Slava Zhuyko
  • to run the program on another computer, you can use PsExec from PsTools - Slava Zhuyko

0