サービス プログラムからバイナリを呼び出そうとしています。バイナリのパスは、レジストリ キーから取得されます。バッファを文字列に割り当てると、パスには「C」のみが含まれます。どこで間違いを犯していますか。Visual Studio 2010 を使用しています コードは次のとおりです。
std::string path;
getPathFromKey(path);
path = path+"\\myapp.exe";
argument = "start \"\" \""+path+"\"";
system(argument.c_str());
/ * キーを取得中* /
void getPathFromKey(std::string &path)
{
HKEY hKey = 0;
char buf[512];
DWORD dwType = 0;
DWORD dwBufSize = sizeof(buf);
if( RegOpenKey(HKEY_LOCAL_MACHINE,L"SOFTWARE\\MYAPP\\MyApp",&hKey) == ERROR_SUCCESS)
{
dwType = REG_SZ;
if( RegQueryValueEx(hKey,L"InstallPath",0, &dwType, (LPBYTE)buf, &dwBufSize) == ERROR_SUCCESS)
{
for(int i=0;buf[i];i++)
path[i]=buf[i];
return;
}
else
{
RegCloseKey(hKey);
return;
}
}
else if( RegOpenKey(HKEY_LOCAL_MACHINE,L"Software\\Wow6432Node\\MYAPP\\MyApp",&hKey) == ERROR_SUCCESS)
{
dwType = REG_SZ;
if( RegQueryValueEx(hKey,L"InstallPath",0, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS)
{
for(int i=0;buf[i];i++)
path[i]=buf[i];
return;
}
else
{
RegCloseKey(hKey);
return;
}
}
}
次のエラーが表示されます。
Windows cannot find "C"