I have created a C++ Custom Action DLL. I have an msi that calld from the DLL but the DLL is not included in the MSI, It is in the same location as it.
I use the following to get the location of the MSI:
TCHAR* szValueBuf = NULL;
DWORD cchValueBuf = 0;
UINT uiStat = MsiGetProperty(hInstall, TEXT("OriginalDatabase"), TEXT(""), &cchValueBuf);
if (ERROR_MORE_DATA == uiStat)
{
++cchValueBuf;
szValueBuf = new TCHAR[cchValueBuf];
if (szValueBuf)
{
uiStat = MsiGetProperty(hInstall, TEXT("OriginalDatabase"), szValueBuf, &cchValueBuf);
}
}
if (ERROR_SUCCESS != uiStat)
{
if (szValueBuf != NULL)
delete[] szValueBuf;
return ERROR_INSTALL_FAILURE;
}
This works great and gets me the full path, However the path has the name of the MSI at the end and I need to remove this to put in the name of my DLL or is there another way?
I have tried:
std::string s = "NPath";
int pos = s.find_last_of("\\");
s.erase(0, pos + 1);
s.erase(s.length() - 4, 4);
s.append("product.ini");
But i’m getting this error:
error C2894: templates cannot be declared to have 'C' linkage
Thanks
I worked it out: