|
I am making calls from my C# client to COM server. One function of the COM server returns a VARIANT of safearray containing BSTRs. Another function of COM server removes/destroy the VARIANT from memory. After receiving the VARIANT as an "object" in the C# client and processing the information, I am trying to use the destroy function to remove the VARIANT permanently. Because of memory management in the Managed side, the unmanaged code fails to remove the VARIANT. I was hoping to use "fixed" keyword but it does not work with "object". Is there any possible approach to achieve this requirement?
Thanks for your help in advance.
|
|
|
|
|
You don't have to warry about a VARIANT of safearray which contains BSTRs
C# GC will destroy it by oneself
Or You can destroy it like obj=null.
|
|
|
|
|
how to get all the com interface with VC 6.0
i just to know "ITextDocment"..
and i want to know all the interface like "ITextDocment"
how can i to know and where the docment
when i found on MSDN ,but it only support .net
i am work on VC 6.0
|
|
|
|
|
|
HI,
I have little knowledge in COM. But in my recent interview i faced these questions, and i couldnt answer.
please clarify my doubts.
1.) If I crate 2 Components with same name then how do I call the desired component?
Because Iam passing only Component name as parameter to CreateInstance Function?
2.) If I crate 2 Components with same name and iam going to register ,then what will happen ?
3.) If you need to add new functionality to your COM Component, then what do you do for that?
Can you change existing COM component ? Do you need to register once again?
Thanks,
Krishna Rayalu
|
|
|
|
|
A COM component is identified using a class Id called a CLSID and not its name.
If you want to add new functionality to an existing COM component, you create a new interface.
It is not necessary to register the component again because the CLSID doesn't change.
|
|
|
|
|
Thank you so much for your Knowledge sharing.
Regards,
Rayalu.
|
|
|
|
|
Hello
I have two COM local servers developed using ATL. The local servers have interface pointers to each other and the pointers will be released when
Stop()is called from a client to each server. The client will also release its pointers to the servers and both components will die (lock count == 0).
Now to my problem. If one of the components crash I have a problem to shut down the other server. The still running server will have a lock count from the allready dead server.
I would be very happy if someone could give me a sugestion how to solve this.
Johan
|
|
|
|
|
Can I ask why you're not concentrating on preventing the 'crash' instead of putting effort into trying to deal with the after effects of such a crash?
|
|
|
|
|
The local servers are running on an embedded device with Windows CE. Before release everything should be tested as good as possible but there is still a risk for crashes. The most obvious would be to implement a watchdog which would reset the device but this is not an option because of the long boot time of the operating system.
Each server implements a watchdog configured to terminate the server process. This termination will be notised by the client and the client restarts the terminated server.
One way to shut down servers who refuse to die is to send WM_QUIT to it. This whould probably work because this is what happen when the lock count reach zero. This solution is very ugly and I am looking for the right way to do it. There must be a standard solution for problems like this.
|
|
|
|
|
I've never done abything on CE but how about...
Johan.Wade wrote: This termination will be notised by the client and the client restarts the terminated server.
If your client can notice that one of the local servers has been termnated, the client must then be able to instruct the other non-terminated server to ignore the pointer it holds to the terminated server. To recover the client can then set up a new server and by some mechanism have them 'discover' each other to set up new pointers.
During the 'instruction to ignore the other server', that is prior to the 'discover' phase, the server must be instructed by the client to internally call Release to restore the existing servers count to 1.
|
|
|
|
|
Johan.Wade wrote: Now to my problem. If one of the components crash I have a problem to shut down the other server. The still running server will have a lock count from the allready dead server.
I would be very happy if someone could give me a sugestion how to solve this.
There is an IExternalConnection interface which can help in your troubles.
With best wishes,
Vita
|
|
|
|
|
Hello Friends,
I am develping a simple Addon(Extension)
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService (Components.interfaces.nsIObserverService);
var enu = observerService.enumerateObservers("domwindowclosed")
while(enu.hasMoreElements())
{
var x1 = enu.getNext()
}
It works fine, from here i want to identify which addon(Extension) uses the current X1
pls help some sone
thanks in advance
|
|
|
|
|
You better read the MDC because FF-Addons arent here a big issue.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I had used the DirectShowLib 2005 and DirectX libraries for saving videos in WMV format.The Format is wmv and the video standard is PAL_B.
In my application I was able to see the preview of the Video but when saving an error comes "HResult E_FAIL returned from COM DEVICE" on mediaController.Run().Why is this error coming any idea will be very beneficial.
Thanks
|
|
|
|
|
I don't know why you get E_FAIL but have you tried getting more information, if it's available, using the COM mechanism IErrorInfo?
HRESULT hr;<br />
CComPtr<IErrorInfo> spErrorInfo;<br />
hr = GetErrorInfo(0, &spErrorInfo);
|
|
|
|
|
Hi All,
I don't know whether my question will appear in COM category or not, sorry for that. I am working on windows platform with no administrative privileges. I want to send messages/files from my pc to another in LAN. I am using one software 'IP Messanger' which doesn't required any privileges to install it or to send messages/files from one pc to another in LAN. I know DOS commands like 'send','msg' etc. but they need 'Messenger' to be on. My pc's 'Messenger' is off but still 'IP Messenger' works fine. How? Can i send messages without turning 'Messenger' on? and how? Can anyone please explain this or just give me some idea so that i can search more on it.
Thanks
Nilesh
|
|
|
|
|
Nilesh Hamane wrote: My pc's 'Messenger' is off but still 'IP Messenger' works fine.
So what exactly is the problem? If IP Messenger works fine and can send messages/files your problem appears to be solved.
|
|
|
|
|
There is no problem with IP Messenger, its working fine; but i want know how can the software work well without turning 'Messenger' service on? Also i want know that, is there any method/command available in DOS to send messages/files without 'Messenger' service?
|
|
|
|
|
IP Messenger does not use the Messenger service, I expect it uses direct TCP/IP protocol to transfer data between computers. I am not aware of any direct DOS command to transfer between different machines unless you have FTP service running on the destination.
|
|
|
|
|
|
This is a though one (no, really).
I'm making a shell extension that implements infotip and thumbnail for cbz(zip) and cbr(rar) archives. For some COM-gods-only-known reason, it works flawlessly in XP but in Vista, behaviour is strange - infotip seems to work, but Vista loads dll only for showing infotip, and then immediately unloads it (observed in Process Explorer) and thumbnail extraction fails.
When I make separate dlls (old code adapted from some examples) for infotip and thumbnail, they work fine in Vista (but it would be nice to kill 2 flies with 1 strike). If I use this Explorer lookalike for debugging, thumbnails are sometimes extracted but it often silently crashes.
What am I doing wrong? (got ideas but not that much experience with COM /learning by copy-paste).
Thanks for your help in advance!
The project skeleton was created with vc6 and further with vc9express+WDK ATL/WTL.
Here is the complete project:
http://www.autohotkey.net/~T800/TEMP/CBXshell.zip
and quick peek of implementation:
class ATL_NO_VTABLE CCBXShell :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CCBXShell,&CLSID_CBXShell>,
public IDispatchImpl<ICBXShell, &IID_ICBXShell, &LIBID_CBXSHELLLib>,
public ISupportErrorInfo,
public IPersistFile,
public IExtractImage2,
public IQueryInfo
{
public:
CCBXShell() {}
BEGIN_COM_MAP(CCBXShell)
COM_INTERFACE_ENTRY(ICBXShell)
COM_INTERFACE_ENTRY(IPersistFile)
COM_INTERFACE_ENTRY(IQueryInfo)
COM_INTERFACE_ENTRY(IExtractImage)
COM_INTERFACE_ENTRY(IExtractImage2)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
DECLARE_REGISTRY_RESOURCEID(IDR_CBXShell)
DECLARE_PROTECT_FINAL_CONSTRUCT()
STDMETHOD(Load)(LPCOLESTR wszFile, DWORD dwMode) { return m_cbx.OnLoad(wszFile); }
STDMETHOD(GetClassID)(LPCLSID clsid){return E_NOTIMPL;}
STDMETHOD(IsDirty)(VOID){return E_NOTIMPL;}
STDMETHOD(Save)(LPCOLESTR, BOOL){return E_NOTIMPL;}
STDMETHOD(SaveCompleted)(LPCOLESTR){return E_NOTIMPL;}
STDMETHOD(GetCurFile)(LPOLESTR FAR*){return E_NOTIMPL;}
STDMETHOD(GetLocation)(LPWSTR pszPathBuffer, DWORD cchMax,
DWORD *pdwPriority, const SIZE *prgSize,
DWORD dwRecClrDepth, DWORD *pdwFlags)
{ return m_cbx.OnGetLocation(prgSize, pdwFlags); }
STDMETHOD(Extract)(HBITMAP* phBmpThumbnail) { return m_cbx.OnExtract(phBmpThumbnail); }
STDMETHOD(GetDateStamp)(FILETIME *pDateStamp) { return m_cbx.OnGetDateStamp(pDateStamp);}
STDMETHOD(GetInfoTip)(DWORD dwFlags, LPWSTR* ppwszTip) { return m_cbx.OnGetInfoTip(ppwszTip);}
STDMETHOD(GetInfoFlags)(LPDWORD pdwFlags) { *pdwFlags = 0; return E_NOTIMPL;}
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
private:
__cbx::CCBXArchive m_cbx;
}; CCBXArchive::GetLocation
HRESULT OnGetLocation(const SIZE *prgSize, DWORD *pdwFlags)
{
ATLTRACE("IExtractImage2::GetLocation\n");
m_thumbSize = *prgSize;
*pdwFlags |= (IEIFLAG_CACHE | IEIFLAG_REFRESH);
if (*pdwFlags & IEIFLAG_ASYNC) return E_PENDING;
return NOERROR;
}
|
|
|
|
|
Check in all your implementation for valid value. As her
in OnGetLocation(const SIZE *prgSize, DWORD *pdwFlags)
if( *prgSize &&*pdwFlags)
{
//your code
}
return E_FAIL;
COM is a real pain.
Good luck
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Still nothing.
I traced class members, but it seems that only infotip works ok.
In XP it goes (while shown in Explorer sidepane, debug output):
IPersistFile::Load
IExtractImage2::GetLocation
IPersistFile::Load
IQueryInfo::GetInfoTip
IExtractImage2::GetDateStamp
IExtractImage::Extract
but in Vista CCBXShell class destructs immediately (commented code, left only IExtractImage stuff):
CCBXArchive::CCBXArchive
CCBXShell::CCBXShell
CCBXShell::~CCBXShell
CCBXArchive::~CCBXArchive
I tried to (un)comment various stuff, like class inheritance, interface parts, unrar dependency, everything I could come up with but to no avail. I know that IExtractimage::GetDateStamp is broken in Vista, I tried also with Win7 RC1 (got it in virtual machine) - no good.
I still haven't tried to make IThumbnailProvider version (would be nice if I could make it more cross-windows).
Anyway, I'm running out of nerves, will and (my free) time (I'll skip harder words about M$).
I don't know if that misterious "com object aggregation" stuff might be relevant.
|
|
|
|
|