HOWTO: Find the Installation Path of an Office 2000 Application

ID: Q234788


The information in this article applies to:


SUMMARY

This article demonstrates how to use the Windows Installer to find the installation path of Microsoft Office applications.


MORE INFORMATION

Office 2000 does not include path information in the shortcut links when installed. This is done so that the "Run on First Use" option can be used. When this option is used, the shortcuts will appear, but the applications will not be installed on the hard disk. When you click on the shortcut for the first time, the applications will be installed.

You can use the Windows Installer to get the path of the installed Office application. Follow the steps given below to create a console application that reports the directory of an installed Office application.

Building the Sample

  1. Create a blank console application in Visual C++.


  2. Create a new file called main.cpp and paste the following code in the code window:


  3. 
    #include <windows.h>
    #include <msi.h>
    #include <ostream.h>
    
    const char *Word = "{CC29E963-7BC2-11D1-A921-00A0C91E2AA2}";
    const char *Excel = "{CC29E96F-7BC2-11D1-A921-00A0C91E2AA2}";
    const char *PowerPoint = "{CC29E94B-7BC2-11D1-A921-00A0C91E2AA2}";
    const char *Access = "{CC29E967-7BC2-11D1-A921-00A0C91E2AA2}";
    
    int main(void)
    {
    	DWORD size = 300;
    	INSTALLSTATE installstate;
    	char *sPath;
    
    	sPath = new char[size];
            installstate = MsiGetComponentPath(
            "{00000409-78E1-11D2-B60F-006097C998E7}",Word,sPath,&size);
    	if ((installstate == INSTALLSTATE_LOCAL) || 
                (installstate == INSTALLSTATE_SOURCE)) 
    	  cout << "Installed in: " << sPath << endl;
    	delete sPath;
    	return 0;
    } 
  4. Click the Project menu and then click Settings to bring up the project settings dialog box.


  5. Click the Link tab and add msi.lib in the list of Object/library modules.


  6. Run the program. It will display the file path where Microsoft Word 2000 is installed.


  7. NOTE: Included in the code are the GUIDS associated with Word, Excel, PowerPoint and Access. To find the path for another Office application, pass in the name of the application as the second parameter of the MsiGetComponentPath function.


REFERENCES

You can download the Windows Installer SDK, which includes the MSI.LIB file, from:

http://www.microsoft.com/msdownload/platformsdk/WinInst.htm

For more information on Office Automation, please visit the Microsoft Office Development support site at:

http://support.microsoft.com/support/officedev/

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Mark Durrett, Microsoft Corporation

Additional query words:


Keywords          : kbVC500 kbVC600 kbGrpDSO kbOffice2000 kbDSupport 
Version           : WINDOWS:2000; winnt:5.0,6.0
Platform          : WINDOWS winnt 
Issue type        : kbhowto 

Last Reviewed: July 13, 1999