C++: Find Installation Directory of MS PowerPoint Viewer - c++

I would like to call MS PowerPoint Viewer executable(PPTVIEW.exe) from within my C++ application.
I do not wish to ask the user, where MS PowerPoint viewer is installed. I believe, it is not professional and relies on user making appropriate input. Instead, I would like to be able to identify the location of the installation directory on my own.
For example, the default location of MS PowerPoint Viewer 2007 is the following:
c:\program files\microsoft office\office12\PPTVIEW.exe
This of course does not have to be always true, especially different versions (2003, 2007, 2010) have have different locations.
Would you advise, please, where to get the correct path, and even better, to be able to identify, if MS PowerPoint viewer is not installed at all?
There must be something in the registry, but which key is the correct one?
I use:
Non Managed C++
Needs to be compatible with WinXP
Should be compatible with bot 32 and 64 bit OS
Should be able to identify location of Powerpoint Viewer of all the versions after 2003(including.)
Thank you.

The best solution so far i found is searching for the appropriate path in registry by reading the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\pptview.exe
The key above gives me location to where PowerPoint Viewer is installed. However, I have no clue whether this key is present in every workstation where PowerPoint Viewer is installed.

If you rephrase the question as "I would like to display a powerpoint in slideshow mode from within my C++ application." then it would be easy to achive this by querying the registered file handler and using the applicable COM object.
The following registry key will be present if there is a registered extension handler:
HKEY_CLASSES_ROOT\.pptx\

Related

How to read .scd data files with in a mfc application

I just purchased and installed a application from 3 Cds using registration key in pendrive. After installation, I just got a MFC Application (.exe). When i viewed the files, I found a data folder inside which I found many .scd files. The data is accessible within the application.
Now I would like to extract that scd files and need those data alone
separately.
I tried with FileViewPro, Scribus and many exe reader Software, but not successful.
Please someone help me to read the .scd files to extract the data from it.
Thanks in Advance,
First of all, please clarify what is the MFC application you are referring to? Was it installed? How do you know that it is MFC app?
Secondly, by giving just a file extension you do not provide enough information about a file. it could be MD scheduler, MS system management, TurboTax and many more.
The only way to do what you need is to find an application that does that or learn about a file format from documentation and write your own application.
It may be impossible if the file is proprietary format and there is no documentation released.

How can I find out version of MSWord on computer?

