这可能是一个简单的问题,但我已经尝试了一切并且完全不知所措。
sprintf(&szDevCapEntry[strlen(szDevCapEntry)], ",%s:%0d", (LPCSTR)szAnalogP, szAnalogChannels);
该条目应该添加AL:1000
,但它添加了A:1000
,我不知道为什么。szAnalogP
绝对是AL。有人有什么想法吗?
编辑:我的功能:
extern "C" UINT __stdcall WriteDriverEntry(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
CString m_DevicePrintName, m_nDeviceNumber, m_DeviceName;
LPWSTR szDevicePrintName= NULL, szDeviceNum = NULL, szValueBuf = NULL, szAnalogP = NULL, szDigitalP = NULL, szAnalogOP = NULL, szDigitalOP = NULL;
LPWSTR szDiagnosticP = NULL, szCounterP;
CHAR szDevCapEntry[256], szBuffer[MAX_PATH];
int Index, szAnalogChannels, szDigitalChannels, szAnalogOChannels, szDigitalOChannels, szDiagnosticChannels, szCounterChannels;
hr = WcaInitialize(hInstall, "WriteDriverEntry");
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
hr = WcaGetProperty(L"COMPORTNUMBER", &szDeviceNum);
ExitOnFailure(hr, "failed to get comport number");
m_nDeviceNumber = szDeviceNum;
hr = WcaGetProperty(L"DEVICEPRINTNAME", &szDevicePrintName);
ExitOnFailure(hr, "failed to get device print name");
m_DevicePrintName = szDevicePrintName;
hr = WcaGetProperty(L"DEVICENAME",&szValueBuf);
ExitOnFailure(hr, "failed to get device name");
m_DeviceName = szValueBuf;
wsprintf(szDevCapEntry, "%s,%s,%s", (LPCSTR)m_DeviceName, m_nDeviceNumber, (LPCSTR)m_DevicePrintName);
hr = WcaGetProperty(L"ANALOGPREFIX",&szAnalogP);
hr = WcaGetIntProperty(L"ANALOGCHANNELS",&szAnalogChannels);
if (szAnalogChannels != 0 )
{
WcaSetProperty(L"TEST", szAnalogP);
sprintf(&szDevCapEntry[strlen(szDevCapEntry)], ",%s:%0d", (LPCSTR)szAnalogP, szAnalogChannels);
WcaLog(LOGMSG_STANDARD, szDevCapEntry);
}
if (!UpdateCapEntry(szDevCapEntry))
return -1;
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
我有不同的变体,例如 %.2s,因此它会显示两个字符,但我只得到一个。如果这是一个太宽泛的问题,我很抱歉,但我是初学者,无法弄清楚。我想也许将变量转换为 char 可能会起作用,但它给了我相同的结果。