Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7599149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:35:23+00:00 2026-05-30T22:35:23+00:00

This is a possible duplicate. Couldn’t find the exact one, I remember going through

  • 0

This is a possible duplicate. Couldn’t find the exact one, I remember going through one such long time back.

The tool needs a capability to detect if any MS Word file is opened anywhere from the computer. So we use a process watcher, like this:

string query = "SELECT TargetInstance FROM __Instance" + Event + "Event WITHIN 0.5 " +
               "WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = '" + processName + "'";

string scope = @"\\.\root\CIMV2";

//Create a watcher and listen for events
watcher = new ManagementEventWatcher(scope, query);
watcher.EventArrived += eventHandler;
watcher.Start();

Now whatever that is, here is the tricky part: I need to get the word automation instance of the currently opened WINWORD process. So I use Marshal.GetActiveObject to get the running instance. But an opened Word application gets registered in the running object table only if the word app loses focus (as documented by msdn). How do I manually register the word application in ROT if I have the process with me? Some pseudo code below

//process started
private void ProcessStarted(object sender, EventArrivedEventArgs e)
{
     // Marshal.GetActiveObject fails since there is no object yet.
     // Process.GetProcessesByName("WINWORD") got it.
     // now how to register this word process to ROT?
     // so that I have a global instance of word application?
}

Note: I can with some heavy API calls programmatically force focus away from opened word window and then bring it back, but thats a complete mess.

Any normal way of registering?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:35:25+00:00Added an answer on May 30, 2026 at 10:35 pm

    As far as I know there is no way to register another application’s objects in the ROT without its direct cooperation. The table doesn’t track processes, it tracks class factories and their associated monikers. In order to register something in the ROT you need its IUnknown pointer, which is not something you’re going to get from Word directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Returning reference to a local variable I happened to find this code
Possibly a duplicate, but I couldn't find an exact answer to my problem searching
I apologize if this is a duplicate post, but I couldn't find the answer
Possible Duplicate: CSS 3 content selector? I couldn't find a way online to hide
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: PHP ToString() equivalent I get this error: Catchable fatal error: Object of
Possible Duplicate: Plugging in to Java compilers Edit - this appears to be a
Possible Duplicate: NoClassDefFoundError - Eclipse and Android I'm seeing this question is getting asked
Possible Duplicate: php multi-dimensional array remove duplicate I have an array like this: $a
Possible Duplicate: What's wrong with this division? If you divide 2 / 3 ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.