UnlockFile | UnlockFile allows to unlock a file

 by   meziantou C# Version: v2.0 License: MIT

kandi X-RAY | UnlockFile Summary

kandi X-RAY | UnlockFile Summary

UnlockFile is a C# library. UnlockFile has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

UnlockFile allows to unlock a file by shutting down the applications that lock the file.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              UnlockFile has a low active ecosystem.
              It has 12 star(s) with 0 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 1 have been closed. On average issues are closed in 2 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of UnlockFile is v2.0

            kandi-Quality Quality

              UnlockFile has no bugs reported.

            kandi-Security Security

              UnlockFile has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              UnlockFile is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              UnlockFile releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of UnlockFile
            Get all kandi verified functions for this library.

            UnlockFile Key Features

            No Key Features are available at this moment for UnlockFile.

            UnlockFile Examples and Code Snippets

            No Code Snippets are available at this moment for UnlockFile.

            Community Discussions

            QUESTION

            In Windows 3.1 WinAPI How To Lock A File?
            Asked 2019-Jul-15 at 09:07

            I was trying to run Visual Basic 4 (16-bit) in Windows 3.1 running within DosBox. However it failed to launch with error:

            SHARE.exe must be installed in order to run Visual Basic

            Some old MS-DOS applications just check for existence of the EXE and it's presence in autoexec.bat, but in this case the EXE exists, but the error still occurs.

            Running on Windows 7 32-bit and using a debugger attached to NTVDM.exe I found the following process is used:

            1. A Temp file is created with GetTempFilename
            2. Call to LockFile API
            3. Call to UnlockFile API

            When I set a breakpoint at return of LockFile API and faked a faliure (returned false) On Windows 7 I got the same error message "SHARE.exe must be installed in order to run Visual Basic"

            However within the VB.exe I can't find any reference to LOCKFILE API, so I suspect NTVDM.exe is translating it somehow.

            The APIs that seem potentially related in the import table of VB.exe are:

            • Kernel!OPENFILE
            • Kernel!_LWRITE
            • Kernel!_LREAD
            • Kernel!_LOPEN
            • Kernel!_LLSEEK
            • Kernel!_LCREAT
            • Kernel!_LCLOSE
            • OLE2!OLELOCKRUNNING
            • Kernel!LOCKRESOURCE
            • Kernel!LOCKSEGMENT

            I am trying to work out how the lock / unlock file test is done so I can try to remediate within DosBox and create my own test program to replicate in C or VB.

            ...

            ANSWER

            Answered 2019-Jul-15 at 09:07

            SHARE.exe must be installed in order to run Visual Basic

            SHARE.EXE works as Terminate and Stay Resident kind of program. So it existence is not enough. It must be run, to hook into system and intercept some requests.

            SHARE.EXE intercepts DOS Interupt (0x21) and DOS Multiplex Interrupt (0x2F).

            In 0x21 interrupt code 0x5c handles locking and unlocking files

            http://www.techhelpmanual.com/530-dos_fn_5c00h__lock_file_access.html

            LockFile 5c00h
            Expects:
            AX 5c00H
            BX file handle
            CX:DX file offset from start of file (CX * 65536)+DX
            SI:DI length in bytes of region to lock (SI * 65536)+DI
            Returns: AX error code if CF is set to CY

            This function locks access to a region of the file identified by the file handle in BX. The region of the file that begins at file logical offset CX:DX extending for a length of SI:DI is locked ...

            http://www.techhelpmanual.com/531-dos_fn_5c01h__unlock_file_access.html

            UnlockFile 5c01h
            Expects:
            AX 5c01H
            BX file handle
            CX:DX file offset from start of file (CX * 65536)+DX
            SI:DI length in bytes of region to lock (SI * 65536)+DI
            Returns: AX error code if CF is set to CY

            This function unlocks access to a region of the file which was previously locked...

            You could also check 5dh functions marked mostly as internal.

            Implementation in Free DOS:

            https://sourceforge.net/p/freedos/svn/HEAD/tree/kernel/trunk/kernel/dosfns.c
            see DosLockUnlock function
            https://sourceforge.net/p/freedos/svn/HEAD/tree/kernel/trunk/share/share.c

            Looking at vDos source code could help if you plan to bring this funcionality to Dos Box

            https://sourceforge.net/projects/vdos/files/Version%202015.04.10/

            However within the VB.exe I can't find any reference to LOCKFILE API

            I'm not sure if LockFile existed in Win16 (probably not), but there is possibility that sharing API is called directly through DOS interrupts.

            I suspect NTVDM.exe is translating it somehow

            I don't know it for sure, but I would assume that it intercepts DOS interrupts and uses Win32 API calls to simulate needed behavior.

            I am trying to work out how the lock / unlock file test is done so I can try to remediate within DosBox and create my own test program to replicate in C or VB

            I would try to log INT 21h and INT 2Fh calls in DOS Box.

            Source https://stackoverflow.com/questions/57028383

            QUESTION

            os.rename, os.replace and shutil.move errors on windows 10
            Asked 2018-Sep-17 at 21:11

            I'm trying to implement simple file locking using renaming on windows 10. I've got the following test program that renames a file to lock it, then opens and reads it, and renames it to unlock it. However, I'm seeing intermittent errors when I run two of these simultaneously using different arguments (e.g. test.py 1, test.py 2)

            ...

            ANSWER

            Answered 2018-Sep-17 at 21:11

            Ok, based on the post linked above, os.path lies, I cobbled together a solution. This may still just be lucky timing and is only for Windows at this point. If I change the subprocess.Popen to rename/replace or omit the os.stat before doing the os.path.exists check then it doesn't work. But this code doesn't seem to hit the problem. Tested with 5 simultaneous scripts running and without sleep calls.

            Source https://stackoverflow.com/questions/52339001

            QUESTION

            Child process inherits a handle from its parent process but fails to write in it
            Asked 2017-Dec-08 at 05:24

            I want to have 2 processes write in the same file. I created a file in the first process (parent) and call the second process (child) . I have made the file inheritable and the second process inherits the handle as a command line argument.

            Although the handle is not equal to INVALID_HANDLE_VALUE, the second process can't do anything with the file. WriteFile() ends with Error 6(the handle is invalid). The same is for LockFile(),Unlockfile().

            What is wrong with the code and how can I fix it? I want to make 2 processes work with the same file.

            Process 1:

            ...

            ANSWER

            Answered 2017-Dec-08 at 05:24

            You may be creating the child process with an inheritable file handle, but you are not actually telling the child what the value of that handle is! The child is looking for that value in argv[1], but the code you have shown is not passing any value in that parameter! Even if there were, you are not retrieving the value correctly anyway.

            Command-line parameters are always strings, so argv[1] is a pointer to a null-terminated string, not a handle. You have to convert the handle pointer to a string representation when you put it on the command-line, and then you have to parse that string back to a pointer when processing the command-line.

            Try something more like this:

            Process 1:

            Source https://stackoverflow.com/questions/47703225

            QUESTION

            vba dll call writefile from kernel32 creates huge file
            Asked 2017-May-23 at 17:16

            I'm trying to append one text file to another using VBA7 in excel 2010 32 bit, on windows 7 64 bit for prototyping purposes. Once this works, I'm going to be using the same method to append wav data from many files together and modifying the header information to be correct for the size of the appended wav data.

            The problem that I'm having is when I call WriteFile (synchronously), it takes a long time to complete, and the reason is that it is writing 4 gigs to the text file, it should only be writing 20 bytes (the size of one.txt). What is going wrong or how can I debug it?

            I have limited tools available to me on this machine, because it is a managed by a large organization. I only have access to VBA for programming environment. Powershell and normal command shell utilities are available.

            I have done the following research: Read the msdn articles for all dll calls, set breakpoints to verify values are correct, read about 32bit vs 64bit compatibility in office 2010, read and understand (mostly) an msdn article on passing information to dll procedures in VB, found this great page about varptr and calling dll functions in VB, and got the code from an msdn C++ example, among much learning.

            ...

            ANSWER

            Answered 2017-May-22 at 23:39

            You are passing vbNull to SetFilePointer.

            vbNull is an enumeration constant that equals 1. It is one of the possible results that VarType() can return. It is not C++'s nullptr or VB's Nothing. Passing this value as lpDistanceToMoveHigh instructs the function to use 64-bit addressing and take the 1 as the high dword.

            Apparently you wanted to pass ByVal 0&. It is what you pass to byref parameters when you want to pass null pointer.

            Source https://stackoverflow.com/questions/44123338

            QUESTION

            Open window in C# class library project
            Asked 2017-Apr-20 at 18:14

            I am still new and learning C# as I go. My question is generic, so let me know if I can be more specific in any way. I am moreover looking for guidance/examples to go off of or even a simple solution to build from.

            I have a class library that is currently working, but I want to display a window to the user. My class is for a program called Solidworks PDM and is a menu command. In the middle, I need the user to review and select "OK" or "Cancel".

            Basically, how do I get a window that contains two buttons "OK" and "Cancel" in the my class library? Thanks in advance!

            ...

            ANSWER

            Answered 2017-Apr-20 at 18:14

            You'll have to create a Form that has input options for the user to interact with to get the file paths and such that you need. Based on the code you've given, I went ahead and made up what I think you need. It should be pretty close to what you actually use, but with this as a basis you should be able to edit it to your needs pretty easily.

            The form with a File Selector and Folder Selector with OK and Cancel buttons...

            Source https://stackoverflow.com/questions/43522493

            QUESTION

            Is it possable to call a method that takes this.Handle as an argument inside a background worker in C#
            Asked 2017-Apr-18 at 21:39

            I am working on a stand-alone WinForm program in C# that uses the Solidworks EPDM api. The program takes a top level assembly and finds all the referenced and referencing files in the assembly. e.g. all sub-assemblies, part files, and drawings. The program then checks out all the files from EPDM, updates the data cards, and checks in all the files back to the EPDM.

            I have successfully implemented the portion of the code that finds all the referenced and referencing files and updates the data card information using a background worker. This portion of the code does not require access the the UI thread. I would like to be able to add the code that checks out the files and checks them back in within a background worker. The problem is that the methods used to do the checkout and check-in take this.Handle as an argument. I know that accessing the UI thread from within a background worker will throw a cross thread exception. The code does not access any of the UI controls. It only need access to this.Handle. Is it possible to pass this.Handle to a background worker in a thread safe way that will not throw a cross thread exception?

            This is my first use of background workers so my knowledge is limited. Below is the code that I would like to run in a background worker.

            ...

            ANSWER

            Answered 2017-Apr-13 at 22:01

            Just put a 0 in there for the handle. As long as your code will not require user input, it will work. I do it often.

            Source https://stackoverflow.com/questions/43398566

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install UnlockFile

            Install .NET Core 2.1: https://www.microsoft.com/net/download/Windows/run
            Install the UnlockFile:

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/meziantou/UnlockFile.git

          • CLI

            gh repo clone meziantou/UnlockFile

          • sshUrl

            git@github.com:meziantou/UnlockFile.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link