|
grassrootkit wrote: * Just by knowing the component's CLSID & the interface's IDs?
Use a component with the "import" directive, that takes information from the .tlb file? <-won't this require any header file?
A header file will be created during the build process that usually has the .tlh extension.
grassrootkit wrote: * Creation using ProgIDs is efficient?
In comparison to what? The CLSID I presume. Due to how the registry is organized, using the ProgID will require an extra round-trip to find out the CLSID since it's underneath that key in the registry the path to the dll is found.
grassrootkit wrote: * A COM DLL doesn't mean a component. A COM dll may contain any number of components inside.
Correct in the sense that a COM DLL may contain more than one COM server.
grassrootkit wrote: * A CoClass is a component object. As a COM DLL can contain more components, there'll be more CoClasses accordingly.
Yes.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
hopefully we gave the same results
|
|
|
|
|
|
But what does this mean?
#import "C:\Program Files\Common Files\System\ADO\msado15.dll"
|
|
|
|
|
It means that you want to include type library information from the file.
Read more here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Also, my program has not generated any .tlh or .tli files. But it has created a C file with _i suffixed. like this : MyComTest_i.c. I should use this rather?
Using VC8.0.
|
|
|
|
|
The extensions of the preprocessor generated files can be configured in the project settings. Different versions of MSVC seem to use different extensions.
Don't worry about the *.c-file. If you want to use the typelibrary information from another file, simply include the preprocessor generated header file.
A common way is to do the import in the stdafx.h file and then include the preprocessor generated header file as needed.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
//You mean,In the project option, Configuration properties-> MIDL->Output->IID File = MyProject_i.c ?
I should use this file for using with client?
|
|
|
|
|
|
Hi guys,
I have COM DLL Servers creating a lot of COM objects with CoCreateInstance and it's quite slow.
I wondered if replacing the CoCreateInstance(CLSID_Foo) by a new CComObject < CFoo > would speed up things ?
Or to be clearer, how slower is CoCreateInstance compared to new operator ?
thanks !
|
|
|
|
|
Alexandre GRANVAUD wrote: I wondered if replacing the CoCreateInstance(CLSID_Foo) by a new CComObject < CFoo > would speed up things ?
No.
Since in both ways a COM object is created. Using the "new operator", as you call it, will eventually call ::CoCreateInstance() , so there's no difference.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
calling new CComObject < CThing > calls CoCoreateInstance????
i'm sure it doesnt !!
|
|
|
|
|
Alexandre GRANVAUD wrote: calling new CComObject < CThing > calls CoCoreateInstance????
i'm sure it doesnt !!
No, of course; allocating memory for a CComObject doesn't call ::CoCreateInstance() .
But in order to create the server you'd have to call CComObject::CreateInstance() .
Otherwise the server won't be created and your comparison wouldn't make sense at all.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
why do you need to call it ?
as i can see, the CCOmObject constructor call FinalConstruct, so what extra initialization do we need ?
|
|
|
|
|
You simply cannot use new to create COM objects (COM objects lifetime has its own rules ). If you need to create multiple objects, then you may obtain a speed enhancement using directly the IClassFactory interface, see the remarks section of this page [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
yes you can in the same DLL, i do it everyday : in inprocess it's ok to do so
new CComObject < CThing > then doing a Queryinterface or a AddRef on it and your object is ok
|
|
|
|
|
And what is the rationale behind that (other than revealing your bad practices )?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
speed is always a good practice
having a bad practice is ok if you know you have (i do ) and know the consequences
|
|
|
|
|
|
lol i agree for the speed (but can't slowdown)
i don't break the com creation mechanism : the CreateInstance in a ClassFactory does exactly the same : a new CComObject<cthing> !
|
|
|
|
|
Alexandre GRANVAUD wrote: i don't break the com creation mechanism : the CreateInstance in a ClassFactory does exactly the same : a new CComObject !
Avoiding such call you're breaking it by definition. Of course you'll see the practical implications of such a wicked act just on 'strange' servers (i.e. servers that don't "do exactly the same", such a behaviour is allowed by COM ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi,
Please, I developed an application with C + + and I need help; I am trying to test in my application that usually requires a COM + dll and I wonder how I could test that this dll is registred or no and it should display a message if this dll is not in the register or it does not exist?
thanks
|
|
|
|
|
What about calling CoGetClassObject [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i just create an instance of a class in this dll and after i do a test if it is registred or no .this are some lines of code which can explain what i need exactly:
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
hRes = TContext::CreateInstanceNoAppID(CLSID_TLibraryInformation_SeeEdbUI, &piLibInfoSeeEdbUI);
if(FAILED(hRes))
{
if(hRes == REGDB_E_CLASSNOTREG)
{
strTemp.LoadString(IDS_SEEEDBUIDLL_NOT_FOUND);
TErrorTool::DisplayErrorStack(TRUE, _bstr_t(strTemp));
}
else
{
strTemp.LoadString(IDS_SEEEDBUIDLL_NOT_FOUND);
TErrorTool::DisplayErrorStack(TRUE, _bstr_t(strTemp));
}
exit(0);
}
|
|
|
|
|
You don't you trust CoGetClassObject , do you? Why?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|