Results 1 to 5 of 5

Thread: Retrieve the Path of a File open by an EXE !!

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    43

    Retrieve the Path of a File open by an EXE !!

    Is there a way of getting the qualified name (ie full path + name) of a file that is currently open by an foreign application without using Automation.

    So for example, let's say a running instance of Excel has a workbook open. How can I get ,from my VB application, the full path of this WorkBook file ?

    As I said , I don't want to use Automation with which I could easily use the VB GetObject function .This is because I need this for other applications that do not support Automation.

    I assume this could be solved via some API programming..well I hope so

    Hope this make sense.

    Any takers.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Retrieve the Path of a File open by an EXE !!

    In general, it isn't possible.

    Many programs open files but do not lock them, they just load the data at one point and save it at another.

    If the file stays locked then presumably you will be able to track down the application using a few API calls (I don't know which I'm afraid), but are unlikely to be able to do it the other way around.

    Why are you wanting to do this?

  3. #3

    Re: Retrieve the Path of a File open by an EXE !!

    investigate this decleration:

    VB Code:
    1. Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
    2.  
    3. Public Type OPENFILENAME
    4.         lStructSize As Long
    5.         hwndOwner As Long
    6.         hInstance As Long
    7.         lpstrFilter As String
    8.         lpstrCustomFilter As String
    9.         nMaxCustFilter As Long
    10.         nFilterIndex As Long
    11.         lpstrFile As String
    12.         nMaxFile As Long
    13.         lpstrFileTitle As String
    14.         nMaxFileTitle As Long
    15.         lpstrInitialDir As String
    16.         lpstrTitle As String
    17.         flags As Long
    18.         nFileOffset As Integer
    19.         nFileExtension As Integer
    20.         lpstrDefExt As String
    21.         lCustData As Long
    22.         lpfnHook As Long
    23.         lpTemplateName As String
    24. End Type

    i've never used it though, but i have read about it a little.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Retrieve the Path of a File open by an EXE !!

    That is used to show the "Open" common dialog I'm afraid.

  5. #5

    Re: Retrieve the Path of a File open by an EXE !!

    lol, i doubt it helped then.

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