I have a C++ Custom Action Project. I have two functions, RegProductName
and GetProductName
.
I call RegProductName
and it has three possible outcomes. I have these in an if statement that if it is outcome 1 or outcome 2 then i call my second function GetProductName
but i can't seem to get it working. Can anyone give me an example of calling one function from another please?
extern "C" UINT __stdcall RegProductName(MSIHANDLE hInstall)
{
AssertSz(FALSE, "debug here");
DebugBreak();
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
char szProductName[MAX_PATH];
hr = WcaInitialize(hInstall, "RegProductName");
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
strcpy(szProductName, Orc_Get_Product_Name());
if(szProductName == "ORCHESTRATOR")
{
GetProductName();
}
else if (szProductName == "CORAL")
{
GetProductName();
}
else
{
MsiSetProperty(hInstall, "PRODUCTNAME", szProductName);
}
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
The error is "Too few arguments in function call when i hover over GetProductName();
extern "C" UINT __stdcall GetProductName(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
DWORD Ret;
CHAR *Section = "General";
CHAR szBuffer[MAX_PATH];
CHAR szProductIniFile[MAX_PATH];
char lpszString[MAX_PATH];
int lplValue;
hr = WcaInitialize(hInstall, "GetProductName");
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
TCHAR* szValueBuf = NULL;
DWORD cchValueBuf = 0;
UINT uiStat = MsiGetProperty(hInstall, TEXT("TEMPFOLDER"), TEXT(""), &cchValueBuf);
if (ERROR_MORE_DATA == uiStat)
{
++cchValueBuf;
szValueBuf = new TCHAR[cchValueBuf];
if (szValueBuf)
{
uiStat = MsiGetProperty(hInstall, TEXT("TEMPFOLDER"), szValueBuf, &cchValueBuf);
}
}
if (ERROR_SUCCESS != uiStat)
{
if (szValueBuf != NULL)
delete[] szValueBuf;
return ERROR_INSTALL_FAILURE;
}
strcpy(szProductIniFile,szValueBuf);
Ret = strlen(szProductIniFile);
if(szProductIniFile[Ret-1] != '\\')
strcat(szProductIniFile,"\\");
strcat(szProductIniFile, "Product.ini");
Ret = GetPrivateProfileString(Section, // Section Title [General]
"PRODUCT_NAME", // Entry
"Orchestrator", // Default Value
szBuffer, // Address of buffer to read to
MAX_PATH, // Length of buffer
szProductIniFile); // .ini file name
if (strlen(szBuffer) == 0)
strcpy(szBuffer, "ORCHESTRATOR");
if (strlen(szBuffer) >= 3 && (stricmp(szBuffer+strlen(szBuffer)-3,"DEM") == 0))
lplValue = 1;
else
lplValue = 0;
MsiSetProperty(hInstall, "PRODUCTNAME", szBuffer);
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
Your GetProductName()
function takes an argument MSIHANDLE hInstall
. You'll need to provide that when calling it. For instance, if you just want to call it with the same handle as RegProductName()
was called with:
GetProductName(hInstall);