|
Hi Experts,
I want to create instance of a inteface(IPropertyBag) ,defind in a abc.dll file.
And same name interface exist in ocidl.h file.How can i pass a correct GUID
so that i can access method defind in abc.dll.
i try like this
IPropertyBag* Properties;
hr=CoCreateInstance(__uuidof(PropertyBag),NULL,CLSCTX_INPROC_SERVER,
__uuidof(IPropertyBag),(void**) &Properties);
|
|
|
|
|
pther wrote: I want to create instance of a inteface(IPropertyBag) ,defind in a abc.dll file.
You don't "create" interfaces.
You create a component and ask for one, or several, of its interfaces.
When you create a component you have to specify which component you want to create and which interface you want to access in that component.
This is what the arguments to ::CoCreateInstance() is for.
The first parameter should be the CLSID of the component you want to create, have a look here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
You can use the Visual Studio Ole View tool to see the CLSID of the object.
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.
|
|
|
|
|
I saw the CLSID by ole Tool as u suggested.And i try to put the CLSID directly in CoCreateInstance().
Like:
hr=::CoCreateInstance(uuid(47000673-7DB2-44C9-8AC1-65266117D280),NULL,CLSCTX_INPROC_SERVER,
__uuidof(IPropertyBag),(void**) &Properties);
But it dispaly syntext error.
error C2059: syntax error : ')'
error C2059: syntax error : 'bad suffix on number'
error C2059: syntax error : 'bad suffix on number'
error C2059: syntax error : 'bad suffix on number'
How can i make it correct
|
|
|
|
|
pther wrote: hr=::CoCreateInstance(uuid(47000673-7DB2-44C9-8AC1-65266117D280),NULL,CLSCTX_INPROC_SERVER,
__uuidof(IPropertyBag),(void**) &Properties);
You cannot use the CLSID string (47000673-7DB2-44C9-8AC1-65266117D280) that way, you have EITHER TO:
(1) Properly initialize the GUID struct members (The following example deals with MsComm control, asking for IUnknown interface):
GUID guid;
IUnknowun *pUnk;
guid.Data1 = 0x648A5600;
guid.Data2 = 0x2C6E;
guid.Data3 = 0x101B;
guid.Data4[0] = 0x82;
guid.Data4[1] = 0xB6;
guid.Data4[2] = guid.Data4[3] = guid.Data4[4] = guid.Data4[5] = guid.Data4[6] = 0x00;
guid.Data4[7] = 0x14;
hr = CoCreateInstance( guid, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **) &pUnk);
OR
(2) Use the UuidFromString to perform the task, i.e.
GUID guid;
IUnknown * pUnk;
RPC_STATUS Status = UuidFromString((unsigned char *)"648A5600-2C6E-101B-82B6-000000000014", &guid);
hr = CoCreateInstance( guid, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **) &pUnk);
Please note that point (2) requires the rpc.h header in your source file and to link your project with rpcrt4.lib library.
Hope that helps.
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.
|
|
|
|
|
Why does we pass a const reference object parameter in copy constructor?
|
|
|
|
|
why not ? maybe because we don't want to modify the original object ?
|
|
|
|
|
If you would pass an object instead of a reference, this would in turn call the copy constructor (because a copy of the object is made and passed to the function), so you will end in an infinite loop of calling copy constructor.
And for the const, it makes sense that you want to make a copy of the original object and not modify it.
|
|
|
|
|
toxcct wrote: hey, will you stop asking dummy question and think a little by yourself...
And another thread (How to Authorize a Dll Loading[^]):
that's stupid...
Did someone pee in your Cheerios today?
Jeff
|
|
|
|
|
You have posted several questions within a short amount of time that suspiciously look like homework.
__________________
Bob is my homeboy.
|
|
|
|
|
I dunno, they've been trying to figure out copy constructors since January. December
|
|
|
|
|
Remembering copy constructors I want to know if anyone knows the optimization issues with it. Does a compiler automatically synthesise a copy constructor if it is not found. What is the performance hit vis a vis a contructor although they both serve the different purpose.
Does anyone have debugged a copy constructor when it is not exclusively mentioned for a class.
|
|
|
|
|
Plz tell me how events are processed (flow of direction from WinApp to Doc)in Doc-view architecture in VC++?
|
|
|
|
|
Plz look it up in MSDN.
WM_CONTROL is one of the words you could try searching.
Failure is not an option - it's built right in.
|
|
|
|
|
jhwurmbach wrote: WM_CONTROL is one of the words you could try searching.
Got a link for that message?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No, but additionally to making a sniding remark at me (which I deserved), you *could* have given him the link to WM_COMMAND .
Failure is not an option - it's built right in.
|
|
|
|
|
jhwurmbach wrote: ...you *could* have given him the link to WM_COMMAND.
You're assuming I knew that was your intent. I had no idea what message you were referring to (hence the sincere question).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Provide me a simple code for multithreading,so that i can start it.
|
|
|
|
|
See Here[^]
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
It seems that your link has problem. www.codeproject.com/info/error500.asp?500;http://www.codeproject.com/useritems/MultithreadingTutorial.asp
|
|
|
|
|
|
|
The best place to start is here[^].
The article will help you avoiding common pitfalls when starting with multithreading.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
One very important thing you should realize is that it is HARD to write robust, reliable, multithreaded code, and you can't toss off a one-afternoon example and expect it is going to be right. Master the basics first.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
When does vtable create? Run time or compile time.
Plz reply in descreptive way.
|
|
|
|