Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

LPUNKNOWN Get_NewEnum()

Posted on 2003-03-25
5
Medium Priority
?
829 Views
Last Modified: 2008-03-10
Hi

I want to get a enumeration for a excel range using automation in MFC.
I think I need to use

LPUNKNOWN Get_NewEnum()

only I can't find any examples on how you would then use this
LPUNKNOWN.

Anyone had the pleasure!
0
Comment
Question by:mjwilliamson
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Salte
ID: 8205618
LPUNKNOWN is a COM interface thingy.

It is the basic interface that all COM interfaces inherits from and expands.

The LPUNKNOWN have only 1 function of interest:

QueryInterface()

You pass it an argument identifying the interface you want to use (The particular interface depends on what the object in Excel you want to access is, for an Excel range you pass the interface GUID value for excel ranges :-))

If the specified object has the interface you query about it will return a pointer to a new object type which isn't LPUNKNOWN but is a pointer to the object type you want to get. That object type will then have methods that are specific to that object type and defined in a C++ class wrapper for that COM object.

If the object do not support the interface you query about it will return a NULL pointer.

The LPUNKNOWN interface has - as far as I know - only two additional methods one to add a reference to the object and one to delete a reference to the object.

Hope this helps.

Alf
0
 

Author Comment

by:mjwilliamson
ID: 8205792
thanks

do you know of any good examples of using
QueryInterface, I think I need and IEnumVARIANT pointer

0
 
LVL 12

Accepted Solution

by:
Salte earned 200 total points
ID: 8208919
Well, you can always check out any COM library - for example DirectX.

I would assume you can find example code usign QueryInterface in those. The main important thing is that you need to know the GUID value of the interface you're interested in (and that presumably this pointer is a pointer to).

One way to find out this is of course to search through the relevant include files.

In C++ you typically use a class interface to work on interfaces and so there's a include file and the same include file typically also define a #define or const value for the GUID to use as argument to QueryInterface.

So you will then typically do something like this:

LPUNKNOWN uptr;
foo * fptr = uptr -> QueryInterface( FOO_GUID );

Not sure if QueryInterface take more arguments than the GUID parameter, you can see the prototype of the function (QueryInterface) in the include file where the IUnknown interface is defined.

In your include file where the class 'foo' is defined you will also typically find the GUID value for Ifoo (the interface for foo).

A description of several COM interfaces and their usage can be found in Win32 documentation. Search for names like IUnknown, IMoniker, IStorage etc etc (all interfaces start with I). Also beware that in .NET they also have an interface type and those interfaces also start with 'I' but are otherwise unrelated to COM interfaces and in particualr there's no IUnknown in .NET). There may be a manner to translate a COM interface to a .NET interface and as such the IUnknown would be available but that is a different issue).

Alf
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9558813
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to Salte

Please leave any comments here within the next seven days. Experts: Silence
means you don't care.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question