UnlockFile | UnlockFile allows to unlock a file
kandi X-RAY | UnlockFile Summary
kandi X-RAY | UnlockFile Summary
UnlockFile allows to unlock a file by shutting down the applications that lock the file.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of UnlockFile
UnlockFile Key Features
UnlockFile Examples and Code Snippets
Community Discussions
Trending Discussions on UnlockFile
QUESTION
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:
- A Temp file is created with GetTempFilename
- Call to LockFile API
- 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:07SHARE.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.
QUESTION
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:11Ok, 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.
QUESTION
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:24You 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:
QUESTION
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:39You 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.
QUESTION
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:14You'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...
QUESTION
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:01Just 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.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install UnlockFile
Install the UnlockFile:
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page