How to programmatically locate Arbortext on a Windows system

John Dreystadt (PTC) shows how to ask Windows where Arbortext is installed Last Updated: 2006-08-04

In our 5.2 release, we switched to a much more modern installer technology for Windows. Below is some example code (unsupported by the way) that uses the Installer API from Microsoft to see where we got installed. You should be able to use this as a start for your own code.

// Example of using the Windows Installer API to locate an // Arbortext installation. DJW 5/19/06 int main(int argc, TCHAR* argv[]) {    // Enumerate all of the installed products by GUID. TCHAR szProductCode[39]; // 38-character GUID plus terminator DWORD i = 0; while (MsiEnumProducts(i++, szProductCode) == ERROR_SUCCESS) {        TCHAR szProductName[256], szInstallLoc[256], szVerMajor[256], szVerMinor[256], szVerString[256]; // For each installed product, obtain the name and see // if it begins with "Arbortext ". DWORD len = 256; if (MsiGetProductInfo(szProductCode, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, szProductName, &len) != ERROR_SUCCESS) continue; if (_tcsncmp(szProductName, _T("Arbortext "), 10) != 0) continue; // We have a hit. Fetch the install location and the // version information. len = 256; MsiGetProductInfo(szProductCode,                          INSTALLPROPERTY_INSTALLLOCATION, szInstallLoc, &len); len = 256; MsiGetProductInfo(szProductCode, INSTALLPROPERTY_VERSIONMAJOR,                           szVerMajor, &len); len = 256; MsiGetProductInfo(szProductCode, INSTALLPROPERTY_VERSIONMINOR,                          szVerMinor, &len); len = 256; MsiGetProductInfo(szProductCode, INSTALLPROPERTY_VERSIONSTRING,                          szVerString, &len); printf("Product name: %s\nInstalled location: %s\n",               szProductName, szInstallLoc); printf("Version major: %s\nVersion minor: %s\nVersion string: %s\n",               szVerMajor, szVerMinor, szVerString); }      return 0; }
 * 1) include "windows.h"
 * 2) include "msi.h"
 * 3) include "tchar.h"
 * 4) include "stdio.h"