|
Hi,
I am new to COM. I just started learning the COM. Its interesting. I am learning from "Inside COM" book. I just want to be a COM programmer. So do i need to learn all COM stuffs. I read till ClassFactory and little abt Containment and Aggregation.
Do I need to learn all the other cocepts to be a good programmer like IDispath,Monikers(its not given in this book) and other threading concepts and even Aggregation in detail.
could anyone guide me on this regard?
Also I want to learn ATL too. I have done projects in ATL too. But want to be good prgmer in that too.
|
|
|
|
|
urssmiling wrote:
Do I need to learn all the other cocepts to be a good programmer like IDispath,Monikers(its not given in this book) and other threading concepts and even Aggregation in detail.
IDispatch - yes, at least if you want to interoperate with braindead languages such as VBScript, or want to use automation functionality exposed by many applications.
Monikers - it doesn't hurt. Especially not if you are to create your own monikers.
Threading concepts - absolutely.
urssmiling wrote:
could anyone guide me on this regard?
This book is highly recommended[^]
urssmiling wrote:
Also I want to learn ATL too. I have done projects in ATL too. But want to be good prgmer in that too.
You should most definately learn ATL as well, if you are going to do serious COM programming. You will become sick of all the boiler plate code otherwise.
Good music: In my rosary[^]
|
|
|
|
|
Thanks for ur reply. I have some more clarifications. Could you be more clear about IMonikers about whehter its really a needed one. Also about aggregation and containment.
Also could u specify me about learning ATL. I have Inside ATL book. Do I need to learn about all the ATL object and so on. could you guide me more on this.
Thanks.
|
|
|
|
|
Hi,
I am using ADSI api and want to extract Net BIOS name from DNS using C++.
I got following sample from MSDN. But this sample is not compiling. I got following compilation error:
error C2065: 'IADsNameTranslate' : undeclared identifier
I have Included "activeds.h" and "Iads.h" in the header files but still I am not able to get the desired result.
If someone has worked on it then please sent me the working code.
#include "activeds.h"
#include "Iads.h"
int wmain( int argc, wchar_t *argv[] )
{
IADsNameTranslate *pNto;
HRESULT hr;
hr = CoCreateInstance(CLSID_NameTranslate,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADsNameTranslate,
(void**)&pNto);
if(FAILED(hr)) { exit 1;}
hr = pNto->InitEx(ADS_NAME_INITTYPE_SERVER,
CComBSTR("aDsServer"),
CComBSTR("aUser"),
CComBSTR("userDomain"),
CComBSTR("passwd"));
if (FAILED(hr)) { exit 1;}
hr =pNto->Set(ADS_NAME_TYPE_1779,
CComBSTR("cn=jeffsmith,cn=users,dc=Fabrikam,dc=com"));
if(FAILED(hr)) {exit 1;}
BSTR bstr;
hr = pNto->Get(ADS_NAME_TYPE_NT4, &bstr);
printf("Translation: %S\n", bstr);
SysFreeString(bstr);
pNto->Release();
}
Thanks and Regards
Ankur
|
|
|
|
|
Hello Friends,
I want to learn COM Programming. So, Please suggest me the path to be taken for becoming a Advance COM Programmer.
From Basic to Advance to Expert??
Neelesh K J Jain.
|
|
|
|
|
Hi Neelesh ,
TO start with COM the best resources are books and online MSDN.
Here are some good books.
Essential COM
by-Don Box
Inside COM
by-Dale Rogerson
Have fun !
Cheers,
Vishal
|
|
|
|
|
hi
i m new to the field of activex and i want to know that are activeX (internet activex) made in the vc or vb are capable of self registering. or had to something extra to
register them. particularly the (internet activex) controll. if not that what functions will be used to register them.
i had made the (internet activex) that play the movie on the page i want to know that when user will visit my page then ocx will be selfdownloaded
and selfrejisted to that client pc. or what will happen.
ddd
|
|
|
|
|
tasleem143 wrote:
activeX (internet activex) made in the vc or vb are capable of self registering. or had to something extra to
register them.
The components are capable of self registering themselves, provided they have the necesary permissions to do so.
The Internet Activex control should be singed by any of the singing authorities otherwise when it tries to register itself then u will get a security warning.
tasleem143 wrote:
what functions will be used to register them
To register an control use "Regsvr32.exe"
tasleem143 wrote:
i want to know that when user will visit my page then ocx will be selfdownloaded
and selfrejisted to that client pc. or what will happen.
For a component to download itself on to the client machine, create a Cabinet (.cab) file for that component along with the .inf file, mentioning that the control has to register itslef once it get downloaded on to the client machine.
place "cab" file in the virtual directory.
|
|
|
|
|
hi
i want to know how to make the (.cab) file for the component along with inf file. and in the codebase attribute of the object tag i should refer to that site where cabfile is placed. and in the cab file ocx will be present.
ddd
|
|
|
|
|
Hi,
Inorder to make the cabinet file u need "Microsoft Cabinet Software Development Kit. you can download it from the following location:
http://support.microsoft.com/default.aspx?scid=KB;en-us;310618&[^]
tasleem143 wrote:
i want to know how to make the (.cab) file for the component along with inf file
The following entries have to be made in the (.inf) file
<br />
[version]<br />
signature="$CHICAGO$"<br />
AdvancedINF=2.0<br />
<br />
[Add.Code]<br />
YourComponent.dll=YourComponent.dll<br />
<br />
[YourComponent.dll]<br />
file-win32-x86=thiscab<br />
clsid={CLSID of the component}<br />
FileVersion=1,0,0,1 <br />
RegisterServer=yes<br />
"YourComponent.dll" is the name of your component
Save the above as file as "YourComponent.inf" file
Run the "cabarc" utitlity as following.
cabarc n CabinetFileName.cab YourComponent.dll YourComponent.inf
it generates a cab file in the current directory.
place the cab file in the virtual directory.
tasleem143 wrote:
the codebase attribute of the object tag i should refer to that site where cabfile is placed.
declare the <object> Tag as following:
<object id="<i">ObjectName height=100 width=100
classid="CLSID:CLSID of the component"
CODEBASE="CabinetFileName.cab#version=1,0,0,1">
Tiru
|
|
|
|
|
hi
thanks for ur help i had downloaded that from site. i had bid of confusion. u said that in making the inf file i should replace the
"YourComponent.dll" with myown component. but my component extension in .ocx not .dll.
2nd u specifie that i should place the cab file in the "virtual directory". i want to know that what is that virtual directory. is that is the
place where mysite in rejistered or mysite folder.
third in the codebase tag suppose mysite is rejisted as yahoo.com and cabfile name is test then i should write this on tag
CODEBASE="http://www.yahoo.com/test.cab#version=1,0,0,1">
if want to check that locally on my computer then i should install the iis and then can check that or without that is possible. and in the
code base tag i should write
CODEBASE="C:\test.cab#version=1,0,0,1">
i had tried to check that locally without installing the" iis" it did not worked
by making the cabfile as u specified and in the cabfile the ocx and inf were presetnt. with procedure u specified.
ddd
|
|
|
|
|
tasleem143 wrote:
"YourComponent.dll" with myown component. but my component extension in .ocx not .dll
yeah u can mention your .ocx file name instead of the .dll file.
tasleem143 wrote:
i want to know that what is that virtual directory
Virtual directory is the folder that u create in your web site. it contains all the web pages.
Regarding the Code base, u just need to mention the name of the cab file and its version.
tasleem143 wrote:
i had tried to check that locally without installing the" iis" it did not worked
by making the cabfile as u specified and in the cabfile the ocx and inf were presetnt. with procedure u specified.
inorder to test it on the local machine u need to install IIS on it and follow the earlier procedure.
|
|
|
|
|
hi
thank for ur useful time. it works properly.
when u had not replied on sundays then i searched the microsft soft site for that purpose then i found and article related to the cab file in which all procedure was explained. i read that and i want that with the cab file all the dll required to run the mfc programs ie mfc42.dll should be also downloded and extracted automatically.
it was explained in that but icannot understand that all dll's (mfc42.dll and other 2) and on inf should be packed in seperate cabfile alongwith the inf file or in same cab file in which ocx is present. it is below i dont know
ddd
|
|
|
|
|
|
Hi All, I have a program which uses the IE engine to display HTML docs in it's window. It uses COM/ATL to interface to IE. Is there a function I can call which would return to my program the highlighted text in the displayed HTML doc? Also, does anyone know of a good reference (maybe a book?) that describes how the interface to the IE engine works? Thanks in advance for any ideas, Melena
|
|
|
|
|
Hi Melena,
So your program has IWebBrowser embeeded inside to render the HTML pages?
To retrieve the highlighted (selected) text you must query for an interface "IHTMLSelectionObject", once you get the interface pointer then check the type of this selection using IHTMLSelectionObject::Type. It could be "Text" or "Object"
Once you get d valid pointer you must create the range for the current selection using "IHTMLTxtRange = IHTMLSelectionObject.createRange" and here is your desire result "IHTMLTxtRange::Text" this would return you the highlighted (selected) text.
Does this helps you ?
Enjoy !
Cheers,
Vishal
|
|
|
|
|
Thanks Vishal, that helps a lot. It looks very similar to getting the selected text from Javascript.
|
|
|
|
|
Hello,
im new to MFC and ActiveX and such
I would like to write a simple opengl activeX control that i can render a cube to, and imbed in a Web page (and the cube spins etc etc), i have seen alot of examples (there is one on this site) but i cannot get them working (xcept through vb)
Are there any samples/basecodes around that i can learn from?
Also, i can create an opengl window with an SDI MFC project; but where does OpenGL anchor to for an activeX application (there is no default window?)
Can someone steer me in the right direction plz
Cheers
Muncher
|
|
|
|
|
I am new to COM. I tried creating the COM objects without using ATL wizards. As the way explained in the article "COM from scrach - part 2".
I try connecting with the server obejct from the client ,by calling the COCreateInstance() or CoGetClassObject() methods, i get the error saying "The specific module could not be found."
I registered the class too. what is this error?? How to rectify it?
|
|
|
|
|
You can try COCreateInstanceEX.
HRESULT CoCreateInstanceEx(
REFCLSID rclsid, //CLSID of the object to be created
IUnknown *punkOuter, //If part of an aggregate, the
// controlling IUnknown
DWORD dwClsCtx, //CLSCTX values
COSERVERINFO *pServerInfo, //Machine on which the object is to
// be instantiated
ULONG cmq, //Number of MULTI_QI structures in
// pResults
MULTI_QI *pResults //Array of MULTI_QI structures
);
|
|
|
|
|
Hi,
I got it right. Its problem with the path of the dll. Dll was not loaded in the path specified in the registry.
Thanks.
|
|
|
|
|
Hi, there. I'm a COM noob, and I was hoping I would be able to get some on something I'm working on..
I've managed to create a prototype IDL and get a simple COM server/client up and running. However, I've been having trouble finding help for what I'm trying to do next - making my IDL file support multiple server implementations.
Looking at the client's perspective, what is the best way to support multiple server implementations of the same IDL on a given system? In other words, I'm considering a situation where my client needs to distinguish between more than one registered "server.dll," while sticking with just one IDL file...
e.g.:
I define an IDL file. I give it to two separate people, who both implement a COM server. I register both resulting DLL files on my system. How can I make my client cope with this situation?
Perhaps I'm thinking about this the wrong way... In any case, suggestions would be much appreciated!
|
|
|
|
|
If your two separate people are both implementing COM servers, which have the same interface as defined in the IDL, then you need to register one or the other DLL and which ever DLL is the last one registered will be used.
If however the two implementations do different things, despite having the same interface, then you need to use two IDL files with different GUIDs. In the client program, when you call CoCreateInstance(), specify the appropriate CLSID.
|
|
|
|
|
Ah, I see. Thanks for clearing that up.
|
|
|
|
|
Hello Vertig0,
My post here is written with due respect to my fellow developers including "Anonymous". However, I do seriously beg to differ with "Anonymous"'s answers to you which, in my sincere and humble opinion, are incorrect.
I'll go through his answers first to set the record straight and then I'll go through the original questions that you posted. Finally, I'll provide some of my own extra inputs. I have also written a set of sample codes to illustrate my points and would be glad to email it to you. My email address will be provided below.
OK, let's go through "Anonymous"'s answers :
Anonymous wrote : "If your two separate people are both implementing COM servers, which have the same interface as defined in the IDL, then you need to register one or the other DLL and which ever DLL is the last one registered will be used."
My comments : This is not correct. Two or more (multiple, in fact) COM objects housed in separate (or even the same) DLL(s) may implement the same interface AND they can ALL be registered on the same machine, live side by side and be used separately or simultaneously by a client application.
Just imagine this, vertig0 : ALL COM objects must implement IUnknown. If what Anonymous said was true, then only one object can be registered and used at one time. What kind of a COM world would we be living in ?
Anonymous wrote : "If however the two implementations do different things, despite having the same interface, then you need to use two IDL files with different GUIDs. In the client program, when you call CoCreateInstance(), specify the appropriate CLSID."
My comments : what else is the purpose of providing two or more implementations of one published interface but to treat them as providing two or more versions of the same expected functionality ? Still, vertig0, the central idea is to maintain ONE interface (with a constant IID) coded in ONE IDL file.
Anonymous wrote : "In the client program, when you call CoCreateInstance(), specify the appropriate CLSID.".
My comments : this is exactly how a client would get hold of a specific interface implemented by one particular COM object. However, the IID of the interface -must- remain the same. It is the CLSID that is different.
OK, vertig0, now onto your questions :
vertig0 wrote : " However, I've been having trouble finding help for what I'm trying to do next - making my IDL file support multiple server implementations."
My comments : my sample codes will show you how to achieve this.
vertig0 wrote : "Looking at the client's perspective, what is the best way to support multiple server implementations of the same IDL on a given system? In other words, I'm considering a situation where my client needs to distinguish between more than one registered "server.dll," while sticking with just one IDL file..."
My comments : The CLSID of the specific COM server (which implements the interface) is what you would use to distingusish between more than one registered "server.dll".
The central point is to enable your client code to create instances (via CoCreateInstance(), etc) of the various COM objects that implement your interface. You differentiate between the versions of the interface implementation by the CLSID. My sample codes will illustrate this.
Finally :
vertig0 wrote : "Perhaps I'm thinking about this the wrong way... In any case, suggestions would be much appreciated!"
My comments : you are thinking about this the right way, vertig0. It is most intuitive and is very much in line with Object-Oriented development principles.
Send an email to me, vertig0, and I'll email you the sample codes. Here is my email address :
bio_lim_2004@yahoo.com
Again, my assurance of full respect to Anonymous.
Best Regards,
Bio.
|
|
|
|
|