Index: trunk/gsinstaller/gsRegistry.cpp
===================================================================
--- trunk/gsinstaller/gsRegistry.cpp	(revision 1589)
+++ trunk/gsinstaller/gsRegistry.cpp	(revision 1590)
@@ -3,94 +3,96 @@
 gsRegistry::gsRegistry(installManager &manager, configureFile &configFile)
   : installAgent(manager)
-{ 
-  // Create string for volume key
-  volumeKey = "Software\\" + configFile.getString("CompanyName") + "\\" +
-    configFile.getString("CollectionName") + "\\" +
-    configFile.getString("CollectionVolume") + "\\" +
-    configFile.getString("CollectionVersion");
-  
-  // Create string for collection key
-  collectKey = "Software\\" + configFile.getString("CompanyName") + "\\" +
-    configFile.getString("CollectionName") + "\\" +
-    configFile.getString("CollectionVersion");
+{
+	// Create string for volume key
+	volumeKey = "Software\\" + configFile.getString("CompanyName") + "\\" +
+							configFile.getString("CollectionName") + "\\" +
+							configFile.getString("CollectionVolume") + "\\" +
+							configFile.getString("CollectionVersion");
+
+	// Create string for collection key
+	collectKey = "Software\\" + configFile.getString("CompanyName") + "\\" +
+  							configFile.getString("CollectionName") + "\\" +
+                configFile.getString("CollectionVersion");
 }
 
 bool gsRegistry::logAction(string action, HKEY base, string path, string item, string value)
 {
-  unInstallCommand command(action);
-  command.addParameter(path);
-  if (item != "" || value != "")
+	unInstallCommand command(action);
+	command.addParameter(path);
+	if (item != "" || value != "")
+  {
+  	if (item == "")
     {
-      if (item == "")
-	{
-	  command.addParameter("{Default}");
-	}
-      else
-	{
-	  command.addParameter(item);
-	}
-      command.addParameter(value);
+    	command.addParameter("{Default}");
     }
+    else
+    {
+    	command.addParameter(item);
+    }
+    command.addParameter(value);
+  }
   return manager->storeCommand(command);
 }
 
 bool gsRegistry::undoAction(string actionName, stringArray &params)
-{
-  if (actionName == "RegistryCreateKey")
-    {
-      this->destroyKey(HKEY_LOCAL_MACHINE, params[0]);
-    }
+{ if (actionName == "RegistryCreateKey")
+	{	this->destroyKey(HKEY_LOCAL_MACHINE, params[0]);
+  }
   else if (actionName == "RegistrySetString")
-    {
-      this->destroyItem(HKEY_LOCAL_MACHINE, params[0], params[1]);
-    }
+  {	this->destroyItem(HKEY_LOCAL_MACHINE, params[0], params[1]);
+  }
   else
-    {
-      return false;
-    }
+  { return false;
+  }
+  return true;
+}
+
+bool gsRegistry::ensureParentKeyExists(HKEY base, string key)
+{	string parent;
+	int foundat;
+
+	if ((foundat = key.rfind('\\', key.length())) < key.length())
+  {	parent = key.substr(0, foundat);
+
+    return this->ensureKeyExists(base, parent);
+  }
   return true;
 }
 
 bool gsRegistry::ensureKeysExist()
-{
-  if (!this->ensureKeyExists(HKEY_LOCAL_MACHINE, this->collectKey))
-    {
-      return false;
-    }
+{ if (!this->ensureKeyExists(HKEY_LOCAL_MACHINE, this->collectKey))
+	{	return false;
+  }
   return this->ensureKeyExists(HKEY_LOCAL_MACHINE, this->volumeKey);
 }
 
 bool gsRegistry::ensureKeyExists(HKEY base, string key)
-{
-  if (!registry_keyExists(base, key.c_str()))
-    {
-      if (!registry_ensureKeyExists(base, key.c_str()))
-	{
-	  return false;
-	}
-      this->logAction("RegistryCreateKey", base, key, "", "");
+{ if (!registry_keyExists(base, key.c_str()))
+	{ if (!this->ensureParentKeyExists(base, key))
+  	{	return false;
     }
+  	if (!registry_ensureKeyExists(base, key.c_str()))
+  	{	return false;
+    }
+  	this->logAction("RegistryCreateKey", base, key, "", "");
+  }
   return true;
 }
 
 bool gsRegistry::destroyKey(HKEY base, string key)
-{
-  return registry_deletekey(base, key.c_str());
+{	return registry_deletekey(base, key.c_str());
 }
 
 bool gsRegistry::storeKeyString(HKEY base, string path, string item, string value)
-{
-  HKEY local;
-  bool reply;
+{	HKEY local;
+	bool	reply;
 
   if (!registry_openkey(base, path.c_str(), &local))
-    {
-      return false;
-    }
+ 	{	return false;
+  }
   reply = registry_setstring(local, item.c_str(), value.c_str());
   if (reply)
-    {
-      this->logAction("RegistrySetString", base, path, item, value);
-    }
+  {	this->logAction("RegistrySetString", base, path, item, value);
+  }
   registry_closekey(local);
   return reply;
@@ -98,11 +100,9 @@
 
 bool gsRegistry::destroyItem(HKEY base, string path, string item)
-{
-  HKEY local;
-  
-  if (!registry_openkey(base, path.c_str(), &local))
-    {
-      return false;
-    }
+{ HKEY local;
+
+	if (!registry_openkey(base, path.c_str(), &local))
+  {	return false;
+  }
   registry_deleteitem(local, item.c_str());
   registry_closekey(local);
@@ -111,58 +111,48 @@
 
 bool gsRegistry::collectionInstalled()
-{
-  return registry_keyExists(HKEY_LOCAL_MACHINE, this->collectKey.c_str());
+{	return registry_keyExists(HKEY_LOCAL_MACHINE, this->collectKey.c_str());
 }
 
 bool gsRegistry::volumeInstalled()
-{
-  return registry_keyExists(HKEY_LOCAL_MACHINE, this->volumeKey.c_str());
+{	return registry_keyExists(HKEY_LOCAL_MACHINE, this->volumeKey.c_str());
 }
 
 string gsRegistry::collectKeyId()
-{
-  return this->collectKey;
+{	return this->collectKey;
 }
 
 string gsRegistry::volumeKeyId()
-{
-  return this->volumeKey;
+{	return this->volumeKey;
 }
 
 string gsRegistry::exeKeyId(string exename)
-{
-  string reply = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\";
-  reply += exename;
+{	string reply = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\";
+	reply += exename;
   return reply;
 }
 
 string gsRegistry::uninstallKeyId(string collectName)
-{
-  return "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + collectName;
+{	return "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + collectName;
 }
 
 FilePath *gsRegistry::collectionPath()
-{
-  char *path = NULL;
-  FilePath *reply = NULL;
-  HKEY key;
-  
+{ char *path = NULL;
+	FilePath *reply = NULL;
+	HKEY key;
+
   if (registry_openkey(HKEY_LOCAL_MACHINE, this->collectKey.c_str(), &key))
-    {
-      if (registry_getstring(key, "library", &path))
-  	{
-	  // get leaf (\library.exe) and remove it to give a path
-	  char *leaf;
+  {	if (registry_getstring(key, "library", &path))
+  	{ // get leaf (\library.exe) and remove it to give a path
+    	char *leaf;
 
-	  leaf = strrchr(path, '\\');
-	  if (leaf != NULL)
-	    {
-	      *leaf = '\0';
-	    }
-	  reply = new FilePath(path);
-	  free(path);
-	}
-      registry_closekey(key);
+    	leaf	= strrchr(path, '\\');
+			if (leaf != NULL)
+      { *leaf = '\0';
+      }
+      reply	= new FilePath(path);
+      free(path);
     }
+  	registry_closekey(key);
+  }
   return reply;
 }
Index: trunk/gsinstaller/gsRegistry.h
===================================================================
--- trunk/gsinstaller/gsRegistry.h	(revision 1589)
+++ trunk/gsinstaller/gsRegistry.h	(revision 1590)
@@ -19,27 +19,27 @@
 
 class gsRegistry : public installAgent
-{
-private:
-  string volumeKey;
-  string collectKey;
+{	private:
+		string volumeKey;
+    string collectKey;
 
-  bool logAction(string action, HKEY base, string path, string item, string value);
-public:
-  gsRegistry(installManager &manager, configureFile &configFileb);
-  virtual ~gsRegistry () {}
-  bool storeKeyString(HKEY base, string path, string item, string value);
-  bool collectionInstalled();
-  bool volumeInstalled();
-  bool ensureKeysExist();
-  bool ensureKeyExists( HKEY base, string key);
-  bool destroyKey(HKEY base, string key);
-  bool destroyItem(HKEY base, string key, string name);
-  string collectKeyId();
-  string volumeKeyId();
-  string exeKeyId(string exeName);
-  string uninstallKeyId(string collectName);
-  FilePath *collectionPath();
-  bool undoAction(string ActionName, stringArray &params);
-  //    Path();
+    bool logAction(string action, HKEY base, string path, string item, string value);
+    bool ensureParentKeyExists( HKEY base, string key);
+	public:
+  	gsRegistry(installManager &manager, configureFile &configFileb);
+		bool 			storeKeyString(	HKEY base, string path, string item, string value);
+    bool 			collectionInstalled();
+    bool 			volumeInstalled();
+    bool			ensureKeysExist();
+    bool			ensureKeyExists( HKEY base, string key);
+    bool			destroyKey(HKEY base, string key);
+    bool			destroyItem(HKEY base, string key, string name);
+    string		collectKeyId();
+    string		volumeKeyId();
+    string		exeKeyId(string exeName);
+    string    uninstallKeyId(string collectName);
+    FilePath *collectionPath();
+    bool undoAction(string ActionName, stringArray &params);
+//    Path();
 };
 #endif
+
