Index: trunk/NSClient++.cpp
===================================================================
--- trunk/NSClient++.cpp	(revision 99bb0300f93e0485bc9085608e2a2bc32cb1f060)
+++ trunk/NSClient++.cpp	(revision c8ebdecdf91a062ab9bbc91626e8ca60b3bce10e)
@@ -20,4 +20,5 @@
 #include <Socket.h>
 #include <b64/b64.h>
+#include <config.h>
 
 
@@ -65,5 +66,10 @@
 			g_bConsoleLog = true;
 			std::string password;
-			Settings::getInstance()->setFile(mainClient.getBasePath() + "NSC.ini");
+			try {
+				Settings::getInstance()->setFile(mainClient.getBasePath() + "NSC.ini");
+			} catch (SettingsException e) {
+				std::cout << "Could not find settings: " << e.getMessage() << std::endl;;
+				return 1;
+			}
 			std::cout << "Enter password to encrypt (has to be a single word): ";
 			std::cin >> password;
@@ -97,5 +103,9 @@
 #endif
 			g_bConsoleLog = true;
-			mainClient.InitiateService();
+			if (!mainClient.InitiateService()) {
+				LOG_ERROR_STD("Service *NOT* started!");
+				return -1;
+			}
+			LOG_MESSAGE_STD("Using settings from: " + Settings::getInstance()->getActiveType());
 			LOG_MESSAGE("Enter command to inject or exit to terminate...");
 			std::string s = "";
@@ -146,11 +156,16 @@
  * When the program is started as a service this will be the entry point.
  */
-void NSClientT::InitiateService(void) {
-	Settings::getInstance()->setFile(getBasePath() + "NSC.ini");
-
+bool NSClientT::InitiateService(void) {
+	try {
+		Settings::getInstance()->setFile(getBasePath() + "NSC.ini");
+	} catch (SettingsException e) {
+		LOG_ERROR_STD("Could not find settings: " + e.getMessage());
+		return false;
+	}
 	try {
 		simpleSocket::WSAStartup();
 	} catch (simpleSocket::SocketException e) {
 		LOG_ERROR_STD("Uncaught exception: " + e.getMessage());
+		return false;
 	}
 
@@ -161,7 +176,9 @@
 		} catch(const NSPluginException& e) {
 			LOG_ERROR_STD("Exception raised: " + e.error_ + " in module: " + e.file_);
+			return false;
 		}
 	}
 	loadPlugins();
