File is in use by what process?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • AS1
    Forum Member
    • Jun 2009
    • 70

    File is in use by what process?

    Hello,
    I have an little script what has to protect files from editing, in other words as soon as its get opened by any other file then ProcessX.exe it has to terminate it.

    The only far i've gotten was check if its in use :o the file we are talking about can be any file, in this 'tesing' case it is an Text file

    note: i know i am no proffesional but i didnt get any furter by the forum or manual

    Regards
    AS1
  • Imagine Programming
    Indigo Rose Customer
    • Apr 2007
    • 4252

    #2
    If ProcessX.exe has been written by you, why don't you make sure
    the file is opened at all times?

    use
    Code:
    hFile = io.open(FilePath, "rb");
    to open the file and

    Code:
    hFile:close();
    to close it again.

    By opening the file using io.open, no other process can write to that
    very file, only read it.
    Bas Groothedde
    Imagine Programming :: Blog

    AMS8 Plugins
    IMXLH Compiler

    Comment

    • AS1
      Forum Member
      • Jun 2009
      • 70

      #3
      yes, that was part 1 of my question.
      But i asked also that no other process can write to it even if ProcessX.exe is closed.

      Comment

      • Imagine Programming
        Indigo Rose Customer
        • Apr 2007
        • 4252

        #4
        Originally posted by AS1 View Post
        yes, that was part 1 of my question.
        But i asked also that no other process can write to it even if ProcessX.exe is closed.
        There is no way, there must always be a process having the file
        opened so no other process can write to it. You could try
        setting the attributes of the file to Read-Only when you close
        ProcessX.exe and set the system and hiddne attribute to true
        aswell.

        look up File.SetAttributes(szFilename, tAttributes); in the helpfile
        Oh, and you're welcome
        Bas Groothedde
        Imagine Programming :: Blog

        AMS8 Plugins
        IMXLH Compiler

        Comment

        Working...
        X