views:

198

answers:

2

Hi Guys, I am using C++ unmanaged with Power Point (2003 and 2007).

How do I get the running version of Power Point (2003 or 2007) with IDispatch?

Thanks, any help would be awesome.

+1  A: 

Try Version method from Application object.

bb
I am sorry I am kind of newbie in C++ unmanaged. I am using IDispatch I think I just need to make an "invoke" to get the version but I don't know which one is it.Is Application Object unmanaged code or not? because I can't do it if it is managed.Thanks.
Ubalo
Why you work dirrectly with IDispatch interfaces?You can generate ATL wrappers.
bb
I was using IDispatch because I have IDispatch interface implemented in my project.But you're right I don't have to use it directly.Can you give some sample that show me how to use ATL Wrapper and Application.vesion.thanks again.
Ubalo
You can use #import directive to generate *.tlh header file from powerpoint class library and then use generated objects.But I don't know, how you get this IDispatch interface for provide short example.
bb
I have an instance of CComDispatchDriver then I call GetPropertyByName("Name", result) and I got"Microsoft PowerPoint" but I need the version not the application name.I think I just need use the invoke with the right property, I mean disp.invoke("pptversion",,) something like that.
Ubalo
ok.In general IDispatch interface allow call function/properties by name. It is very important for script or other high level language.Use GetIDsOfNames for get id of this function "Version".Use id for call this method.
bb
[id(0x000007de), propget, helpcontext(0x0007a8ff)] HRESULT Version([out, retval] BSTR* Version);Method description.Try do this, but if you will have some problems, I will try to prive full example.
bb
A: 

I am sorry I was working in another project. I found a simple way to get the version using CComDispatchDriver instance.

CComVariant ccVersion;

//disp is CComDispatchDrive type

disp.GetPropertyByName("Version", ccVersion);

doing that I get ccVersion = "11.0" for 2003 and "12.0" for 2007.

To cast it to string I used CString class:

CString version;

version = CString (V_BSTR(&ccVersion));

Thanks for your help, I hope this can be useful for someone else

Ubalo