How can I find out version of MSWord on computer? - c++

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.

Related

C++: Find Installation Directory of MS PowerPoint Viewer

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\

How to programmatically get windows search history?

How to get the windows search history and use it in my program? For example I write ".doc" in windows search bar. Now I want in my program to find out from somewhere, that I searched for ".doc" in my system (not web).
I don't know if there's an API for it, but if you do a Windows search for an unlikely string, say "zxcvbnm", then search the registry for it, then on XP you can see it under one of the folders in:
HKEY_CURRENT_USER\Software\Microsoft\Search\ACMru
along with the rest of your recent search strings. I imagine this registry location may change between Windows versions though.
If you're targetting Windows 7 then this MSDN article looks like a good starting point.

Path variable to mso.dll and msoutl.olb

I'm trying to develop a toolbar for Microsoft Outlook. For getting it to work I need mso.dll and msoutl.olb as an import.
My problem is: the path is hardcoded , but it varies for every OS and of course if someone doesn't install Office to the default path.
I tried it this way
http://support.microsoft.com/kb/234788/en-us/
but it didn't work, because I couldn't get the return value I needed (OK, after four type conversions but I thought there had to be a better way ;) )
Thanks for helping
The path to MSO.DLL is stored under the following registry key for Office 2007:
HKLM\SOFTWARE\Microsoft\Office\12.0\Common\FilesPaths\mso.dll
The install path is also under this key:
HKLM\SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot\Path

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

Dealing with obsolete versions of RTF

Summary questions:
Do you know of a lightweight application that can save files in RTF Version 1.6 format?
Do you know what version of RTF Abiword's "Rich Text Format for old apps" corresponds to?
Do you know a way to inspect an RTF file and determine what version of RTF it's encoded under?
Do you know which DLL describes the RTF format on a Windows NT 4.0 machine and whether it can be upgraded?
I have a legacy MS Visual C++ 6.0 MFC application that runs on an embedded Windows NT 4.0 machine. The application provides in-app help using MFC's CRichEditView class to pull text out of an RTF file called help.rtf. The help file is saved as RTF version 1.6. It has always been edited using MS Word 2000 or the version of WordPad that comes with Windows NT 4.0.
The problem is that our developer workstations tend to have Windows XP (and its version of WordPad) and Office 2003 or better, both of which use more recent versions of RTF than 1.6, and it is becoming increasingly cumbersome to find a machine on which the file can be edited and re-saved in that obsolete format. If a newer version of Word or WordPad is used to save the file, it gets saved as a newer version of RTF. Then, when the application is run on the NT machine, the help text doesn't display properly. (Although when the same application is run on an XP machine, the help text does display properly.)
So, I'm looking to do one of two things:
Find an application (preferably lighter-weight than Word 2000) that will save files in RTF version 1.6 format, that we can use for future editing of the help file.
Figure out a way to get the NT machine to read later versions of RTF properly.
On the first front, I've tried AbiWord, which has a "Rich Text Format for old apps" option, but I can't tell what version of RTF this option outputs. Do you know what version this is? Unfortunately, it's not readily apparent from the metadata in the file, which just says "rtf1", per this cute passage from all versions of the RTF spec. Is there a way to analyze an RTF file and determine what version of RTF it's encoded under?
The RTF standard described in this RTF Specification, although titled as version 1.6, continues to correspond syntactically to RTF Specification version 1. Therefore, the numeric parameter N for the \rtf control word should still be emitted as 1.
On the second front, I'm wondering if there's some DLL that I can just update so that Windows NT will recognize the newer version of the format. Do you know which DLL describes the RTF format and whether it can be upgraded?
I believe the rich edit format is determined by the rich edit control itself. I wouldn't try to upgrade the DLL, because there's a lot that could break.
See this MSDN note for hints on using the later version of the rich edit control. Version 2.0 should be available in NT 4.0.
http://msdn.microsoft.com/en-us/library/tt1cfb9f(VS.80).aspx
You might try copying the version of WordPad from your NT system and see if that works as an alternative.
Following a chain of hints that started with Mark Ransom's answer, I ended up copying riched20.dll and riched32.dll from C:\Windows\System32\ on my XP machine to C:\WinNT\System32\ on the NT machine. After I did this, RTF files edited with WordPad or Word on the XP machine rendered correctly on both WordPad and my application on the NT machine.
First thing that comes to mind is WordPad. It's on every machine and is really lightweight in it's RTF. I've found it much better than Word at many simple RTF tasks.