Thread: lockfile/unlockfile,can not work between the processes?

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    5

    lockfile/unlockfile,can not work between the processes?

    hello,
    I locked a file in a process ,and now to release it in another process,but it doesn't work.the GetLastError() API indicates as if I never locked that file.

    how come it turned out to be like this?
    Is there any other way to do this: lockfile in one process and unlock in another?

    regards

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by wal_sug View Post
    hello,
    I locked a file in a process ,and now to release it in another process,but it doesn't work.the GetLastError() API indicates as if I never locked that file.

    how come it turned out to be like this?
    Is there any other way to do this: lockfile in one process and unlock in another?

    regards
    And why would you want to do it that way? The whole purpose of LockFile and UnlockFile is that they keep track of the process that locked the file, and prevent any other process from operating on the file. It would be pretty insecure and pointless to have a locking mechanism that doesn't check that the process unlocking the file is the same process that locked it. It reminds me of the time when Ford in the UK had a lock that just about any key would unlock and start any Ford model of that year - it wasn't exactly a publicity success (well, if you count "any publicity is good publicity", then perhaps it was!

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  3. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  4. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 04:48 AM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM