|
|
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;
};
|
|
|
|
|
Yes, you need to add code into the Invoke methods that looks at the dispid that's passed and maps that to the method you need to call. In addition, you need to unpack the parameter values from the struct pointed at by pDispParams.
Also, that thread needs to be in a window message dispatch loop - my understanding is that COM method calls are passed from other threads and processes into your thread using windows messages.
I know you can't/don't want to use ATL and I can totally understand that...but ATL does make this sort of thing REALLY easy
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
thanks a lot for your reply. Do you know if there will be an example about the invoke theme? I didn't know how this function will/must be called and how my functions then will be called / how I can get a message from the COM server above this invoke functions.
I know and I heared also from other people that it will be easier to work with ATL. But in this project I can't use ATL.
|
|
|
|
|
OK - the Invoke method is called when an event is raised by the server. It will tell you which method it's calling using the dispidMember parameter. The parameters to the call will be in the structure pointed at by pdispparams. You can pass back a result in pvarResult.
So, you could implement your Invoke using a switch statement and parameter transformation like this:
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;
switch (dispIdMember)
{
case 1:
if (pDispParams->cArgs != 1) return E_INVALIDARG;
if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL|VT_BYREF) return E_INVALIDARG;
OnConfigurationApply(V_BOOLREF(&pDispParams->rgvarg[0]));
break;
case 2:
break;
}
return hr;
}
HTH!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The problem I have before is that the Invoke Function will not be called. What must I do that this function will be called from the Server when an event is raised?
I can see that an event is raised from the server because an dialog will be opended. But the invoke function will not be called.
|
|
|
|
|
Your code all looks reasonable - I presume you've set a breakpoint in your Invoke method to see if it gets called?
I'd also set breakpoints on your AddRef, QueryInterface methods and see if they get called when you call the connection point's Advise method - that's how you tell the server about your event handler.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I set now also some breakpoints in the AddRef and QueryInterface Methods. These methods will be called. Only the Invoke function will not be called.
Do you know what I can do to test if I did something wrong or if the COM server works correct?
|
|
|
|
|
Suddenly realised what your problem could well be.
The server could be asking for your event handler's dispinterface methods by name - in which case you would need to implement GetIDsOfNames.
Or it could be asking for your class's type-information, in order to determine what methods and associated parameters are available. I think you need to investigate (with breakpoints) whether the othe r IDispatch methods are called. If they are, then as you don't implement them, the server will (as a result) decide not to call your IDispatch::Invoke method.
All these details, and the pain of implementation, are why I use ATL - I fully accept that you can't use ATL - I sympathize with your predicament!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|