|
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.
In C#.net we have BinkToMoniker to get the object. Is there any such thing in C++(unmanaged).
Thanks in advance.
Regards,
KTT
|
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
|
Please do not post the same question in multiple forums, read the guidelines[^].
|
|
|
|
|
Hi,
We have used the same code as given in
http://blogs.msdn.com/oldnewthing/archive/2004/04/23/118893.aspx
to capture objects under mouse in timer.But we are facing memory leakage problem.
While debuging this code we got the point of leakage is in function
AccessibleObjectFromPoint.
We already using IAccesible::Release function and VariantClear to release memory
but still memory leakage is there.
Any one know ,how to release memory used after AccessibleObjectFromPoint is called.
Please help.
Thanx in advance.
-Jay
|
|
|
|
|
The leak could be from accessing a member function of IAccesible and not freeing its output parameter like the SysFreeString in the link.
You should consider using ATL classes like CComPtr[^] which is a smart pointer and do not need to be released.
Some other useful ATL classes are -
CComBSTR[^]
CComVariant[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
Hi,
Thanx for reply.
Actualy we had removed all IAccessible function calls to clear that doubt,So now there is only one function call in timer that AccessibleObjectFromPoint() ,But still there is a memory leakage.
If you have any knowledge regarding this please let us know.
Thanx again,
-Jay
|
|
|
|
|
Hi. I call my own external function from html:
my.html
var data = "";
data = window.external.MyOwnDhtmlFunction();
In derived class CMyDhtmlDlg:
1.
CMyDhtmlDlg()
{ EnableAutomation(); }
2.
STDMETHODIMP CMyDhtmlDlg::GetExternal(IDispatch **ppDispatch)
{
*ppDispatch = GetIDispatch(TRUE);
return TRUE;
}
3. BOOL CMyDhtmlDlg::OnInitDialog()
{ SetExternalDispatch(GetIDispatch(TRUE)); }
4.
BEGIN_DISPATCH_MAP(CMyDhtmlDlg, CDHtmlDialog)
DISP_FUNCTION(CMyDhtmlDlg, "MyOwnDhtmlFunction", MyOwnDhtmlFunction, VT_BSTR, VTS_NONE)
END_DISPATCH_MAP()
Its all ok in windows xp sp2 ie 6.0. I can call MyOwnDhtmlFunction from html. But its doesnt work in windows xp sp1 ie. 6.0. How can i make it work in win xp sp1 under ie 6.0. And one more thing, what are the system requirements for CdhtmlDialog ? Can i use it in windows NT sp6 with ie 6.0 ?
Please help me. Thanks for reply and sorry for my bad english.
Its me
|
|
|
|
|
Hi all... in my application i want get the original GetInfoTip() text, after it i want edit and show the new modified Text.
Now i use IQueryInfo for "hook" the GetInfoTip() function and work very well, but i must rewrite all file information tip text myself.. I have added:
NoRemove *
{
NoRemove ShellEx
{
{00021500-0000-0000-C000-000000000046} = s '{MYKEY}'
}
}
It's for all file and i have some trouble for reset the InfoTip text... any mode for get original default?
I have tryed this code:
IShellFolder* shFolder = NULL;
IQueryInfo* pInfo;
LPITEMIDLIST pidl = NULL;
SHGetDesktopFolder(&shFolder);
SHILCreateFromPath(file, &pidl, 0);
if (SUCCEEDED(shFolder->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&pidl, IID_IQueryInfo, NULL, (void**)&pInfo)))
{
pInfo->GetInfoTip(0, &pwszTip);
pInfo->Release();
if (pwszTip)
{
MessageBox(NULL, pwszTip, NULL, MB_OK);
}
}
But it still show the tip text of My Computer icon
Thanks in advance.
|
|
|
|
|
anyone???
modified on Saturday, October 10, 2009 4:33 PM
|
|
|
|
|
Did You check this code for any other type of files (.cpp, .h or anything else) ?
May be Shell does not analyze registry entry *.
|
|
|
|
|
Our company has an created an ActiveX control using Visual Basic 6 that allows users to view TIFF images in a web page. When Office 2007 is installed, the error "component not correctly registered" shows up when this web page is loaded and the ActiveX control calls the AsyncRead function. We do not see this error when other versions of Office are installed; it will work just fine with Office 2000 and Office 2003. Also, the applications in Office 2007 do not need to be running for this error to occur.
I have tried removing the control from the Downloaded Program Files folder and downloading it again, but I am still getting the same error.
Any help would be appreciated.
|
|
|
|
|
Does the control have any dependency on any of the office components?
If so you may need to release a separate version of your control that works with Office 2007.
Otherwise try and install (register) your control after installing Office 2007.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
I think your ActiveX control has dependency on Office 2003 Web component 1.1..If so then you need to update your ActiveX com.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I think your ActiveX control has dependency on Office 2003 Web component 11.0 ..If so then you need to update your ActiveX com.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
i need to create a web interface to control (enter the multicast address, set playlist,start/stop streaming) the multicast settings of the windows media services, in server 2003.so that an admin can log in from any machine in the network and control the main streaming server.
it is for my project and its very urgent.
can anyone help me we it?some tell me to go with a COM, but i have no idea how to do it.any alternatives?please, im desperate.
thank you
|
|
|
|
|
Hi,
I hve just started learning COM. Can anybody suggest me some books, online tutorials etc.,
Thanks in advance
Sairam
|
|
|
|
|
|
Try this book:
Essential Com By Don Box
|
|
|
|
|
Hi All,
now I get connected in my main.cpp file to the server. I hope this will be correct. But how can I get now an event from the server? The server sends some events. I can see that because an Message Dialog will be opened from the server.
Now my questions are the following:
a)
Is the code until now correct? Is it possible to make a test if I get the correct connection or anything else?
b)
How can I get in the main.cpp an event (OnShowMessageDlg) or any message from the server? Do I need to add something to the sink class?
c)
Must I add something in the Sink class to get the an event in the invoke function? Or how should this work?
Let me know If you need any more information.
Once more, thanks for any help.
Juergen
main.cpp File
CComPtr<ICWOLE2> tCWOLE;
HRESULT hr;
hr = CoInitialize(0);
hr = CoCreateInstance(CLSID_CWOLEv2, 0, CLSCTX_LOCAL_SERVER, IID_ICWOLE2, (void**)&tCWOLE);
IConnectionPointContainer * pConnPtContainer;
hr = tCWOLE->QueryInterface(IID_IConnectionPointContainer,(void**)&pConnPtContainer);
if(FAILED(hr)){
CoUninitialize();
return false;
}
CComPtr<IConnectionPoint> ICPoint;
hr = pConnPtContainer->FindConnectionPoint(DIID_ICWOLEEvents,&m_pConnectionPoint);
if(FAILED(hr)){
CoUninitialize();
return false;
}
m_sink = new CSink;
LPUNKNOWN pUnk = NULL;
m_sink->QueryInterface(IID_IUnknown,(void**)&pUnk);
hr = m_pConnectionPoint->Advise(pUnk,&m_sink->cookie);
if(FAILED(hr)){
CoUninitialize();
return false;
}
pConnPtContainer->Release();
.
.
.
.
.
.
m_pConnectionPoint->Unadvise(m_sink->cookie);
m_pConnectionPoint->Release();
m_sink->Release();
CSink.h
class CSink : public ICWOLEEvents
{
public:
CSink::CSink() {m_refCount = 1, cookie = 0;}
CSink::~CSink() {}
STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP GetTypeInfoCount(UINT *iTInfo);
STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
STDMETHODIMP Invoke(DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo,
UINT* puArgErr);
public:
int m_refCount;
DWORD cookie;
void OnShowMessageDlg(IMsgDlg *pIMsg, VARIANT_BOOL *Result);
};
CSink.cpp
HRESULT CSink::QueryInterface(REFIID riid, void ** ppvObj)
{
if (riid == IID_IUnknown){
*ppvObj = static_cast<void*>(this);
}
else if (riid == DIID_ICWOLEEvents){
*ppvObj = static_cast<ICWOLEEvents*>(this);
}
else if (riid == IID_IDispatch){
*ppvObj = static_cast<IDispatch*>(this);
}
else
{
char clsidStr[256];
WCHAR wClsidStr[256];
char txt[512];
StringFromGUID2(riid, (LPOLESTR)&wClsidStr, 256);
WideCharToMultiByte(CP_ACP, 0, wClsidStr, -1, clsidStr, 256, NULL, NULL);
sprintf(txt, "riid is : %s: Unsupported Interface", clsidStr);
*ppvObj = NULL;
return E_NOINTERFACE;
}
static_cast<IUnknown*>(*ppvObj)->AddRef();
return S_OK;
}
STDMETHODIMP_(ULONG) CSink::AddRef()
{
return ++m_refCount;
}
STDMETHODIMP_(ULONG) CSink::AddRef()
{
return ++m_refCount;
}
STDMETHODIMP_(ULONG) CSink::Release()
{
if (--m_refCount == 0)
{
delete this;
return 0;
}
return m_refCount;
}
STDMETHODIMP CSink::GetTypeInfoCount(UINT *iTInfo)
{
return E_NOTIMPL;
}
STDMETHODIMP CSink::GetTypeInfo(UINT iTInfo, LCID lcid,
ITypeInfo **ppTInfo)
{
return E_NOTIMPL;
}
STDMETHODIMP CSink::GetIDsOfNames(REFIID riid,
OLECHAR **rgszNames,
UINT cNames, LCID lcid,
DISPID *rgDispId)
{
HRESULT hr = E_FAIL;
return hr;
}
STDMETHODIMP CSink::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
if ((riid != IID_NULL))
return E_INVALIDARG;
HRESULT hr = S_OK;
return hr;
}
void CSink::OnShowMessageDlg(IMsgDlg *pIMsg, VARIANT_BOOL *Result){
}
Test.idl
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: test_programm.exe
[
uuid(90B4344B-90CD-4527-BC00-4F4D45C793D6),
version(2.13),
helpstring("CW CWOLE")
]
library CW_CWOLE
{
importlib("stdole2.tlb");
interface ICWOLE2;
dispinterface ICWOLEEvents;
.
.
.
.
.
[
uuid(6775FB91-B5BE-11D6-A996-0050BA24C7B9),
version(1.1),
helpstring("Event dispatch interface for CW CWOLE")
]
dispinterface ICWOLEEvents {
properties:
methods:
[id(0x00000001)]
void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept);
[id(0x00000002)]
void OnShowMessageDlg(
[in] IMsgDlg* pIMsg,
[out, retval] VARIANT_BOOL* Result);
};
typedef [uuid(5CBBA151-1C47-4D6C-B14C-C527E333F812), version(1.2)]
enum {
ECS_DEFAULT = 0,
ECS_FRONT = 1,
ECS_LEFT = 2,
ECS_RIGHT = 3,
ECS_LEFTUP = 4,
ECS_RIGHTUP = 5,
ECS_TOP = 6,
ECS_BACK = 7,
ECS_BACKLEFTUP = 8,
ECS_BACKRIGHTUP = 9,
ECS_BOTTOM = 10
} ECamSetup;
typedef [uuid(9545E3CA-6401-4418-A040-DA3A89E2C792), version(1.3)]
enum {
EPM_PERSP = 0,
EPM_ORTHO = 1,
EPM_2D = 2
} EProjectionMode;
[
uuid(F560F763-2948-11D7-A9BF-0050BA24C7B9),
version(2.13),
helpstring("CWOLE2")
]
coclass CWOLEv2 {
[default] interface ICWOLE2;
[default, source] dispinterface ICWOLEEvents;
};
|
|
|
|
|