Results 1 to 6 of 6

Thread: [RESOLVED] Lock File

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Resolved [RESOLVED] Lock File

    hi

    I am makeing a small program that will enable the user to select an exe program and it makes it password protected, basily all it does is combine the exe to protect into the main exe, witch is then run and prompts for a password, if the password is correct the exe to run is extracted and then executed.

    now what I whould like to know is how can I lock this file, meaning when the app is extracted as explained above and run, I need a way for the user 1 not to rename , copy or move the file.

    any ideas?

    Thanks.
    When your dreams come true.
    On error resume pulling hair out.

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Lock File

    You can never completely lock a file anyway.

    May I ask what its going to be used for?

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: Lock File

    Do you have adminrights to the machine where this program runs?
    If so, you can use NTFS permissions to restrict the user's access to the exe.

    Another option is to encrypt the exe, decrypt it when needed and when done delete the decrypted exe.

    I would also tell the user not to touch anything in the installationfolder so he won't break things.
    If you need to be sure, train a dog to bite him if he does anyway.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Re: Lock File

    yes I have adminsotrator rights, I am not sure encrypting will help becuase even when decryped and run, the app can still be selected , moved and copyed, bascily I want it so it shows the message if a user tryes to do any of the above.

    ---------------------------
    Error Copying File or Folder
    ---------------------------
    Cannot copy app.exe: It is being used by another person or program.

    Now I was looking at LockFile API but I can;t seem to find an example, does anyone know were I may find one.

    Thanks
    When your dreams come true.
    On error resume pulling hair out.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Re: Lock File

    Sorted I figured it out very simple as well I feel such a Noob now. anyway if someone wants to know here is the code,

    lets say you run Demo.exe and then you have some other app with the line of code in

    Open "C:\demo.exe" For Binary Lock Read As #1

    when you execute that code it will lock demo.exe when it running so even if you try t copy move, rename etc you get an error messae. o made sure in your program you also put close#1 somewere

    anyway thanks; for the help.
    When your dreams come true.
    On error resume pulling hair out.

  6. #6
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Talking Re: [RESOLVED] Lock File

    Thx for the code, this could be useful!
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width