How do I know if a file is open (being used) by any program?

I'm trying to write a program that will log file usage. For example, it will log when a file (or program) begins to be used (or opened), and then log when it is closed.
So what I'm looking for is a method / algorithm that will tell me if a file is currently open (or if an executable fileis currently open, in the case of a program).

If you mean the ability to do this system wide (and not just in your app) then you would need to use JNI and a HOOK function (assuming this is windows you are talking about). I am sure there are similar hooks in UNIX/LINUX.

Similar Messages

  • How to make a remote panel file dialog open remote directory from any computer

    Hello to everybody. I am using Labview 6.1 and I would like to know how to make a remote panel file dialog open remote directory from any computer (Not only from a specific computer. If I open the file with a specific computer, I have to conect the path of the remote machine, but if I don´t know which remote computer is going to run the aplication, how can I do it?)?

    Hi!
    first you have to know progammatically the name of the remote pc connected to your server: this is a problem!
    I did not find a straigth way, LV 6.1 doesn't allow much progammatic control on the remote panel connection feature, but I'm confident that in the next LV version this will be improved!
    The point is that the Remote Panel Connection Manager (from the Tools menu) has all the informations about the connection: client name, server vi and whatever.
    This application is embedded in the \PROJECT\REMOTEPANEL.LLB and consists of a set of password protected vis.
    So here's the trick: use VIServer to grab data from the rpcm Get Server Data.vi when the Remote Panel Connection Manager is in run mode. By this you get all the informations (not only client name)o
    f the remote panel connection. See my example.
    By the way use client machine name to build the file dialog function input path.
    If anybody has an alternative method it would be more than appreciated to share it.
    Good luck,
    Alberto Locatelli
    Attachments:
    get_remote_machine_data.vi ‏151 KB

  • How do I know if my disk caching is being used?

    Hi everybody, I would like to know how can I confirm if my  disk caching is being used? And if it is not. How can I make it works?
    Here are the specifications of my desktop:
    Product Name: h8-1440t
    OS: Windows 8.1 Pro with Media Center 64-bit 
    Microprocessor: Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz
    RAM: 16.0GB DDR3 @ 797MHz (9-10-9-26)
    Motherboard:  PEGATRON CORPORATION 2ACE (SOCKET 0) 36 °C
    Graphics:
     HP x2301 (1920x1080@60Hz)
     3072MB NVIDIA GeForce GT 640 (MSI) 52 °C
    Storage:
     931GB Western Digital WDC WD10EZEX-60ZF5A0 (SATA) 29 °C
     931GB Western Digital WDC WD10EZEX-60ZF5A0 (SATA) 29 °C
     14GB SanDisk SDSA5GK-016G-1006 (SSD)
    Optical Drives:
     hp BD-RE BH38L
     hp DVD A DH16ACSHR
    Audio:
     IDT High Definition Audio CODEC
    ======
    Additionally:
    Hard drives:
    -WDC WD10EZEX-60ZF5A0
         Manufacturer Western Digital
         Heads 16
         Cylinders 121,601
         Tracks 31,008,255
         Sectors 1,953,520,065
         SATA type SATA-III 6.0Gb/s
         Device type Fixed
         ATA Standard ACS2
         Serial Number WD-WCC1S1164451
         Firmware Version Number 80.00A80
         LBA Size 48-bit LBA
         Power On Count 2145 times
         Power On Time 204.6 days
         Speed 7200 RPM
         Features S.M.A.R.T., NCQ
         Max. Transfer Mode SATA III 6.0Gb/s
         Used Transfer Mode SATA III 6.0Gb/s
         Interface SATA
         Capacity 931 GB
         Real size 1,000,204,886,016 bytes
         RAID Type None
          S.M.A.R.T
           Status Good
           Temperature 29 °C
           Temperature Range OK (less than 50 °C)
            S.M.A.R.T attributes
          Partition 0
           Partition ID Disk #0, Partition #0
           File System NTFS
           Volume Serial Number FE384C77
           Size 1022 MB
           Used Space 384 MB (37%)
           Free Space 638 MB (63%)
          Partition 1
           Partition ID Disk #0, Partition #1
           Size 360 MB
          Partition 2
           Partition ID Disk #0, Partition #2
           Disk Letter C:
           File System NTFS
           Volume Serial Number 8878D4A2
           Size 908 GB
           Used Space 406 GB (44%)
           Free Space 502 GB (56%)
          Partition 3
           Partition ID Disk #0, Partition #3
           File System NTFS
           Volume Serial Number 80C60E18
           Size 349 MB
           Used Space 296 MB (84%)
           Free Space 53 MB (16%)
          Partition 4
           Partition ID Disk #0, Partition #4
           Disk Letter D:
           File System NTFS
           Volume Serial Number 56971929
           Size 21 GB
           Used Space 18.4 GB (87%)
           Free Space 2.58 GB (13%)
    - WDC WD10EZEX-60ZF5A0
         Manufacturer Western Digital
         Heads 16
         Cylinders 121,601
         Tracks 31,008,255
         Sectors 1,953,520,065
         SATA type SATA-III 6.0Gb/s
         Device type Fixed
         ATA Standard ACS2
         Serial Number WD-WCC1S1282644
         Firmware Version Number 80.00A80
         LBA Size 48-bit LBA
         Power On Count 2145 times
         Power On Time 204.6 days
         Speed 7200 RPM
         Features S.M.A.R.T., NCQ
         Max. Transfer Mode SATA III 6.0Gb/s
         Used Transfer Mode SATA III 6.0Gb/s
         Interface SATA
         Capacity 931 GB
         Real size 1,000,204,886,016 bytes
         RAID Type None
          S.M.A.R.T
           Status Good
           Temperature 29 °C
           Temperature Range OK (less than 50 °C)
            S.M.A.R.T attributes
          Partition 0
           Partition ID Disk #1, Partition #0
           Disk Letter E:
           File System NTFS
           Volume Serial Number 4847795E
           Size 931 GB
           Used Space 687 GB (73%)
           Free Space 244 GB (27%)
    -SanDisk SDSA5GK-016G-1006
         Manufacturer SanDisk
         Heads 16
         Cylinders 1,946
         Tracks 496,230
         Sectors 31,262,490
         SATA type SATA-III 6.0Gb/s
         Device type Fixed
         ATA Standard ACS2
         Serial Number 124370401347
         Firmware Version Number CS.54.06
         LBA Size 48-bit LBA
         Power On Count 2141 times
         Power On Time 62.4 days
         Speed Not used (SSD Drive)
         Features S.M.A.R.T., APM, NCQ, TRIM, SSD
         Max. Transfer Mode SATA III 6.0Gb/s
         Used Transfer Mode SATA II 3.0Gb/s
         Interface SATA
         Capacity 14.9 GB
         Real size 16,013,942,784 bytes
         RAID Type None
          S.M.A.R.T
           Status Good
            S.M.A.R.T attributes
          Partition 0
           Partition ID Disk #2, Partition #0
           Size 14.9 GB

    Hello @JoBla,
    Thank you for the information, and welcome to the HP Forums, I hope you enjoy your experience! To help you get the most out of the HP Forums I would like to direct your attention to the HP Forums Guide First Time Here? Learn How to Post and More.
    I have read your post on how you are wondering if your desktop computer's hard disk is caching is being used, and I would be happy to assist you in this matter!
    For caching on your computer, you will have needed to install one of the following drives:
    1 TB, 7200 rpm, SATA
    2 TB, 7200 rpm, SATA
    3 TB, 7200 rpm, SATA
    1 TB, 7200 rpm, SATA + 16 GB Disk Caching Solid State Drive
    2 TB, 7200 rpm, SATA + 16 GB Disk Caching Solid State Drive
    3 TB, 7200 rpm, SATA + 16 GB Disk Caching Solid State Drive
    128 GB SATA Solid State Drive
    256 GB SATA Solid State Drive
    It is likely that this caching drive will be shown in Disk Management, which can be accessed by following this document on Partitioning and Naming Drives (Windows 8). It is important to note that an mSATA drive will not be visible in Windows, if you have one installed. You will also need to have Intel RST software installed.
    I hope this helps!
    Best Regards
    MechPilot
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the right to say “Thanks” for helping!

  • How to check if a DSO Active Table is being used in any look-up's?

    Hi Gurus,
    We have a DSO that is being loaded on a weekly basis. Now this DSO is being loaded right from the time our project went live. There are no reports built on top of this DSO and the DSO is not being used as a Data Mart i.e. it doesn't feed any other DSO's or InfoCube's. Also this DSO is not being used in any MultiProviders.
    So the only sensible reason for using this DSO that we can think of is that the data from this DSO is being 'looked up' by some other DSO's or InfoCube at run-time. So Is it possible to check if the active data table of an DSO is being ;looked up' at run time by some other data loads? I already tried using an 'Where Used List' on the active data table of the DSO, but it didn't show any results.
    Thanks
    Arvind

    Try the following:
    Check the table RSAABAP in SE16, you can search the technical name of DSOs active table in field EDIC.
    You get all Code-IDs, where this table is used in ABAP coding.
    In RSAROUT you can check, which code-type it is.
    Now you know, if the DSO is used in any routines.
    Hope this helps.
    Regards
    Tobias

  • How to read from a xml file(in String format) using a java program

    hi friends
    i have a string , which is xml format. i want read the values and display it.can any one suggest how to read a xml file of string format using a javaprogram
    thanks

            final DocumentBuilder db =  DocumentBuilderFactory.newInstance().newDocumentBuilder();      
            final InputStream documentStream = new ByteArrayInputStream(documentXMLSourceString.getBytes("utf-8"));
            final Document document = db.parse(documentStream);

  • How to know if a specific InfoObject is being used in any Query

    Dear SDN members,
    I have an InfoObject which is being used for one of the InfoCube. This specific Infocube has more than 100 queries created. Is there any way I can find out if above mentioned Info Object is being used anywhere in one of those queries without manually checking one by one.
    I tried where used list which appears on the InfoObject screen. This is just showing Cubes, ODS, TRs, Infosources... but not covering the queries.
    Your help is much appreciated.
    many thanks
    Shanthi

    Hi Shanti,
    You can see this in the Metadata repository.
    Select infoobject and the the specific infoobject.
    It will show you a list of queries where the infoobject is used.
    Success
    Udo

  • How do it know which backup files to keep and which to delete?

    How do you know which backup files to keep and which to delete?

    If you still have all devices, just delete all. They will re backup.

  • How to know whether a file is opened  or not ?

    Hi all,
    How to know whether a file is opened by its editor or not ? File may be any of the type.

    There are platform-dependent commands that tell whether a file (or directory, port etc.) is used by which processes.
    [oracle@izsak ~]$ fuser .
    .:                    9299c
    [oracle@izsak ~]$ ps -p  9299 -f
    UID        PID  PPID  C STIME TTY          TIME CMD
    oracle    9299  9298  0 Apr25 pts/0    00:00:00 -bash
    [oracle@izsak ~]$ ls -l $fn
    -rw-r-----  1 oracle oinstall 111215876 Apr 25 19:05 /opt/oracle/product/AS/10g/R2/opmn/logs/OC4J~ebank~default_island~1
    [oracle@izsak ~]$ fuser $fn
    /opt/oracle/product/AS/10g/R2/opmn/logs/OC4J~ebank~default_island~1:  3746  3747  3748  3749  3750  3751  3752  3753  3754  3755  3756  3758  3761  3762  3765  3767  3769  3770  3771 18638 21605 21743 21744 21745 22140 22143
    [oracle@izsak ~]$ ps -p 3746 -f
    UID        PID  PPID  C STIME TTY          TIME CMD
    oracle    3746 26427  0 Apr23 ?        00:00:01 /opt/oracle/product/AS/10g/R2/jdk/bin/java -server -Djava.security.policy=/opt...

  • How to get the number of files currently open?

    hi,
    does any one know how to get the number of files currently open in windows OS?
    e.g. lets say .txt files...
    any comment will be really appreciated.
    thanks

    Assuming that you don't want to actually do this from within Java code (which would obviously require native code), here's a utility that will give you a list of which file handles are opened by which processes (on Windows):
    http://www.sysinternals.com/ntw2k/freeware/handle.shtml
    - K

  • How To Store pdf or doc file in Oracle Database using Java Jdbc?

    can any one help me out How To Store pdf or doc file in Oracle Database using Java Jdbc in JSP/Serlet? i tried like anything. using blob also i tried. but i am able 2 store images in DB not files. please if u know or else if u have some code like this plz send that to me, and help me out plz. i need that urgent.

    Hi.. i am not getting error, But i am not getting the original contents from my file. i am getting all ASCII vales, instead of my original data. here i am including my code.
    for Adding PDF in DB i used image.jsp
    Database table structure (table name. pictures )
    Name Null? Type
    ID NOT NULL NUMBER(11)
    IMAGE BLOB
    <%@ page language="java" import="java.util.*,java.sql.*,java.io.*" pageEncoding="ISO-8859-1"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%
    try{
         Class.forName("oracle.jdbc.driver.OracleDriver");
         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
         PreparedStatement ps,pstmt,psmnt;
         ps = con.prepareStatement("INSERT INTO pictures VALUES(?,?)");
    File file =
    new File("D:/info.pdf");
    FileInputStream fs = new FileInputStream(file);
    ps.setInt(1,4);
    ps.setBinaryStream(2,fs,fs.available());
    int i = ps.executeUpdate();
    if(i!=0){
    out.println("<h2>PDF inserted successfully");
    else{
    out.println("<h2>Problem in image insertion");
    catch(Exception e){
    out.println("<h2>Failed Due To "+e);
    %>
    O/P: PDF inserted successfully
    i tried to display that pdf using servlet. i am giving the code below.
    import java.io.IOException;
    import java.sql.*;
    import java.io.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class DispPDF extends HttpServlet {
         * The doGet method of the servlet. <br>
         * This method is called when a form has its tag value method equals to get.
         * @param request the request send by the client to the server
         * @param response the response send by the server to the client
         * @throws ServletException if an error occurred
         * @throws IOException if an error occurred
         public void service(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              //response.setContentType("text/html"); i commented. coz we cant use response two times.
              //PrintWriter out = response.getWriter();
              try{
                   InputStream sPdf;
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                        Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
                        PreparedStatement ps,pstmt,psmnt;
                   psmnt = con.prepareStatement("SELECT image FROM pictures WHERE id = ?");
                        psmnt.setString(1, "4"); // here integer number '4' is image id from the table.
                   ResultSet rs = psmnt.executeQuery();
                        if(rs.next()) {
                   byte[] bytearray = new byte[1048576];
                        //out.println(bytearray);
                        int size=0;
                        sPdf = rs.getBinaryStream(1);
                        response.reset();
                        response.setContentType("application/pdf");
                        while((size=sPdf.read(bytearray))!= -1 ){
                        //out.println(size);
                        response.getOutputStream().write(bytearray,0,size);
                   catch(Exception e){
                   System.out.println("Failed Due To "+e);
                        //out.println("<h2>Failed Due To "+e);
              //out.close();
    OP
    PDF-1.4 %âãÏÓ 2 0 obj <>stream xœ+är á26S°00SIá2PÐ5´1ôÝ BÒ¸4Ü2‹ŠKüsSŠSŠS4C²€ê P”kø$V㙂GÒU×713CkW )(Ü endstream endobj 4 0 obj <>>>/MediaBox[0 0 595 842]>> endobj 1 0 obj <> endobj 3 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj xref 0 7 0000000000 65535 f 0000000325 00000 n 0000000015 00000 n 0000000413 00000 n 0000000168 00000 n 0000000464 00000 n 0000000509 00000 n trailer <<01b2fa8b70ac262bfa939cc786f8770c>]/Root 5 0 R/Size 7/Info 6 0 R>> startxref 641 %%EOF
    plz help me out.

  • How can i upload a image file to server by using jsp or servlet.

    Hi,
    I m gurumoorthy. how can i upload a image file to server by using jsp or servlet without using third party API. pls anyone send me atleast outline of the source code.
    Pls send me anyone.
    Regards,
    Gurumoorthy.

    I'm not an applet programmer so I can't give you much advice there.
    If you want to stream the file from the server before it's entirely uploaded, then I don't believe you can treat it like a normal file. If you're just wanting to throw it up there and then listen to it, then you can treat it like a normal file.
    But again, I'm not entirely certain. You might be able to stream the start of the file from the server while you're still uploading the end of it, but it probably depends on what method you're using to do the transfer.

  • How do i get my mp3 file to open in garageband?

    how do i get my mp3 file to open in garageband?

    PsychSlinger wrote:
    how do i get import my mp3 file to open in garageband?
    http://www.bulletsandbones.com/GB/GBFAQ.html#importaudio
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • How to append paragraph in text file of TextEdit application using applescript

    how to append paragraph in text file of TextEdit application using applescript and how do i save as different location.

    christian erlinger wrote:
    When you want to print out an escape character in java (java is doing the work in client_text_io ), you'd need to escape it.
    client_text_io.put_line(out_file, replace('your_path', '\','\\'));cheersI tried replacing \ with double slash but it just printed double slash in the bat file. again the path was broken into two lines.
    file output
    chdir C:\\DOCUME~1\
    195969\\LOCALS~1\\Temp\
    Edited by: rivas on Mar 21, 2011 6:03 AM

  • How to know the full path which is being used in the dataconnection .

    How to know the full path which is being used in the dataconnection without going and looking into coding.
    I am new to crystal reports.
    Plz advice.Thanks in advance
    Jay

    This forum is dedicated to topics related to custom application development or deployment with Crystal Reports in .Net. This includes full versions of Crystal Reports as well as those versions of Crystal Reports bundled with Microsoft Visual Studio .Net.
    As you do not want to do any coding, this query is in the wrong forum. However, in most versions of Crystal Reports, you can look up the database connection information by simply opening the report in the CR designer. Then go to the database menu and select "Set Datasource Location..."
    Ludek

  • How to insert data from *.dmp file to  oracle 11g using Oracle SQL Develope

    hi
    i backup my database using PL/SQL developer and made *.dmp file
    how to insert data from *.dmp file to oracle 11g using Oracle SQL Developer 2.1.1.64
    and how to make *.dmp file from sql*plus ?
    thanks in advance

    Pl/Sql developer has a config window, there you choose the exec to do the import/export.
    Find it and his home version, it may be exp or expdp, the home version is the version of the client where the exp executable is.
    Then use the same version of imp or impdp to execute the import, you do not need to use Oracle SQL Developer 2.1.1.64. If you want to use it, you must have the same version in the oracle home that exp/imp of sql developer use.

Maybe you are looking for