+	return true;
 }
 /**
Index: trunk/NSClient++.h
===================================================================
--- trunk/NSClient++.h	(revision 9bc31a8a27f662c95284c419304c773799dec4f4)
+++ trunk/NSClient++.h	(revision c8ebdecdf91a062ab9bbc91626e8ca60b3bce10e)
@@ -53,5 +53,5 @@
 
 	// Service helper functions
-	void InitiateService(void);
+	bool InitiateService(void);
 	void TerminateService(void);
 	static void WINAPI service_main_dispatch(DWORD dwArgc, LPTSTR *lpszArgv);
Index: trunk/NSClient++.sln
===================================================================
--- trunk/NSClient++.sln	(revision 9bc31a8a27f662c95284c419304c773799dec4f4)
+++ trunk/NSClient++.sln	(revision c8ebdecdf91a062ab9bbc91626e8ca60b3bce10e)
@@ -119,5 +119,4 @@
 		{BD93F0C3-E342-4D68-9717-FCAC2E7189AA}.Distribution.Build.0 = Debug|Win32
 		{BD93F0C3-E342-4D68-9717-FCAC2E7189AA}.Release.ActiveCfg = Release|Win32
-		{BD93F0C3-E342-4D68-9717-FCAC2E7189AA}.Release.Build.0 = Release|Win32
 		{E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug.ActiveCfg = Debug|Win32
 		{E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug.Build.0 = Debug|Win32
Index: trunk/include/INISettings.h
===================================================================
--- trunk/include/INISettings.h	(revision 8b89aba942bc1a2492e1562596c052a8967b54c6)
+++ trunk/include/INISettings.h	(revision c8ebdecdf91a062ab9bbc91626e8ca60b3bce10e)
@@ -25,7 +25,9 @@
 	{
 	}
+	std::string getActiveType() {
+		return "INI-file";
+	}
 
 	static bool hasSettings(std::string file) {
-		std::cout << GetPrivateProfileInt(MAIN_SECTION_TITLE, MAIN_USEFILE, MAIN_USEFILE_DEFAULT, file.c_str()) << ":" << file << std::endl;
 		return GetPrivateProfileInt(MAIN_SECTION_TITLE, MAIN_USEFILE, MAIN_USEFILE_DEFAULT, file.c_str()) == 1;
 	}
Index: trunk/include/REGSettings.h
===================================================================
--- trunk/include/REGSettings.h	(revision 8b89aba942bc1a2492e1562596c052a8967b54c6)
+++ trunk/include/REGSettings.h	(revision c8ebdecdf91a062ab9bbc91626e8ca60b3bce10e)
@@ -6,4 +6,5 @@
 #define BUFF_LEN 4096
 
+#include <iostream>
 class REGSettings : public TSettings
 {
@@ -19,11 +20,13 @@
 
 	static bool hasSettings() {
-		// @todo
-		return false;
+		return getInt_(NS_HKEY_ROOT, NS_REG_ROOT, "use_reg", 0) == 1;
+	}
+
+	std::string getActiveType() {
+		return "registry";
 	}
 
 	sectionList getSections(unsigned int bufferLength = BUFF_LEN) {
-		sectionList ret;
-		return ret;
+		return getSubKeys_(NS_HKEY_ROOT, NS_REG_ROOT);
 	}
 
@@ -34,6 +37,5 @@
 	*/
 	sectionList getSection(std::string section, unsigned int bufferLength = BUFF_LEN) {
-		sectionList ret;
-		return ret;
+		return getValues_(NS_HKEY_ROOT, std::string((std::string)NS_REG_ROOT + "\\" + section).c_str());
 	}
 	/**
@@ -45,6 +47,5 @@
 	*/
 	std::string getString(std::string section, std::string key, std::string defaultValue = "") const {
-		std::string ret;
-		return ret;
+		return getString_(NS_HKEY_ROOT, std::string((std::string)NS_REG_ROOT + "\\" + section).c_str(), key.c_str(), defaultValue);
 	}
 
@@ -60,7 +61,98 @@
 	*/
 	int getInt(std::string section, std::string key, int defaultValue = 0) {
-		return 0;
+		return getInt_(NS_HKEY_ROOT, std::string((std::string)NS_REG_ROOT + "\\" + section).c_str(), key.c_str(), defaultValue);
 	}
 	void setInt(std::string section, std::string key, int value) {
 	}
