Reputation: 496
I have property MYPATH in my MSI setup and I am installing some components to this path. Now I want to get the path where is my component installed. I am using following code:
INSTALLUILEVEL pervousUILevel = MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
MSIHANDLE handle = NULL;
MsiOpenProduct(productCode,&handle);
wchar_t myPath[2048];
DWORD dwBuffer = 2048;
MsiGetProductProperty(handle, L"MYPATH", myPath, &dwBuffer);
MsiCloseHandle(handle);
MsiSetInternalUI(pervousUILevel, NULL);
But I am still getting the default value "C:\MyDefaultPath" instead of "C:\The Path I Specified During The Installation". What am I doing wrong?
Thanks
Edit:
I found out that the code:
wchar_t myPath[4096];
DWORD isBuffer = 4096;
MsiGetComponentPath(productCode, L"{component-guid}", myPath, &isBuffer);
Also returns the default path.
Upvotes: 0
Views: 1310
Reputation: 10993
This happens because you are reading the value directly from the MSI package. You need to get the property value during the installation process, using MsiGetProperty API methodm with a custom action. The linked example is for a custom action that does serial validation, what interest you from there is just the way you define a custom action and how to get the value, the rest of the code you don't need
Upvotes: 1