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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to impliment Mutex

How to impliment Mutex

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
4 Posts 2 Posters 7 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.
  • V Offline
    V Offline
    VC_RYK
    wrote on last edited by
    #1

    Hi All I have to application and one Application is writing something in file and another one is reading from that file. And i used FindFirstChangeNotification but it is working some time and some time it is not working so i want to use create mutex for this communication and i am very new in Mutex and tried my level best to achive but count not carck. can any one help, How will i use MUtex. Thank In advance RYK

    A 2 Replies Last reply
    0
    • V VC_RYK

      Hi All I have to application and one Application is writing something in file and another one is reading from that file. And i used FindFirstChangeNotification but it is working some time and some time it is not working so i want to use create mutex for this communication and i am very new in Mutex and tried my level best to achive but count not carck. can any one help, How will i use MUtex. Thank In advance RYK

      A Offline
      A Offline
      avo2
      wrote on last edited by
      #2

      Hi, So called "named Mutexes" can be uses between processes. So in this case give the Mutex the name of the File yout are using. But be careful, i think backlashes don't work with mutexes, so you should replace backslashes with some other character. cu a.

      i know nothing

      1 Reply Last reply
      0
      • V VC_RYK

        Hi All I have to application and one Application is writing something in file and another one is reading from that file. And i used FindFirstChangeNotification but it is working some time and some time it is not working so i want to use create mutex for this communication and i am very new in Mutex and tried my level best to achive but count not carck. can any one help, How will i use MUtex. Thank In advance RYK

        A Offline
        A Offline
        avo2
        wrote on last edited by
        #3

        Hi, just found some code that might help you: HANDLE GetMutex() { CString Key = m_FileName; // Your Filename! Key.Replace('\\', '_'); HANDLE hMutex = ::OpenMutex(SYNCHRONIZE, TRUE, Key); if (!hMutex) { SECURITY_ATTRIBUTES sa; sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; hMutex = ::CreateMutex(&sa, FALSE, Key); } return hMutex; } cu. a.

        i know nothing

        V 1 Reply Last reply
        0
        • A avo2

          Hi, just found some code that might help you: HANDLE GetMutex() { CString Key = m_FileName; // Your Filename! Key.Replace('\\', '_'); HANDLE hMutex = ::OpenMutex(SYNCHRONIZE, TRUE, Key); if (!hMutex) { SECURITY_ATTRIBUTES sa; sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; hMutex = ::CreateMutex(&sa, FALSE, Key); } return hMutex; } cu. a.

          i know nothing

          V Offline
          V Offline
          VC_RYK
          wrote on last edited by
          #4

          Thanks Dear Let me try.

          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