Jump to content
Sign in to follow this  

Detect and intercept access to a file - is it possible?

Recommended Posts



Is there a way detect and intercept a file by a specific application?

What I need to do is encrypt a text file and when a specific application tries to read it I need decrypt it.

The application is running as a service so I can't use any kind of launchers for it

Any suggestions?


Share this post

Link to post
Share on other sites

You can check if the file is in use:

#Include <WinAPI.au3>

ConsoleWrite(_FileIsUses(@ScriptDir & '\My.pdf') & @CR)

Func _FileIsUses($sFile)

    Local $hFile = _WinAPI_CreateFile($sFile, 2, 2, 0)

    If $hFile Then
        Return 0

    Local $Error = _WinAPI_GetLastError()

    Switch $Error
            Return 1
        Case Else
            Return SetError($Error, 0, 0)
EndFunc   ;==>_FileIsUses

And then do what you want.


My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this