0

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.

Pete Kirkham
  • 48,893
  • 5
  • 92
  • 171
Ubalo
  • 749
  • 3
  • 10
  • 17

2 Answers2

1

Try Version method from Application object.

bayda
  • 13,365
  • 8
  • 39
  • 48
  • 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 Mar 05 '09 at 19:44
  • Why you work dirrectly with IDispatch interfaces? You can generate ATL wrappers. – bayda Mar 05 '09 at 20:28
  • 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 Mar 05 '09 at 22:06
  • 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. – bayda Mar 05 '09 at 23:27
  • 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 Mar 06 '09 at 14:46
  • 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. – bayda Mar 06 '09 at 17:43
  • [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. – bayda Mar 06 '09 at 17:44
0

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
  • 749
  • 3
  • 10
  • 17