Ejemplo n.º 1
0
void CUninstallApp::RecursiveRegDelKey(HKEY hKey)
{
	char keyname[256]={0};
	DWORD namesize=256;

	//base case: no subkeys when RegEnumKeyEx returns error on index 0
	LONG lResult=RegEnumKeyEx(hKey,0,keyname,&namesize,NULL,NULL,NULL,NULL);
	if (lResult!=ERROR_SUCCESS)
	{
#ifdef _DEBUG
		AfxMessageBox("RecursiveRegDelKey found no keys");
#endif
		return;
	}

	DWORD i=1;
	do
	{
		HKEY subkey;
		LONG lResult2;
		LONG lDelResult;
		lResult2=RegOpenKeyEx(hKey,keyname,0,KEY_ALL_ACCESS,&subkey);
		
		if (lResult2==ERROR_SUCCESS)
		{
#ifdef _DEBUG
			AfxMessageBox("RRDK going to " + CString(keyname));
#endif
			RecursiveRegDelKey(subkey);

			RegCloseKey(subkey);
			lDelResult=RegDeleteKey(hKey,keyname);
			if (lDelResult!=ERROR_SUCCESS)
			{
#ifdef _DEBUG
				AfxMessageBox(CString("could not delete ") + CString(keyname));
#endif
			}
			namesize=256;
			//use 0 in the next function call because when you delete one, the rest shift down!
			lResult=RegEnumKeyEx(hKey,0,keyname,&namesize,NULL,NULL,NULL,NULL);
		}

		else 
		{
#ifdef _DEBUG
			AfxMessageBox("failed trying open: " + CString(keyname));
#endif
			break;
		}

	} while (lResult!=ERROR_NO_MORE_ITEMS);
	
}
Ejemplo n.º 2
0
void CUninstallApp::DelHLKeyContentsInCurrentUser()
{
	LONG lResult;
	//note, in HKEY_CURRENT_USER Half-Life Day One is never used. Only Half-Life.
	HKEY hkwipe;
	
	
	lResult = RegOpenKeyEx(HKEY_CURRENT_USER,CString(REG_VALVE_KEY) + "\\Half-Life",0,KEY_ALL_ACCESS,&hkwipe);
	if (lResult==ERROR_SUCCESS)
	{
#ifdef _DEBUG
		AfxMessageBox("starting recursive del on HKCU");
#endif
		RecursiveRegDelKey(hkwipe);
		RegCloseKey(hkwipe);
	}
#ifdef _DEBUG
	else 
	{

		AfxMessageBox(CString("failed trying open: HKCU ")+CString(REG_VALVE_KEY) + "\\Half-Life" );
	}
#endif

	lResult=RegOpenKeyEx(HKEY_CURRENT_USER,REG_VALVE_KEY,0,KEY_ALL_ACCESS,&hkwipe);
	if (lResult==ERROR_SUCCESS)
	{
		lResult=RegDeleteKey(hkwipe,"Half-Life");
#ifdef _DEBUG
		if (lResult!=ERROR_SUCCESS)
		{
			AfxMessageBox("failed trying DELETE: HKCU " REG_VALVE_KEY "\\Half-Life");
		}
#endif

		RegCloseKey(hkwipe);
	}
#ifdef _DEBUG
	else 
	{
		AfxMessageBox("failed trying open: HKCU " REG_VALVE_KEY );
	}
#endif
}
Ejemplo n.º 3
0
void CUninstallApp::DelHLKeyContentsInLocalMachine()
{
	//this func is mainly just a clean-up style function
	//after HL is uninstalled, this just wipes all the HL 
	//related stuff in HKEY_LOCAL_MACHINE
	//InstallShield should wipe it, but it's kind of flaky
	//as to whether or not it will actually do it sometimes.
	
	HKEY hkwipe;
	LONG lResult;
	lResult=RegOpenKeyEx(HKEY_LOCAL_MACHINE,REG_HALFLIFE_KEY,0,KEY_ALL_ACCESS,&hkwipe);
	if (lResult==ERROR_SUCCESS)
	{
#ifdef _DEBUG
		AfxMessageBox("starting recursive del on HKCU");		
#endif
		RecursiveRegDelKey(hkwipe);
		RegCloseKey(hkwipe);
	}
#ifdef _DEBUG
	else 
	{

		AfxMessageBox(CString("failed trying open: HKLM ")+CString(REG_HALFLIFE_KEY));
	}
#endif

	lResult=RegOpenKeyEx(HKEY_LOCAL_MACHINE,REG_VALVE_KEY,0,KEY_ALL_ACCESS,&hkwipe);
	if (lResult==ERROR_SUCCESS)
	{
		RegDeleteKey(hkwipe,m_szSimpleGameName);
		RegCloseKey(hkwipe);
	}
#ifdef _DEBUG
	else 
	{
		AfxMessageBox(CString("failed trying open: HKLM ")+CString(REG_VALVE_KEY));
	}
#endif
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// Purpose: HACK HACK:  We have to delete the RecoContext key or sapi starts to train
//  itself on each iteration which was causing some problems.
// Input  : hKey - 
//-----------------------------------------------------------------------------
void RecursiveRegDelKey(HKEY hKey)
{
	char keyname[256]={0};
	DWORD namesize=256;

	//base case: no subkeys when RegEnumKeyEx returns error on index 0
	LONG lResult=RegEnumKeyEx(hKey,0,keyname,&namesize,NULL,NULL,NULL,NULL);
	if (lResult!=ERROR_SUCCESS)
	{
		return;
	}

	do
	{
		HKEY subkey;
		LONG lResult2;
		LONG lDelResult;
		lResult2=RegOpenKeyEx(hKey,keyname,0,KEY_ALL_ACCESS,&subkey);
		
		if (lResult2==ERROR_SUCCESS)
		{
			RecursiveRegDelKey(subkey);

			RegCloseKey(subkey);
			lDelResult=RegDeleteKey(hKey,keyname);
			namesize=256;
			//use 0 in the next function call because when you delete one, the rest shift down!
			lResult=RegEnumKeyEx(hKey,0,keyname,&namesize,NULL,NULL,NULL,NULL);
		}

		else 
		{
			break;
		}

	} while (lResult!=ERROR_NO_MORE_ITEMS);
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: Given a wavfile and a list of inwords, determines the word/phonene 
//  sample counts for the sentce
// Input  : *wavfile - 
//			*inwords - 
//			*outphonemes{	text.Clear( - 
// Output : SR_RESULT
//-----------------------------------------------------------------------------
static SR_RESULT SAPI_ExtractPhonemes( 
	const char *wavfile,
	int numsamples,
	void (*pfnPrint)( const char *fmt, ... ),
	CSentence& inwords,
	CSentence& outwords )
{
	LogReset();

	USES_CONVERSION;

	CSpDynamicString text;
	text.Clear();

	HKEY hkwipe;
	LONG lResult = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Speech\\RecoProfiles", 0, KEY_ALL_ACCESS, &hkwipe );
	if ( lResult == ERROR_SUCCESS )
	{
		RecursiveRegDelKey( hkwipe );
		RegCloseKey( hkwipe );
	}

	if ( strlen( inwords.GetText() ) <= 0 )
	{
		inwords.SetTextFromWords();
	}

	// Construct a string from the inwords array
	text.Append( T2W( inwords.GetText() ) );

	// Assume failure
	SR_RESULT result = SR_RESULT_ERROR;

	if ( text.Length() > 0 )
	{
		CSentence sentence;

		pfnPrint( "Processing...\r\n" );

		// Give it a try
		result = ExtractPhonemes( wavfile, text, sentence, pfnPrint );

		pfnPrint( "Finished.\r\n" );
		// PrintWordsAndPhonemes( sentence, pfnPrint );

		// Copy results to outputs
		outwords.Reset();

		outwords.SetText( inwords.GetText() );
		
		Log( "Starting\n" );
		LogWords( inwords );

		if ( SR_RESULT_ERROR != result )
		{
			int i;

			Log( "Hypothesized\n" );
			LogWords( sentence );

			for( i = 0 ; i < sentence.m_Words.Size(); i++ )
			{
				CWordTag *tag = sentence.m_Words[ i ];
				if ( tag )
				{
					// Skip '...' tag
					if ( stricmp( tag->GetWord(), "..." ) )
					{
						CWordTag *newTag = new CWordTag( *tag );

						outwords.m_Words.AddToTail( newTag );
					}
				}
			}

			// Now insert unrecognized/skipped words from original list
			//
			int frompos = 0, topos = 0;

			while( 1 )
			{
				// End of source list
				if ( frompos >= inwords.m_Words.Size() )
					break;

				const CWordTag *fromTag = inwords.m_Words[ frompos ];

				// Reached end of destination list, just copy words over from from source list until
				//  we run out of source words
				if ( topos >= outwords.m_Words.Size() )
				{
					// Just copy words over
					CWordTag *newWord = new CWordTag( *fromTag );

					// Remove phonemes
					while ( newWord->m_Phonemes.Size() > 0 )
					{
						CPhonemeTag *kill = newWord->m_Phonemes[ 0 ];
						newWord->m_Phonemes.Remove( 0 );
						delete kill;
					}

					outwords.m_Words.AddToTail( newWord );
					frompos++;
					topos++;
					continue;
				}

				// Destination word
				const CWordTag *toTag = outwords.m_Words[ topos ];

				// Words match, just skip ahead
				if ( !stricmp( fromTag->GetWord(), toTag->GetWord() ) )
				{
					frompos++;
					topos++;
					continue;
				}

				// The only case we handle is that something in the source wasn't in the destination

				// Find the next source word that appears in the destination
				int skipAhead = frompos + 1;
				bool found = false;
				while ( skipAhead < inwords.m_Words.Size() )
				{
					const CWordTag *sourceWord = inwords.m_Words[ skipAhead ];
					if ( !stricmp( sourceWord->GetWord(), toTag->GetWord() ) )
					{
						found = true;
						break;
					}

					skipAhead++;
				}

				// Uh oh destination has words that are not in source, just skip to next destination word?
				if ( !found )
				{
					topos++;
				}
				else
				{
					// Copy words from from source list into destination
					// 
					int skipCount = skipAhead - frompos;

					while ( --skipCount>= 0 )
					{
						const CWordTag *sourceWord = inwords.m_Words[ frompos++ ];
						CWordTag *newWord = new CWordTag( *sourceWord );

						// Remove phonemes
						while ( newWord->m_Phonemes.Size() > 0 )
						{
							CPhonemeTag *kill = newWord->m_Phonemes[ 0 ];
							newWord->m_Phonemes.Remove( 0 );
							delete kill;
						}

						outwords.m_Words.InsertBefore( topos, newWord );
						topos++;
					}

					frompos++;
					topos++;
				}
			}

			Log( "\nDone simple check\n" );

			LogWords( outwords );
			LogPhonemes( outwords );

			ComputeMissingByteSpans( numsamples, outwords );

			Log( "\nFinal check\n" );

			LogWords( outwords );
			LogPhonemes( outwords );
		}
	}
	else
	{
		pfnPrint( "Input sentence is empty!\n" );
	}

	// Return results
	return result;
}