Remove the registery code from affdexme

This commit is contained in:
Abdelrahman Mahmoud 2015-09-04 11:06:45 -04:00
parent e1013e2a3a
commit 7ff285adcd

View file

@ -138,16 +138,6 @@ namespace AffdexMe
} }
private String GetClassifierDataFolder() private String GetClassifierDataFolder()
{
// First see if we can get the Install Path from the registry
RegistryKey rkCurrentUser = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
RegistryKey rkAffdexMe = rkCurrentUser.OpenSubKey("Software\\Affectiva\\AffdexMe");
String classifierPath = String.Empty;
if (rkAffdexMe != null && !String.IsNullOrEmpty((String)rkAffdexMe.GetValue("Install Directory")))
{
classifierPath = (String)rkAffdexMe.GetValue("Install Directory") + "\\data";
}
else
{ {
String affdexClassifierDir = Environment.GetEnvironmentVariable("AFFDEX_DATA_DIR"); String affdexClassifierDir = Environment.GetEnvironmentVariable("AFFDEX_DATA_DIR");
if (String.IsNullOrEmpty(affdexClassifierDir)) if (String.IsNullOrEmpty(affdexClassifierDir))
@ -158,7 +148,6 @@ namespace AffdexMe
{ {
classifierPath = affdexClassifierDir; classifierPath = affdexClassifierDir;
} }
}
DirectoryInfo directoryInfo = new DirectoryInfo(classifierPath); DirectoryInfo directoryInfo = new DirectoryInfo(classifierPath);
if (!directoryInfo.Exists) if (!directoryInfo.Exists)
@ -171,22 +160,12 @@ namespace AffdexMe
private String GetAffdexLicense() private String GetAffdexLicense()
{ {
// First see if we can get the License from the registry
RegistryKey rkCurrentUser = Registry.LocalMachine;
RegistryKey rkAffdexMe = rkCurrentUser.OpenSubKey("Software\\Affectiva\\AffdexMe");
String licensePath = String.Empty; String licensePath = String.Empty;
if ( rkAffdexMe != null && !String.IsNullOrEmpty((string)rkAffdexMe.GetValue("Install Directory")))
{
licensePath = (String)rkAffdexMe.GetValue("Install Directory");
}
else
{
licensePath = Environment.GetEnvironmentVariable("AFFDEX_LICENSE_DIR"); licensePath = Environment.GetEnvironmentVariable("AFFDEX_LICENSE_DIR");
if (String.IsNullOrEmpty(licensePath)) if (String.IsNullOrEmpty(licensePath))
{ {
ShowExceptionAndShutDown("AFFDEX_LICENSE_DIR environment variable (Affdex License Folder) is not set"); ShowExceptionAndShutDown("AFFDEX_LICENSE_DIR environment variable (Affdex License Folder) is not set");
} }
}
// Test the directory // Test the directory
DirectoryInfo directoryInfo = new DirectoryInfo(licensePath); DirectoryInfo directoryInfo = new DirectoryInfo(licensePath);
@ -195,7 +174,7 @@ namespace AffdexMe
ShowExceptionAndShutDown("AFFDEX_License_DIR (Affex License Folder) is set to an invalid folder location"); ShowExceptionAndShutDown("AFFDEX_License_DIR (Affex License Folder) is set to an invalid folder location");
} }
return licensePath + "\\affdex.license"; return licensePath;
} }
public MainWindow() public MainWindow()