+
+
+	static std::string getString_(HKEY hKey, LPCTSTR lpszPath, LPCTSTR lpszKey, std::string def) {
+		std::string ret = def;
+		HKEY hTemp;
+		if (RegOpenKeyEx(hKey, lpszPath, 0, KEY_QUERY_VALUE, &hTemp) != ERROR_SUCCESS) {
+			return def;
+		}
+		DWORD type;
+		DWORD cbData = 1024;
+		BYTE *bData = new BYTE[cbData];
+		BOOL bRet = RegQueryValueEx(hTemp, lpszKey, NULL, &type, bData, &cbData);
+		if (type != REG_SZ) {
+			bRet = false;
+		}
+		RegCloseKey(hTemp);
+		if (bRet) {
+			ret = (LPCTSTR)bData;
+		}
+		delete [] bData;
+		return ret;
+	}
+	static DWORD getInt_(HKEY hKey, LPCTSTR lpszPath, LPCTSTR lpszKey, DWORD def) {
+		DWORD ret = def;
+		LONG bRet;
+		HKEY hTemp;
+		if ((bRet = RegOpenKeyEx(hKey, lpszPath, 0, KEY_READ, &hTemp)) != ERROR_SUCCESS) {
+			return def;
+		}
+		DWORD type;
+		DWORD cbData = 1024;
+		BYTE *bData = new BYTE[sizeof(DWORD)];
+		bRet = RegQueryValueEx(hTemp, lpszKey, NULL, &type, bData, &cbData);
+		if (type != REG_DWORD) {
+			bRet = -1;
+		}
+		RegCloseKey(hTemp);
+		if (bRet == ERROR_SUCCESS) {
+			ret = (DWORD)*bData;
+		}
+		delete [] bData;
+		return ret;
+	}
+	static sectionList getValues_(HKEY hKey, LPCTSTR lpszPath) {
+		sectionList ret;
+		LONG bRet;
+		HKEY hTemp;
+		if ((bRet = RegOpenKeyEx(hKey, lpszPath, 0, KEY_READ, &hTemp)) != ERROR_SUCCESS) {
+			return ret;
+		}
+		DWORD    cValues=0;
+		DWORD    cMaxValLen;
+		// Get the class name and the value count. 
+		bRet = RegQueryInfoKey(hTemp,NULL,NULL,NULL,NULL,NULL,NULL,&cValues,&cMaxValLen,NULL,NULL,NULL);
+		if ((bRet == ERROR_SUCCESS)&&(cValues>0)) {
+			TCHAR *lpValueName = new TCHAR[cMaxValLen+1];
+			for (unsigned int i=0; i<cValues; i++) {
+				DWORD len = cMaxValLen;
+				bRet = RegEnumValue(hKey, i, lpValueName, &len, NULL, NULL, NULL, NULL);
+				if (bRet == ERROR_SUCCESS) {
+					ret.push_back(std::string(lpValueName));
+				}
+			}
+			delete [] lpValueName;
+		}
+		return ret;
+	}
+	static sectionList getSubKeys_(HKEY hKey, LPCTSTR lpszPath) {
+		sectionList ret;
+		LONG bRet;
+		HKEY hTemp;
+		if ((bRet = RegOpenKeyEx(hKey, lpszPath, 0, KEY_READ, &hTemp)) != ERROR_SUCCESS) {
+			return ret;
+		}
+		DWORD    cSubKeys=0;
+		DWORD    cMaxKeyLen;
+		// Get the class name and the value count. 
+		bRet = RegQueryInfoKey(hTemp,NULL,NULL,NULL,&cSubKeys,&cMaxKeyLen,NULL,NULL,NULL,NULL,NULL,NULL);
+		if ((bRet == ERROR_SUCCESS)&&(cSubKeys>0)) {
+			TCHAR *lpValueName = new TCHAR[cMaxKeyLen+1];
+			for (unsigned int i=0; i<cSubKeys; i++) {
+				DWORD len = cMaxKeyLen;
+				bRet = RegEnumKey(hKey, i, lpValueName, len);
+				if (bRet == ERROR_SUCCESS) {
+					ret.push_back(std::string(lpValueName));
+				}
+			}
+			delete [] lpValueName;
+		}
+		return ret;
+	}
 };
Index: trunk/include/Settings.h
===================================================================
--- trunk/include/Settings.h	(revision 8b89aba942bc1a2492e1562596c052a8967b54c6)
+++ trunk/include/Settings.h	(revision c8ebdecdf91a062ab9bbc91626e8ca60b3bce10e)
@@ -10,6 +10,11 @@
 
 class SettingsException {
+private:
+	std::string err;
 public:
-	SettingsException(std::string str) {}
+	SettingsException(std::string str) : err(str) {}
+	std::string getMessage() {
+		return err;
+	}
 
 };
@@ -41,4 +46,9 @@
 			delete settingsManager;
 	}
+	std::string getActiveType() {
+		if (!settingsManager) {
+			return "";
+		} return settingsManager->getActiveType();
+	}
 
 	/**
Index: trunk/include/TSettings.h
===================================================================
--- trunk/include/TSettings.h	(revision 8b89aba942bc1a2492e1562596c052a8967b54c6)
+++ trunk/include/TSettings.h	(revision c8ebdecdf91a062ab9bbc91626e8ca60b3bce10e)
@@ -16,5 +16,5 @@
 	{
 	}
-
+	virtual std::string getActiveType() = 0;
 	virtual sectionList getSections(unsigned int bufferLength = BUFF_LEN) = 0;
 	virtual sectionList getSection(std::string section, unsigned int bufferLength = BUFF_LEN) = 0;
Index: trunk/include/config.h
===================================================================
--- trunk/include/config.h	(revision 8b89aba942bc1a2492e1562596c052a8967b54c6)
+++ trunk/include/config.h	(revision c8ebdecdf91a062ab9bbc91626e8ca60b3bce10e)
@@ -105,2 +105,7 @@
 #define MAIN_ALLOWED_HOSTS "allowed_hosts"
 #define MAIN_ALLOWED_HOSTS_DEFAULT "127.0.0.1"
+
+
+// Main Registry ROOT
+#define NS_HKEY_ROOT HKEY_LOCAL_MACHINE
+#define NS_REG_ROOT "SOFTWARE\\NSClient++"
