Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Getting the running instance from PID using COM

Getting the running instance from PID using COM

Scheduled Pinned Locked Moved COM
csharpquestionc++comtesting
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KTTransfer
    wrote on last edited by
    #1

    Is there any way to get the instance of EXCEL.EXE from Process ID using COM? Similar to GetActiveObject, is there any other thing through which we can get the instances of multiple EXCEL.EXE running in Task Manager? After getting handle to each EXCEL.EXE, I want to track all workbooks and sheets. I am using EXCEL automation to do this using C++. Getting all workbooks and sheets is done. But after getting PID of EXCEL.exe's , how to get that object? I am getting PID for each process using psapi.h. I think I am not asking a question, which I am not supposed to or I shouldn't ask.:confused::~ In C#.net we have BinkToMoniker to get the object. Is there any such thing in C++(unmanaged). Thanks in advance. Regards, KTT

    _ V 2 Replies Last reply
    0
    • K KTTransfer

      Is there any way to get the instance of EXCEL.EXE from Process ID using COM? Similar to GetActiveObject, is there any other thing through which we can get the instances of multiple EXCEL.EXE running in Task Manager? After getting handle to each EXCEL.EXE, I want to track all workbooks and sheets. I am using EXCEL automation to do this using C++. Getting all workbooks and sheets is done. But after getting PID of EXCEL.exe's , how to get that object? I am getting PID for each process using psapi.h. I think I am not asking a question, which I am not supposed to or I shouldn't ask.:confused::~ In C#.net we have BinkToMoniker to get the object. Is there any such thing in C++(unmanaged). Thanks in advance. Regards, KTT

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      The following link should help you - How To Attach to a Running Instance of an Office Application[^] GetRunningObjectTable Function[^] IRunningObjectTable Interface[^]

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      1 Reply Last reply
      0
      • K KTTransfer

        Is there any way to get the instance of EXCEL.EXE from Process ID using COM? Similar to GetActiveObject, is there any other thing through which we can get the instances of multiple EXCEL.EXE running in Task Manager? After getting handle to each EXCEL.EXE, I want to track all workbooks and sheets. I am using EXCEL automation to do this using C++. Getting all workbooks and sheets is done. But after getting PID of EXCEL.exe's , how to get that object? I am getting PID for each process using psapi.h. I think I am not asking a question, which I am not supposed to or I shouldn't ask.:confused::~ In C#.net we have BinkToMoniker to get the object. Is there any such thing in C++(unmanaged). Thanks in advance. Regards, KTT

        V Offline
        V Offline
        Vi2
        wrote on last edited by
        #3

        KTTransfer wrote:

        In C#.net we have BindToMoniker to get the object. Is there any such thing in C++(unmanaged).

        AFAIK, BindToMoniker is an equivalent of C++ CoGetObject function.

        With best wishes, Vita

        K 1 Reply Last reply
        0
        • V Vi2

          KTTransfer wrote:

          In C#.net we have BindToMoniker to get the object. Is there any such thing in C++(unmanaged).

          AFAIK, BindToMoniker is an equivalent of C++ CoGetObject function.

          With best wishes, Vita

          K Offline
          K Offline
          KTTransfer
          wrote on last edited by
          #4

          Hey I tried all the ways but.....no Aim: To attach all the multiple processes of EXCEL.EXE's running in taskmanager and reading all sheets and workbooks using EXCEL automation. But using EXCEL automation only one instance of EXCEL we can connect using GetActiveObject. In above case only active instance is retrieved and even EXCEL.exe which is opened first is retrieved.But want to retrieve all workbooks and sheets in the running instances of EXCEL.EXE. Only way to differentiate between two EXCEL.EXE's running in taskmanager is PID. So want to connect the EXCEL instance using PID and then retrieving the workbooks and worksheets. IS there any way to get it, please give me clue. Thanks in Advance. Regards, KTTransfer.

          V 1 Reply Last reply
          0
          • K KTTransfer

            Hey I tried all the ways but.....no Aim: To attach all the multiple processes of EXCEL.EXE's running in taskmanager and reading all sheets and workbooks using EXCEL automation. But using EXCEL automation only one instance of EXCEL we can connect using GetActiveObject. In above case only active instance is retrieved and even EXCEL.exe which is opened first is retrieved.But want to retrieve all workbooks and sheets in the running instances of EXCEL.EXE. Only way to differentiate between two EXCEL.EXE's running in taskmanager is PID. So want to connect the EXCEL instance using PID and then retrieving the workbooks and worksheets. IS there any way to get it, please give me clue. Thanks in Advance. Regards, KTTransfer.

            V Offline
            V Offline
            Vi2
            wrote on last edited by
            #5

            KTTransfer wrote:

            IS there any way to get it, please give me clue.

            EXCEL registers each of his documents in ROT. Maybe, it's your case: you can enumerate all of EXCEL documents in ROT. PID is wrong way.

            With best wishes, Vita

            K 1 Reply Last reply
            0
            • V Vi2

              KTTransfer wrote:

              IS there any way to get it, please give me clue.

              EXCEL registers each of his documents in ROT. Maybe, it's your case: you can enumerate all of EXCEL documents in ROT. PID is wrong way.

              With best wishes, Vita

              K Offline
              K Offline
              KTTransfer
              wrote on last edited by
              #6

              http://support.microsoft.com/default.aspx/kb/238975 In above site(as suggested by superman) ,it is clearly written that EXCEL registers only one instance of EXCEL.EXE in ROT. The other instance can only be retrieved if names of workbooks are known. Even in the same site, it is mentioned that for multiple instance refer the site: http://support.microsoft.com/kb/190985 But as per my requirement I need to track all excel.exe's running in processes using MFC(No gui, only exe)application but not setting anything in EXCEL as mentioned in above site. If you get any clue from above mentioned sites, please let me know. Thanks in advance. Regards, KTTransfer

              J 1 Reply Last reply
              0
              • K KTTransfer

                http://support.microsoft.com/default.aspx/kb/238975 In above site(as suggested by superman) ,it is clearly written that EXCEL registers only one instance of EXCEL.EXE in ROT. The other instance can only be retrieved if names of workbooks are known. Even in the same site, it is mentioned that for multiple instance refer the site: http://support.microsoft.com/kb/190985 But as per my requirement I need to track all excel.exe's running in processes using MFC(No gui, only exe)application but not setting anything in EXCEL as mentioned in above site. If you get any clue from above mentioned sites, please let me know. Thanks in advance. Regards, KTTransfer

                J Offline
                J Offline
                Jorgen Sigvardsson
                wrote on last edited by
                #7

                If you read the first page you link to, you have: However, because Office applications also register their documents in the ROT, you can successfully attach to other instances by iterating the ROT looking for a specific document, attaching to this document, and then getting the Application object from this document. For a code example of iterating the ROT and looking for a document name, click the article number below to view the article in the Microsoft Knowledge Base:... You don't even have to reference each individual instance as all documents (from all instances of excel) is in the ROT. If you need the application object for a document, it's also there via the document object.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups