Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Getting mutex process

Getting mutex process

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    confalonieri
    wrote on last edited by
    #1

    Hi, In my application, I have to get the ID or the name of the process that created a named mutex. Does anybody know how to proceed ? I use this code : HANDLE MutexHandle = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, MutexName); if (MutexHandle) { // mutex exists ::CloseHandle(MutexHandle); // how to get the process ID ? } else { // mutex doesn't exist } Thanks in advance, Robin.

    A 1 Reply Last reply
    0
    • C confalonieri

      Hi, In my application, I have to get the ID or the name of the process that created a named mutex. Does anybody know how to proceed ? I use this code : HANDLE MutexHandle = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, MutexName); if (MutexHandle) { // mutex exists ::CloseHandle(MutexHandle); // how to get the process ID ? } else { // mutex doesn't exist } Thanks in advance, Robin.

      A Offline
      A Offline
      Aizik Yair
      wrote on last edited by
      #2

      Hi, this code will resolve your problem. HANDLE m_hMutex = NULL; // Create the mutex m_hMutex = CreateMutex( NULL, FALSE, "Process.exe" ); // Check for errors if ( GetLastError() == ERROR_ALREADY_EXISTS ) { // Reset our mutext handle (just in case) m_hMutex = NULL; MessageBox(NULL,"Can't run the application twice!!!.","Task manager:",MB_OK); exit(0); } Aizik Yair Software Engineer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups