|
How to refresh the tree view of the namespace extension on addition or deletion of a node at runtime
|
|
|
|
|
Use SHChangeNotify()
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
I came across some MFC sample code recently that uses DirectShow to render MPEG files in a static control.
The sample code creates a number of DirectShow interface pointers in the main dialog (eg. IGraphBuilder, IMediaSeeking, IMediaControl etc) and then calls methods on these interfaces from a worker thread.
My question is, shouldn't these interface pointers all be marshalled to the worker thread using something like CoMarshalInterThreadInterfaceInStream()? I didn't think that pointers to COM interfaces could be shared amongst threads unless they were marshalled, or is DirectX different?
Note: The calls to the DirectShow interfaces from the worker thread seem to work perfectly fine.
Regards
Martin
|
|
|
|
|
In theory, the interface pointers should be marshalled if the thread is in a separate apartment to the main thread i.e. CoInitialize() has been called in the worker thread. However, if the main thread is a MTA, the worker thread will "share" the apartment and marshalling isn't explicitly necessary (generally, the "server" will AddRef() the interface before passing it on). The reason it currently works is most likely because the code is relatively simple and there is no contention over releasing/unmarshalling of interfaces between the main and worker threads. The marshalling mechanism becomes much more important when interfaces are passed over process boundaries.
|
|
|
|
|
You are right, the interface pointers must be marshalled when passed between apartments.
But MS doesn't always follow it's own rule. DirectX objects mostly use registered as "both" (which mean that whatever apartment you created them in, no proxy will be created), so it shouldn't cause any problem to pass the interfaces like that.
But unfortunately they will do the same (I believe that was a IGraphBuilder in DX 8.0 that I noticed was doing this) with the callback interfaces, i.e. if you created DX object and your callback object in the STA and pass the callback interface to DX object, the methods of your object might be called from any thread. (btw, I observed this with some shell interfaces as well)
Edward
|
|
|
|
|
Hi there.I read the article named Make the Internet Your Office with NetMeeting by Suresh G. Nair .But I am not familiar with ATL.I dont kown how to develop the ActiveX® Template Library (ATL)-based NetMeeting wrapper,and how to use the code offered by Nair in this article. can anybody help me?
|
|
|
|
|
I have a COM object I wrote in VC6 C++ a couple of years aago - I want to rename it and use it another project - how do I do that? No matter how much I change the name in the source files the old name still exists.
If it is called foo and I want it to become bar I have changed all references to foo I can find in the source files to bar yet when I come to reference it it is called foolib - is there a utility to rename a project?
Rugby League: The Greatest Game Of All.
|
|
|
|
|
In this context, does "all source files" include (a) the IDL/ODL file and any associated .REG or RGS files?
Steve S
|
|
|
|
|
I believe so - I have done a search on all the files looking for the name to rename.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
Delete the old object and clean your registry. Make sure the .rgs file is correct.
prashu
|
|
|
|
|
Done all that - it just won't go away - It's quicker just to write the thing again from scratch with a different name than it is to attempt to rename it.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
Thanks for your help everybody. I have given up on this now - 2 days of trying and got nowhere - changed every name, replaced every UUID, searched every file and yet the original name persists or the thing doesn't work at all. I have decided to spend the next 3 months rewriting it in .NET - hopefully I will never have to touch COM again.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
Hi!
I have one question to ask:
If I caught an Appointment window by means of InspectorEvents & ConnectionPoints and created a popup button in the Actions menu,
how do I make the button respond to my sink event?
Thanks!
|
|
|
|
|
Please find the article:
Building an Office2K COM addin with VC++/ATL
By Amit Dey
There is very good example.
================================
Useful links
|
|
|
|
|
All,
Can someone please provide me with the code for the following:
A COM object called Person with a property of Children and a property of Name
A COM Collection of Person elements as the Children property of a Person.
I wish to be able to use the following code in VB.
Dim objP as new Person
objP.Name = "dad"
dim objC as new Person
objC.Name = "child1"
objP.Children.Add objC
for each objC in objP
msgbox objC.Name
objC.Name = "already looped through"
next objC
Apologies, I have looked everywhere and cannot find an example of a read/write collection. I tried the collection wizard(s) supplied on this site, but then none of my creation code works in VB ("cannot create object").
AAGH!
Cheers,
Kieron
|
|
|
|
|
The object objP should implement the property:
[propget, restricted, id(DISPID_NEWENUM)]<br />
HRESULT _NewEnum([out, retval] IUnknown** retval);
The property should return the IUnknown interface of an object implementing IEnumVARIANT . It is the DISPID_NEWENUM + IEnumVARIANT combination that VB/VBS uses to accomplish For Each .
If you are implementing the COM objects in C++ and ATL, you may want to take a look at the MSDN documentation for CComEnumOnSTL , and use that to implement your collection.
--
Din mamma.
|
|
|
|
|
Hi all
I have a com that uses MFC.
When I register the com in a machine with Visual Studio everything is fine. But when I try to register the com in a machine without MFC it shows a error "Not all components could be loaded". Is it because I dont have visual studio installed in the target machine. ?
What files should I deploy with MyCom.dll to make it run everywhere..?
Thanks in advance
Regards
|
|
|
|
|
use Dependency walker tool comes with visual studio to c the dependecies of ur com dll. if mfc4x.dlls are not there in the mechine , then u have to copy that...
rgds.. mil10.
|
|
|
|
|
Hi
Thank you Mil
I will try it..
Regards
Shiraz
|
|
|
|
|
Hi all
In my com I want to accept a filename and open the specified file.
The client will call
mycom->open(char * filename)
How should be my com taking care of it. ?
Please Help me...am new to com..
Regards
|
|
|
|
|
To pass a string into a COM method, use a BSTR type parameter:
e.g. HRESULT IMyComInterface::Open(BSTR Filename);
which would be called like this (error handling and COM object creation omitted for clarity):
BSTR Filename = ::SysAllocString(L"c:\\myfile.txt");
HRESULT hR = pIMyComInterface->Open(Filename);
::SysFreeString(Filename);
HTH
|
|
|
|
|
Thank you for immeadiate response
But inside my com I want to get the string back without using MFC ie CString. How do i do it ?
ie char * filename = ( BSTR convertto string) BSTR file.
Regards
|
|
|
|
|
I think I understand what you're asking, does this help?
_bstr_t Tmp(Filename);
char* pFileToOpen = Tmp.operator char*();
(where Filename is the incoming BSTR parameter)
|
|
|
|
|
Hi
Thanks for your help Rory Solley.
In fact I tried this one, which I found in some previous message posts.
/*********************************
USES_CONVERSION;
const char *text = OLE2A(BSTRstring);
*********************************/
Thanks once again.
Regards
|
|
|
|
|
A BSTR is internally a WCHAR* that points to the beginning of the string. The length of the string is placed before the first character in memory.
You can assign a BSTR to a CString simply by constructing the CString object:
CString s = CString( file );
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|