?
Solved

LPUNKNOWN Get_NewEnum()

Posted on 2003-03-25
5
Medium Priority
?
799 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

762 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