Can anybody help, please. How can I find out version of msword installed on computer? If there is few versions of it, find out that version which open '.doc' by default. Can anybody suggest some C++ functions or algorithm for this task? Sorry for bad english :( Thank you for help.
you can read the registry entry from the path.
for.....
Office 2003 = 11
Office 2007 = 12
Office 2010 = 14
HKLM\Software\Microsoft\Office\12.0\Word\Registration{-------------}\AccessNameVersion
HKLM\Software\Microsoft\Office\12.0\Word\Registration{-------------}\ExcelNameVersion
HKLM\Software\Microsoft\Office\12.0\Word\Registration{-------------}\OutlookNameVersion
HKLM\Software\Microsoft\Office\12.0\Word\Registration{-------------}\PowerPointNameVersion
If I want to know what version of Word, I look at the registry key HKEY_CLASSES_ROOT\Word.Application\CurVer
It will give you a ProgId like: "Word.Application.14", "Word.Application.12", or "Word.Application.11" for Office 2010, 2007, and 2003 respectively. The part to the right of the last "." gives the version. If you look at "Word.Document", it won't always give the correct answer because there are feature packs that can be installed that will allow an older version of Word to read a new version of Word document. These feature packs update some registry settings for Word.Document, but they leave Word.Application alone.
Please don't go rummaging through the registry when there are APIs available. Using the appropriate APIs will help make sure your test works for all versions of Windows and Word.
To find out which executable is registered to handle a certain file type (like .doc), use AssocQueryString. Once you have the path to the executable, you can check its version number using GetFileVersionInfo and VerQueryValue.
If you just want to find out which versions are installed (regardless of which application is associated with .doc), you can probably query Windows Installer. Check out MsiEnumProductsEx and MsiGetProductInfo.
There's probably also a way to query for this stuff using WMI.

How to write a shell extension in C++?

This seemed like a common question but after doing some searching, I wasn't really able to find my answers. There is an article on this here:
http://www.codeproject.com/KB/shell/shellextguide1.aspx
But it's for a very old version of Visual Studio. I'm using VS 2008, so the instructions and interfaces don't seem to match what I'm seeing.
I want to create a simple shell extension using C++ that creates a context menu for files with extension .GZ. When right clicking on these files, I should be able to click my context menu item and have a callback in code to do some sort of operation on that file.
Other context menu items would do things like spawn modless dialogs to accept user input before executing some action.
From what I've seen, ATL is used for this but I have never used ATL, so all of the object types and interfaces are very confusing to me. It wouldn't be so bad if I had a proper tutorial or documentation to read.
Can anyone help me out? Isn't there some sort of tutorial out there that isn't 10 years old?
I can't tell you exactly how to write a shell extension, but I will provide a number of tips. Writing a Shell Extension offers some significant advantages over the much simpler “registry-only” method:
With a Shell Extension, you can dynamically create a context menu item (or submenu) that is more relevant to the selected file(s). For example, if you are writing a Shell Extension for zip files, it is possible to create a submenu within the context menu that shows the entire contents of the zip.
You can handle multiple files simultaneously, which may be more beneficial not just for performance purposes but also so that you can work out what to do based on the selection as a whole rather than just for each file.
Some of the downfalls to Shell Extensions are:
Substantially increased complexity. Be prepared to spend a lot of effort on this to get it working. Have a home-espresso machine installed next to your computer and/or hire someone to make you coffee.
Substantially increased difficulty in debugging. Ditto about coffee.
It's difficult to write a Shell Extension because they can be very hard to debug.
Shell Extensions are loaded by the explorer.exe process, and without specific configuration of Explorer, you need to force-quit the explorer.exe process so that you can install a newer version of your Shell Extension. There is a way to get Explorer to unload DLLs that it is no longer using, but you should only do this on a development machine and not on a deployment target:
In RegEdit, browse to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer
Add a new DWORD key called “AlwaysUnloadDLL” and set its value to 1.
Restart explorer.
This works most of the time, but there may still be times where you need to close Explorer because the Shell Extension was not unloaded.
Keep in mind that your Shell Extension may be loaded by other applications, for example, if you right-click on a file with an applications “open file” dialog, then your Shell Extension will be loaded into that application, and not Explorer.
If your Shell Extension causes a runtime error, quite often the result will simply be that your context menu item does not show, very rarely will you be told that your Shell Extension failed to load or that it caused a runtime error.
Configuration can be hard, even with an installation, registry data needs to be created in several places, and depending where you want your context menu to show, the places in the registry may differ between different versions of Windows.
What you'll need to do:
Visual Studio offers some shortcuts to creating Shell Extensions, but basically you'll need to create a COM DLL. A Shell Extension for context menu items must implement both the IContextMenu interface and the IShellExtInit interface.
In the IShellExtInit::Initialize() method, you can obtain the selected files from the IDataObject parameter. From memory, the data is in “Drag-n-Drop” format, so you need to get an HDROP handle from the IDataObject and query the files from there (this is from memory, it may actually be different than as I described here, so proceed with caution).
Once your DLL is ready to be “installed”, you must copy it somewhere, and then run regsvr32 to make sure it is registered.
Follow this guide to know where to put registry keys.
There may be issues with 64-bit Windows, if you build a 32-bit DLL it may not load in 64-bit Explorer… so keep this in mind if you are having trouble with 64-bit Windows.
Your DLL will actually have two GUIDs associated with it. I can't remember exactly how it works, but one GUID refers to the DLL itself and the other refers to the actual Shell Extension. Make sure you use the GUID of the actual Shell Extension when creating keys in the registry where a GUID is required.
All things considered… (tl;dr)
Weigh up the costs of whether a Shell Extension is worth it. If you want to create menu items dynamically based on the selected files, then a Shell Extension may be the only way. If you want to handle all files simultaneously then you'll probably need a Shell Extension as well.
An alternative to the context menu method, could be to have a drag-n-drop target on the user's desktop or something. Explore other ways that you could have the user submit your files to your application, because a Shell Extension is often far more effort than it is worth. I found this out the hard way and I think everyone else has too.

MS Word/ ODF Automation in Qt

How can I perform automation of MS Word documents (.doc) or ODF documents (.odt) in Qt 4.5? I know using the QAxWidget, QAxObject.
I have data (QString) and few images as well. I have to add them into the document. I googled but I couldn't find any commands for MS- Word/ ODF. But I want the specific commands that should be passed in QAxObject::dynamicCall() function to perform my operations.
For e.g in MS Excel we have to use something like,
excel.querySubObject("ActiveWorkBook");
which will return the object of the Active workbook of the Excel document.
What are all the commands that are available for the generation of MS-Word or ODF (odt) documents? I am using Windows XP. Any links, examples are welcome..
Take a look at http://doc.trolltech.com/qq/qq27-odfwriter.html, Qt provides functionality to create OpenDocument Format (ODF) files.
The ActiveX commands related to the MS Word can be obtained by the VBAWD10.chm that is being installed along with MS - Word.
The details of the ActiveX help documents available can be obtained here.
The toughest part is to conform those in such a way that it can accessed through the ActiveQt Module.
I provided a similar solution to my question here
Hope it helps for those who are all looking similar solutions..

Algorithm to determine vista/windows 7 OS edition from product key

We have to automatically create the XML file for an unattended vista/windows 7 installation in which we do write the product key (MAK type). Unfortunately the windows image contains multiple editions (home, home premium, professional, ultimate) so we need to decide which version we should use and write that info to the XML as well. And we would love beeing able to decide dynamically which edition to use.
Is there any public algorithm/way to determine the OS edition from the product key like windows setup does? Preferrably in C/C++.
EDIT:
The question is not to determine which editions a certain images supports - this can be done simply by looking at the catalog files sources\install_*.clg
EDIT2:
I found some (strange) tools like Microsoft PIDX Check and Windows 7 Product Key Checker. These use the same pidgenx.dll. pkeyconfig.xrm-msof as the windows system itself. It can be used to determine, among others:
The edition of the Windows.
The features to unlock and activate.
The distribution channel of the license.
The license type.
Ways to activate the operating system.
Unique identifier to determine if activation should be accepted.
But the evaluation of a key takes awfully long.
They probably don't want anyone to know the format to make it harder for the keygen writers.
Some ISO's have a ei.cfg file, you could check there