示例#1
0
/*******************************************
 * HUFFMAN
 * Driver program to exercise the huffman generation code
 *******************************************/
void huffman()
{
   // Declare variables
   PAIR temp;
   BNODE * node;
   BNODEVECTOR data;
   STRINGVECTOR code;
   
   // Prompt the user for the file name.
   string filename;
   getFile(filename);

   // read the file
   readFile(filename, temp, node, data);

   // sort for the tree
   sort(data.begin(), data.end(), compareFrequencies);

   // Create the tree
   createtree(data);

   // Determine the path of the nodes on the tree
   encode(data[0], "", code);

   // sort the tree
   sort(code.begin(), code.end(), compareStrings);

   // Display the path
   display(code);
   return;
}
示例#2
0
void TransferWallpapers()
{
	STRINGVECTOR wallpaperRepository;

	LoadWallpaperRepository(&wallpaperRepository);
	int paramLength = 1;
	int size = wallpaperRepository.size();
	for (int i = 0; i < size; ++i)
	{
		wchar_t *str = wallpaperRepository[i];
		paramLength += wcslen(str) + 1;
	}

	if (paramLength > 1)
	{
		wchar_t *param = new wchar_t[paramLength];
		memset(param, 0, paramLength * sizeof(wchar_t));
		wchar_t *tmp = param;
		for (int i = 0; i < size; ++i)
		{
			wchar_t *str = wallpaperRepository[i];
			memcpy(tmp, str, (wcslen(str) + 1) * sizeof(wchar_t));	
			tmp += wcslen(str) + 1;
		}

		HKEY hKey = NULL;
		RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Shell\\WallpaperSets", 0, 0, &hKey);
		if (hKey)
		{
			RegSetValueEx(hKey, L"OEMWallpapers", 0, REG_MULTI_SZ, (LPBYTE)param, paramLength * sizeof(wchar_t));
			RegCloseKey(hKey);
		}
		delete[] param;
	}
	for (STRINGVECTOR::iterator iterator = wallpaperRepository.begin(); iterator != wallpaperRepository.end(); ++iterator)
	{
		delete(*iterator);
	}
	wallpaperRepository.erase(wallpaperRepository.begin(), wallpaperRepository.end());
}