Hi, You can return a Recordset as an IDispatch pointer like this: STDMETHODIMP CMyClass::GetAllRecords(BSTR bstrSearchKey, IDispatch **output) { .... .... *output = (IDispatch*) pRecordset.Detach(); //Return recordset as IDispatch } Regards, ShadiK Shadi Al-Kahwaji
Shadi Al Kahwaji
Posts
-
Problem in passing recordset from server to client -
QueryInterface( ..., void** ppv)Hi, Let us start from the begining of the C/C++ language without COM. In the C/C++ language, whenever you have a class which contains at least ONE Virtual Function/Pure Function, a virtual table will be created at run time for this class which contains a list of the virtual functions in that class, and a Hidden pointer which called _vPtr is returned, this pointer points to the first entry in the virtual table. Let us back to the COM world, QueryInterface is a method in the IUnknown interface, and IUknown interface is accessing the functionality of the component through virtual table. The interface which returned from the QueryInterface is NOT poiting to the virtual table directly, it points to the hidden pointer _vPtr which points to the virtual table. For this reason we have pointer to pointer. ;) Regards, ShadiK. Shadi Al-Kahwaji
-
Automation ErrorHi, Use Form_QueryUnload instead of Form_Unload, this might help, becuase Form_QueryUnload called before the client exists, but Form_Unload is called when the application is already being unloaded. By the way, you can stop existing the client using Form_QueryUnload event using Cancel argument. ShadiK. Shadi Al-Kahwaji
-
Learning COMTo learn what is the difference between these terms, following are some suggested books: "Atl Developers Guide" "The COM and COM+ Programming Primer" "Mastering COM" Regards, ShadiK. Shadi Al-Kahwaji
-
remote operationHi, Yes, COM is the answer. You can use Distributed COM (DCOM), or if you are using Windows2000 you can implement COM+ for this purpose. How you do it needs a lot of training on DCOM or COM+, I recommend the second one, which is COM+, if you have Windows2000 OS. To do this, take one of the good books like "Mastering DCOM", or "The COM and COM+ Programming Primer" and start from there. Regards, ShadiK.:) Shadi Al-Kahwaji
-
Basic ruleCreate another two interfaces IMyInterfaceEx, IDualMyInterfaceEx which will expose the new fuctionality that you want to develop. IMyInterfaceEx implemenattion might be located on the same class which implements IMyInterface interface. And IDualMyInterfaceEx implemenattion might be located on the same class which implements IDualMyInterface interface. Regards, ShadiK. Shadi Al-Kahwaji
-
Basic ruleThe most important thing that you don't change the current interfaces, in this way you have many options: 1. If your old interface name is IMyInterface, you might create a new one called IMyInterfaceEx which include the new functionality (within the same COM object) that you need to distribute. (This might be applicable if you have small added features) 2. You might create totaly new COM object on the same component (.DLL) which provide the new functionality plus the new interfaces, this new COM object can use the old COM object functionality in two ways, either by Containment or Aggregation, so the new clients for your component will deal with one COM object to access new and old functionality. 3. You might create totaly new COM component (.DLL) if you are providing very huage change to the old COM component. You have to read more about Containment and Aggregation, these are advanced topics in COM technology. Regards, ShadiK. Shadi Al-Kahwaji
-
Basic ruleHi, There are two ways to access a COM interface, accessing using virtual table (IUknown interface), and accessing using Dispinterface (IDispatch interface). If you are using the first approach, the fact that the interface is imutable is true, and you will have trouble in accessing changed interfaces. But if you are using the other approach, you are safe, becuase always you are accessing the same interface (IDispatch) which direct your call to the required interface. MS Office tools are using Automation (IDispatch interface), so they don't have problems in changing interfaces' methods. Regards, ShadiK. Shadi Al-Kahwaji
-
Making things pretty by returning BSTR's (ATLCOM)Hi, Actually you can use any data type "Automation Data Types are recomended" to be a return type of any interface's method. But, it's just a recommendation that you use the HRESULT (STDMETHOD macro) as a return type, this return type will give the COM Runtime Environment the ability to return error codes when your component cannot be accessed for any reason. If you don't provide HRESULT as a return type, the COM Runtime Environment cannot return error codes for you. "If You Know That Your Component Will Live With Its Client On The Same Machine, You Can Ignore HRESULT" Regards, ShadiK.
-
Inconsistent registrationTry to move the ATL.DLL with you. Shadi Al-Kahwaji
-
Where I have to call CoUnInitialize function if I have COM interfaces in (MFC) application main class?Hi, If you are using Document/View Architecture, you can put your smart pointers as member variavles in the Document class. At that time you can call CoUnitialize() either in the Main App Destructor or in App ExitInsnance :). ShadiK Shadi Al-Kahwaji
-
Passing a COM interface to an out of process COM objectHi, If you cannot send the Interface becuase you don't find a data type to send it, then there is no problem. If you want to send IMyObject interface to IMyOtherObject interface, you have to define method to do this in IMyOtherObject like this: STDMETHOD(SetIMyObjectInterface)(IMyObject *pMyObject); The problem here that you might compile this using the .h and .c of the IMyObject, but you will face a problem inside the .IDL file, which is IMyObject is undeclared. To solve this problem, move IMyOtherObject section in the IDL to the type library body: library MYLIBLib { .... //Don't forget to import IMyObject type library here to define the IMyObject Interface interface IMyOtherObject : IDispatch { SetIMyObjectInterface(IMyObject *pMyObject); } .... } I guess this would help you to pass an com interface to another com component. If this does not answer your question, please, re-phrase your question. Regards, ShadiK. Shadi Al-Kahwaji
-
How to add new icons to the existing ms-word applicationHi, I guess what you meant by icon is an Add-In to the MS Word "Added Toolbar with icons". Ok, if this your question, then you can use the VB to create an Add-In toolbar which can be deployed and installed later on to be part of MS Word Add-Ins. You might need to try this with Visual Basic | New Project | Add-In. Regards, ShadiK. Shadi Al-Kahwaji
-
DCOM and ConnectionPointHi, DCOM is a Client calling a component on another computer called Server. When we talk about Events, the roles should be changed, the client will be the server and the server will be the client(Security wise). Goto this article, it might help you in this problem. http://www.codeproject.com/useritems/dcomcnfg.asp Don't forget that while configuring the client and the server, you have to give the server the required security privileges to call back the client. Regards, ShadiK. Shadi Al-Kahwaji
-
DCOM access deniedThe article has been posted: http://www.codeproject.com/useritems/dcomcnfg.asp Enjoy it, ShadiK. Shadi Al-Kahwaji.
-
Connection QuestionHi, I do know, you need the following: HW 1. Eithernet card on the two PCs 2. Cross Cable ( make sure that what you have is a cross cable) SW 1. Create a new LAN Connection on the first PC, and give it a dummy IP address, for example 10.10.0.1. 2. Create a new LAN Connection on the second PC, and give it a dummy IP address, this time you have to use the same presvious IP except the last number, for example 10.10.0.2. 3. Add the same user name and password on both PCs. 4. Share a folder on the PC that you want to access. Note: You have to restart both PCs after you change the IP addresses, and make sure that you don't login to any domain, you just login to the Local Machine. Enjoy :), ShadiK. Shadi Al-Kahwaji
-
Creating a new thread from within an MTAHi, There are two things (as I saw from what you have said) that you have to care of: 1- Once you have created a new thread (withing an MTA or STA), this new thread does not know anything about COM Runtime Environment, this means that you have to call CoInitialize(0) or CoInitializeEx(0, ..). 2- Also this new thread cannot access your Vector, you have to pass this vector to the new thread. This is what I can say about your problem :) Enjoy, ShadiK. Shadi Al-Kahwaji
-
About Com:I need help with the following code(simplified)?Hi, The thing that you didn't get about COM technology is that "you will not deal with classes any more, what you have to care about is interfaces". Here you are trying to create an instance of Try class, which is wrong in COM world. You have to ask the component for a certain interface, and the component itself will create the class instance for you, and it will cast it to the required interface. To access your component you have to make a call like this one: { IX *pX; //See, you are defining the interface instead of the class HRESULT hr = CoCreateinstance(CLSID_Try, NULL, CLSCTX_SERVER, IID_IX,(void**) &pX); pX->fx(); pX->Release(); } Regards, ShadiK. Shadi Al-Kahwaji
-
Cannot instantiate abstract class due to following membersThank you sir. And I would like to thank everybody tried to help me. The problem is that I was trying to use the COM component as a smart pointers, but there were not.:laugh: Thank you all again. Shadi Al-Kahwaji
-
Cannot instantiate abstract class due to following membersHi, First thank you for your reply. Actually I'm using a ready made component which I don't know anything about how does it implemented, but I have the component.h and component_i.c files, and I'm linking to the component using these two files and the ofcourse the .DLL itself. No #import, no smart pointers, just CoCreateInstance which directly creates the required interfaces, and on those CoCreateInstance statement I have this error. Regards, ShadiK. Shadi Al-Kahwaji