|
Mayur,
Yes, please post your code. I have never tried what you are talking about.
Thanks,
Royce
|
|
|
|
|
Mayur Mahajan wrote:
A better and safe way other than smart pointers is invoking the COM runtime and obtaining interface explicitly.
How is that safer? Raw interface pointers are almost always the source of memory leaks when dealing with COM. Raw interface pointers are for C programmers only, IMO.
Heck, COM is hard even with smart pointers. Why make it harder by using raw pointers?
--
...Coca Cola, sometimes war...
|
|
|
|
|
I know COM is hard. And pointers in C++ is something people like to stay away But I'm a c++ fan and like to get things done the hard way! Also using smart pointers is something like setting references in VB and too 'unornamented' method to understand the workings of COM. /* And memory is sure to leak out of most progs unless u code with a cool head be it COM or C++ objects */
coding n debugging; two sides of same coin
|
|
|
|
|
Are you an error handling fetishist?
--
...Coca Cola, sometimes war...
|
|
|
|
|
Maybe because I create a lot of errors in code and spend twice the time hunting for it
|
|
|
|
|
RFickling wrote:
Now when I try to use __uuidof() in a VS 7.1 client, it throws an exception "Class not registered" when it clearly is registered.
Uh.. __uuidof doesn't throw anything.
--
...Coca Cola, sometimes war...
|
|
|
|
|
No, but it indirectly invokes CreateInstance() which throws.
|
|
|
|
|
There is nothing wrong in using smart pointers and __uuidof for accessing com object in vc7. it shud work fine. there shud be something else is wrong.
u created the com as a vc7 atl project and what type of .net project was ur client app?
rgds..mil10
|
|
|
|
|
Yes, this project was created using VS 7.1. Using the project wizard, I created an ATL project, Attributed = false, Support MFC = true, Support COM+ = true, and Support Component Registrar = true. Using the Add Class wizard, I then added a ATL Simple Object with defaults. I don't see anything wrong with what I did.
Royce
|
|
|
|
|
thats fine.. what type of project was ur client app? whether it is a Console App(.net), win32 console app or an MFC appwizard exe?
|
|
|
|
|
The client is a MFC App wizard dialog-type application. My code is below.
I use the #import statement:
#import "ComServer.dll"
I define a member variable to hold a pointer to the interface in my dialog's header:
ComServerLib::IMakeKeyPtr m_ptrMakeKey;
This statement fails with a 80040154 error code: "Class not registered"
m_ptrMakeKey = ComServerLib::IMakeKeyPtr(__uuidof(ComServerLib::IMakeKey));
I have used this method of connecting to COM objects for years. I have no clue as to why it is failing. My registry shows the following keys:
The following registry keys show that the required registration has been done. These
keys were copied from the registry immediately after a successful build of the COM server.
The 'MakeKey Class' is registered:
HKEY_CLASSES_ROOT\CLSID\{1BB2A094-1C9E-4B3B-99CF-A92CD5E762A3}
The ComServer 1.0 Type Library is registered:
HKEY_CLASSES_ROOT\TypeLib\{2748E284-3101-4CB7-AF16-C52E02E2A71A}
The IMakeKey Interface is registered:
HKEY_CLASSES_ROOT\Interface\{1B68E9F2-D8F6-42C0-9D12-90255695E6DE}
|
|
|
|
|
Royce Fickling wrote:
uuidof(ComServerLib::IMakeKey);
Dude, you should be using __uuidof(<class name here>) . You are using the interface name, and hence you are trying to create a COM object using an IID. It's the CLSID you want...
--
...Coca Cola, sometimes war...
|
|
|
|
|
Royce Fickling wrote:
uuidof(ComServerLib::IMakeKey);
U asked Royce to use __uuidof(<classname>) instead of IID; Does this return the default interface? By this technique how can I query other interfaces of my COM object?
Fortune favours the naive
|
|
|
|
|
Mayur Mahajan wrote:
Does this return the default interface?
No. In the microsoft compilers, structs and classes can be given compile time attributes. One of these compile time attributes is GUIDs. To interfaces, the IID is set as attribute. So __uuidof(IInterface) is equivalent to IID_IInterface.
Mayur Mahajan wrote:
By this technique how can I query other interfaces of my COM object?
pUnk->QueryInterface(__uuidof(IInterface), (void**)&pInterface);
It's not portable, but hey, who cares? I don't do COM development for anything but windows, and my compiler of choice for the windows platform is the one that comes from Redmond.
--
...Coca Cola, sometimes war...
|
|
|
|
|
An addition to Jörgen Sigvardsson's reply:
chk the .tlh and and the implimentation file .tli for any detailed info.
these files will be there in ur debug folder.
|
|
|
|
|
Hi Royce.. as Jörgen Sigvardsson already posted u shud have used the CoClass name instead of an Interface name in ComServerLib::IMakeKeyPtr(__uuidof(ComServerLib::IMakeKey)); . Here replace IMakeKey with ur coclass name. chk idl for the coclass name.
rgds...mil10
|
|
|
|
|
I've been working on a COM Service project for about 2 months and early in the development process, i had to generate Proxy/Stub dll.
Today, after having a very evolved project, i try to figure out which data type prevents me from using the standard marshalling libraries. I've been browsing thru the net for about 1 hour and a half, trying to find which data type was 'forcing' me to have my own Proxy/Stub dll.
Then, i figure i'll unregister my Proxy/Stub dll and see if i can still acces my COM Service. Well, it works
I guess during the growth of my project i changed whatever required that proxy/stub code and am now fully automation compliant
Just needed to share this as this is not a question, but it sure feels good to know my project is full automation compliant.
|
|
|
|
|
yess boss.. if all the datatypes are automation compliant, then universl marshalor will do tha mrdhl/unmrshl for us..
rgds... mil10..
|
|
|
|
|
Hi,
Iam using dhtml control in my application. Iam having a problem in table selection. For Example: if i put 2 * 3 table and try to select from 2row and 2 column in upwards direction it is selecting 1 row ,3 column also. And merge cells is not activating if the selection is not exact....
Kindly help...
I downloaded the dhtml edit from msdn..
Thanx.
Raj
|
|
|
|
|
I'm trying to figure out what kind of help you need but its not clear in your post.
1) What interface(s) are giving you the problem.
2) Any code sample that we can look at
3) What exactly is your goal, what do you expect your code should be doing
Try to picture yourself as someone trying to help you, what kind of information would you require to help that person.
|
|
|
|
|
Iam using a control(dhtml editor) which was downloaded from msdn.
The problem is in table selection. In a 3 * 3 table if i select from 2 row 2 column to first row ,first column in upwards direction , it selects even the third cell in the first row. I should select 2 rows and 2 column ( try out in frontpage). iam just do the execcommand with ID_TABLE_INSERTTABLE.
How to solve it?
2) How to insert a row or column in a table using IHtmlTable or IHtmlTableRow?
raj
|
|
|
|
|
I am confused with COM, ActiveX and Automation.
Can someone please tell me what exactly is the difference between them.
I know that ActiveX and Automation are COM based technologies. I know what COM is. I wanna know where do ActiveX and Automation differe
Any help is appreciated.
Thanks in advance
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Hello Sohail,
Microsoft is really querky at coining names for their technologies, sometimes creating outright contradictions. Yes, ActiveX and Automation are both COM based technologies.
When COM first came out (mid-90s), ActiveX was the 32-bit version of VBXs (Visual Basic Extensions). ActiveXs also used COM technology and were sometimes know as COM Controls. They are also known as OCXs (for OLE Control Extensions).
ActiveXs, in this context, still exist and are in widespread use. However, the name "ActiveX" itself has been (ab)used in other contexts by none other than Microsoft itself.
Today, ActiveXs can also mean COM Objects. In fact, Visual Basic has a wizard that allows you to create ActiveXs (COM Objects) in VB.
In VC++, you still call a COM Object a COM Object (and not an ActiveX). The VC++ ATL Wizard still refer to these as COM Objects.
So today, by ActiveX, we could mean a COM Control or a COM Object.
The meaning of Automation, on the other hand, has remained intact. Automation was formerly known as OLE Automation. This refers to a COM Object that implements the IDispatch interface. The idea being to allow properties and methods of a COM Object to be late-bound.
Hope the above helps, Sohail.
Best Regards,
Bio.
|
|
|
|
|
Hey Bio,
Thats really helpful.
Lim Bio Liong wrote:
Microsoft is really querky at coining names for their technologies, sometimes creating outright contradictions
I agree what you said
Thanks a lot.
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
modified 21-Apr-21 21:01pm.
|
|
|
|
|
COM is a standard protocol for communicating with objects basically. It does not dictate how you implement your objects (or classes rather). It does dictate the mechanics of their interfaces (the protocol) should work. COM is also a set of universal and well known interfaces. One of those interfaces is IUnknown . I assume by your post that you know about these things.
ActiveX is a set of interfaces which graphical COM objects can implement. These are also known as ActiveX controls. If they do so, they may be used generically by hosts, or containers, which also implement a set of ActiveX interfaces. The control knows about the container's interfaces, and vice versa. This allows the control to communicate with its container to for instance add menu entries in the container. It also allows the container to resize the control. Basically, ActiveX allows control and container to communicate with eachother - a plugin architecture if you will.
Automation is a loose term. Basically all it says is that it exposes some functionaliy which may be exploited by an external party. For instance, it may be an application which can be controlled by another application. Word is an automation enabled application. You can start word, have it open a document, and print it, by issuing commands from your own application, rather than doing so the conventional way (by using the user interface). The requirement for automation is that it should follow the COM standard. It is up to the controlling party to know about the interfaces which the automated application exposes.
--
...Coca Cola, sometimes war...
|
|
|
|