|
VariantChangeType - So simple you would over look it
|
|
|
|
|
I'm starting with ATL, I've written several 'test' COMs but now I face the following problems. I want to create a COM object (class) that will be used from remote machines (DCOM). The COM will be an out of process server. Let's say my object is named MyObj and the C++ class CMyObj.
1. How do I get the count of open objects?
Should I use a static member variable and increase/descrease it everytime an object is constructed/destructed? If yes (or even if no), where should I put the code for this? In the constructor/destructor of CMyObj or in the FinalConstruct-FinalRelease?
2. How to I prevent a client to create an object of that class based on runtime conditions? For example, in order to disallow more than 10 objects at the same time. Should I throw in the constructor? throw what?
3. What's the best way to destroy my object, even if the client hasn't done so yet? 'delete this;'? For example, if the client passes an invalid parameter on one method, I would like to be able to destroy the object (at least on the srv-side).
4. What happens when (in DCOM) the network layer fails? Is the object on the server and/or client side automatically destroyed? If not, can I catch an event or something (I'm more concerned on the server side) when that happens and ... do what?
5. How can I pass my object (and all the data it holds) through the network? Are there any functions I would have to override (something like ReadFromStream or WriteToStream, I don't know)?
6. What's the best way to inform the client of critical failures of a method he just called? Should all these methods have an [out,retval] long *result? Should I use the IErrorSomething that the ATL object wizard allows you to support? Can I return anything else than S_OK, or is HRESULT used internally from the COM/DCOM layer?
Any help would be greatly appreciated.
Moreover, the one who answers all of my questions, will win a free copy of my free Tetris game;)
|
|
|
|
|
I can't pass up the chance for a free tetris game.
1. Thats one way to do it. Put it where ever you would like. In the ctor you can catch it before creating the object. In the FinalConstruct you can be sure the object was successfully created.
2. Don't throw just return an E_FAIL or some HRESULT of your own creation, using the MAKE_HRESULT macro. You could then set the IErrorInfo for more detailed explaination of the failure.
3. Release the object.
4. Don't know (Damn, there goes the Tetris)
5. Pass an interface pointer. You don't want to pass a 500mb object instance down the wire.
6. You could have a retval or use HRESULTs and IErrorInfo, refer to 2.
|
|
|
|
|
Thanks a lot.
I decided I'll give you a copy of Tetris, since you're so excited about it.
Get it from users.otenet.gr/~gtoub/
Btw, it's for DOS (but works on 3.1,95,98,2000 *maybe, it worked for me*).
|
|
|
|
|
When running my program on a 98 box, everything seems to go through smoothly. When running on a Win2000 box, it crashes. I have isolated a commonality between this issue and few other issues in that somewhere along the line it has to display the MSFLEXGRID OCX control. Does there happen to be an extra step in getting the MSFLEXGRID control registered for Win2000? Or perhaps it is registered and it's just something else. It seems 98 recognizes the control.
Thanks!
Chris
Customer: "It seems you have bugs that are inconsistent!"
Support: "We have a patch that makes them consistent."
|
|
|
|
|
all
Is there any way to catch com event from console app?? a short sample code will be great.
psksvp
|
|
|
|
|
Hi
I have serialized my data into an xml file.Now I want to implement IStorage methods and expose those methods to encapsulate my xml code.
To achieve this what I have to do?I want to pass IXMLDOMDocument pointer
to IStorage methods.Can I do this?or how to do?
Thanks in advance
Pathi
bhikshapathi_g@semanticspace.com
|
|
|
|
|
Why can't you use the IXMLDOMDocument methods load and save?
|
|
|
|
|
I was trying to create a WTL based dialog app that had a DateTimePicker on it but can't seem to get it working. When I try to create the contol all I get in return is NULL.
CDateTimePickerCtrl Date;
HWND hWnd = Date.Create(...)
if(NULL == hWnd)
//What happened?
|
|
|
|
|
Did you call InitCommonControls() ?
--Mike--
http://home.inreach.com/mdunn/
"Holding the away team at bay with a non-functioning phaser was an act of unmitigated gall. I admire gall."
-- Lt. Cmdr. Worf
|
|
|
|
|
Its always the simple things. Thanks.
|
|
|
|
|
How do i add an interface with CString as its parameter
i.e. HESULT Calc(CString)
Since CString is a mfc class ,the compiler cannot recognise CString defined in the .IDL file?
please help its urgent.
|
|
|
|
|
To use string use BSTR.
HRESULT Calc(BSTR strParam).
HTH
Jignesh
|
|
|
|
|
Jignesh is correct, the correct way to pass strings in COM is the hated BSTR.
There is a good article by Joseph Newcomer on CString that covers CString to BSTR to CString conversions very well. It is at:
http://www.pgh.net/~newcomer/cstring.htm#CString to BSTR
Jim
|
|
|
|
|
Why reinvent the wheel.
USES_CONVERSION;
A2OLE, OLE2A, A2BSTR, BSTR2A, etc...
|
|
|
|
|
I had an eariler issue dealing with DAO access causing a program to crash. Apparently installing MDAC and DAOSDK solves that issue. (thanks to those who helped on this matter ) However now I am noticing a problem with COM, more specifically MSFLEXGRID. I have a MSFLEXGRID control in the program and I am noticing that within the main window it is not showing up and within a dialog box it is causing the program to crash long before it paints.
Are there more installs that need to happen?
I noticed this all worked when I had VC++ installed.
Thanks!
Chris
"Why are we hiding from the police, Daddy?"
"We use VI, son. They use Emacs."
|
|
|
|
|
how can i pass a map as a in parameter or out parameter ?
I need [out,retval] mymap and
[in] mymap something like this
how can i achieve this ?
parag
|
|
|
|
|
YOu can't. At least not without some serious hacking. C++ specific entities such as maps, lists, etc. were never made to be passed across COM boundaries. You cannot define them sufficiently for MIDL to handle them.
|
|
|
|
|
I would like to talk to Programmers/Trainers that would be interested in teaching COM+ courses for Absolute Solutions, Inc. Absolute Solutions, Inc. is a computer training and consulting firm that is located in Bloomingdale, IL. If someone is interested, please, email your resume to mverma@absolutesolutions.com. Also, if you know someone that might be interested, please, pass this information on to them. Thank you.
|
|
|
|
|
Hi Guys,
I have been using ADO to execute queries asynchronisly. I am using adUserServer as Cursor location and adAsyncExecute flag to run the query using Recordset-->Open method.But the problem is if i cancel the query in between i get the following error:
Error No : 3712
Description: Opeartion has been cancelled by the user.
I don't understand why.
And if i use Command object's Execute method to run my query, then the query dosen't seems to run asynchrosnly.
Did anybody worked with ADO async queries?
Any help in this regard would be highly appreciated.
Cheers,
Mukesh
|
|
|
|
|
Hypothetically,
if I wanted to pass pointers to CComPtr classes around, given that the & operator has an override to return the member pointer data, how would I get the address of the actual CComPtr class?
...and if there is an easy way to do this for a CComPtr, is there a general solution for classes that overide the & operator (i.e. some C++ syntax that has eluded me thus far)???
Any help appreciated...
|
|
|
|
|
I have a User control in a dll (that I created in C#). I've already created the type library and registered it as a global assembly. My question is, how do I actually use this control in VB6 or VC6? I've tried simply adding the ActiveX control using the project references in VB6, but it won't accept it (because it is not an ocx). Is there a way to actually reference the dll and add the user control on the fly?
"Desire is not an occupation"
|
|
|
|
|
I don't believe you can use something created with C# in VC6. The component needs the .NET CLR which VC^ knows nothing about.
You can use VC6 code in .NET by using using the managed/unmanaged facilities
|
|
|
|
|
I've recently written a shell extension that extracts the bitmap preview from AutoCAD drawing files and displays them when viewing folders as web pages. Everything works great except for one thing.
The problem is that when the folder is viewed as Thumbnails, the shell shows the same preview image for *all* DWG files in the folder (whichever one was last selected). At first, even refreshing the thumbnails didn't solve the problem so I modified my implementation of IExtractImage::GetLocation to enable shell caching. That only sort of works. The images are still the same but at least you can refresh them to get the correct preview.
Does anyone know what is causing this problem and how I may prevent it from occuring in the first place?
|
|
|
|
|
I'm working on an activex control that will sit in a webpage. I'm looking to add icons to me TreeView and am having trouble getting an ImageList set up.
So far I've done this:
CoCreateInstance(CLSID_ImageList,
NULL,CLSCTX_INPROC_SERVER,IID_IImageList,(void** &m_ImageList);
CoCreateInstance(CLSID_ListImages,
NULL,CLSCTX_INPROC_SERVER,IID_IImages,(void**)&m_Images);
Since I see that an ImageList needs the Image collection put into it, but then the Image Collection needs Images put into it and I have no idea how to set that up.
Anyone have any tips or links?
-Jack Mott
jackm@scalablesoftware.com
|
|
|
|