我是2001 July的msdn。<br>上面有个例子,好好看看:<br>Interface from Running Object Table<br>A running object table (ROT) tells what object instances are active. By querying this table, you can accelerate the process of connecting a client to an object when the object is already running. Before programs can access TOM interfaces through the running object table, a TOM instance with a window needs to register in the ROT using a moniker. You construct the moniker from a string containing the hexadecimal value of its HWND. The following code sample shows how to do this.<br><br>// This TOM implementation code is executed when a new windowed <br>// instance starts up. <br>// Variables with leading underscores are members of this class.<br><br>OLECHAR szBuf[10]; // Place to put moniker<br>MONIKER *pmk;<br>wsprintf(szBuf, "%x", _hwnd);<br>CreateFileMoniker(szBuf, &pmk);<br>OleStdRegisterAsRunning(this, pmk, &_dwROTcookie);<br>....................<br> <br>// Accessibility Client: <br>// Find hwnd for window pointed to by mouse cursor.<br><br>GetCursorPos(&pt);<br>hwnd = WindowFromPoint(pt);<br><br>// Look in ROT (running object table) for an object attached to hwnd<br><br>wsprintf(szBuf, "%x", hwnd);<br>CreateFileMoniker(szBuf, &pmk);<br>CreateBindContext(0, &pbc);<br>pmk->BindToObject(pbc, NULL, IID_ITextDocument, &pDoc);<br>pbc->Release();<br><br>if( pDoc )<br>{<br> pDoc->RangeFromPoint(pt.x, pt.y, &pRange);<br> // ...now do whatever with the range pRange<br><br>