Exemplo n.º 1
0
// Helper method to build Registry Key string
void GetKey(LPCWSTR pBase, LPCWSTR pGroup, LPCWSTR pApp, LPCWSTR pFolder, LPWSTR pRet)
{
	// Check for required params
	ASSERT(pBase && pApp && pRet);
	if (!pBase || !pApp || !pRet)
		return;

	// Base
	wcscpy(pRet, pBase);

	// Group (optional)
	if (pGroup && (pGroup[0] != '\0'))
	{
		EnsureTrailingSeparator(pRet);
		wcscat(pRet, pGroup);
	}

	// App name
	EnsureTrailingSeparator(pRet);
	wcscat(pRet, pApp);

	// Folder (optional)
	if (pFolder && (pFolder[0] != '\0'))
	{
		EnsureTrailingSeparator(pRet);
		wcscat(pRet, pFolder);
	}
}
Exemplo n.º 2
0
    /**
      Remove the last folder from a folder name.
    */
    std::string RemoveLastFolderFromName(const std::string& name, bool useTrailingSeparator)
    {
      std::string result(name);

      // Get rid of any trailing item first.
      result = EnsureTrailingSeparator(result, true, false);

      // Now get rid of the next segment.
      size_t position = result.find_last_of("\\/");
      if (position != std::string::npos)
      {
        result = result.substr(0, position);
      }

      // Add the new trailing item, as needed.
      result = EnsureTrailingSeparator(result, true, useTrailingSeparator);

      return result;
    }