感觉你的参数少了一点
AnsiString __fastcall TVDSUpdate::GetRegistryValue(AnsiString KeyName,AnsiString Str)
{
AnsiString S = "";
TRegistry *Registry = new TRegistry;
try
{
Registry->RootKey = HKEY_CURRENT_USER;
// false because we do not want to create it if it doesn't exist
if (Registry->OpenKey(KeyName, false))
S = Registry->ReadString(Str);
}
__finally
{
delete Registry;
}
return S;
}
第一个参数是注册表的路径,第二个参数是路径下要读取的字符串值的名称
(前提:要读取注册表项的必须为字符串值)
// Start the child process.
if( !CreateProcess( AppNamePath.c_str(), // No module name (use command line).
NULL, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
// ErrorExit( "CreateProcess failed." );
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
//---------------------------------------------------------------------------
AnsiString __fastcall TVDSUpdate::GetRegistryValue(AnsiString KeyName)
{
AnsiString S = "";
TRegistry *Registry = new TRegistry;
try
{
Registry->RootKey = HKEY_CURRENT_USER;
// false because we do not want to create it if it doesn't exist
if (Registry->OpenKey(KeyName, false))
S = Registry->ReadString("AppName");
}
__finally
{
delete Registry;
}
return S;
}
//---------------------------------------------------------------------------