예제 #1
0
   String
   IniFileSettings::GetInitializationFile() 
   {
      if (m_sIniFile.IsEmpty())
      {

         String AppPath = Utilities::GetExecutableDirectory();

         m_sIniFile = AppPath;

         if (m_sIniFile.Right(1) != _T("\\"))
            m_sIniFile += "\\";

         m_sIniFile += "hMailServer.ini";

#ifdef _DEBUG

         if (!FileUtilities::Exists(m_sIniFile))
         {
            // We're running in debug. Since the hMailServer.ini is not copied to 
            // the Source\hMailServer\Debug directory, we need to locate it.
            //
            // We assume that the install location specified in the registry is
            // the current one.
            //
            String installPath;

            Registry registry;
            if (registry.GetStringValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\hMailServer", "InstallLocation", installPath))
            {
               m_sIniFile = 
                  FileUtilities::Combine(installPath, "Bin\\hMailServer.ini");
            }


         }

#endif
      }

      return m_sIniFile;
   }
예제 #2
0
   String
   Utilities::GetBinDirectory()
   {
      // The install key in the registry should be enough to tell us where we're installed.
      String install_path;
      Registry registry;

      if (registry.GetStringValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\hMailServer", "InstallLocation", install_path))
      {
         return FileUtilities::Combine(install_path, "Bin");
      }
      else
      {

         // Lookup executable path.
         String executable_full_path = Application::GetExecutableName();
         int last_slash = executable_full_path.ReverseFind(_T("\\"));

         return executable_full_path.Mid(0, last_slash);
      }
   }