/[MorrowindCustomClothingSlotCreator]/trunk/MorrowindCustomClothingSlotCreator/MorrowindPathHelper.cs
ViewVC logotype

Contents of /trunk/MorrowindCustomClothingSlotCreator/MorrowindPathHelper.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations) (download)
Fri Jul 29 09:23:17 2011 UTC (8 years, 11 months ago) by william
File size: 2094 byte(s)
** initial commit
: have everything working (upto determining if the plugin is a valid TES3:morrowind esm or esp)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.Win32;
6
7 namespace MorrowindCustomClothingSlotCreator
8 {
9 public interface IMorrowindPathHelper
10 {
11 string MorrowindInstallPath { get; }
12 }
13 public class MorrowindPathHelper : IMorrowindPathHelper
14 {
15 private const string REGKEY_INSTALLL_PATH = "Installed Path";
16 private const string REGKEY_32BIT = @"HKEY_LOCAL_MACHINE\Software\Bethesda Softworks\Morrowind\";
17 private const string REGKEY_64BIT = @"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Bethesda Softworks\Morrowind\";
18 private const string REGKEY_ARCHITECTURE = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\";
19 private const string REGKEY_ARCHITECTURE_KEY = "PROCESSOR_ARCHITECTURE";
20
21 public MorrowindPathHelper()
22 {
23 switch (GetOSProcessorArchitecture())
24 {
25 case "x86": this.MorrowindInstallPath = (string)Registry.GetValue(REGKEY_32BIT, REGKEY_INSTALLL_PATH, false); break;
26 case "x64": this.MorrowindInstallPath = (string)Registry.GetValue(REGKEY_64BIT, REGKEY_INSTALLL_PATH, false); break;
27 case "AMD64": this.MorrowindInstallPath = (string)Registry.GetValue(REGKEY_64BIT, REGKEY_INSTALLL_PATH, false); break;
28 default: this.MorrowindInstallPath = ""; break;
29 }
30 }
31
32 private string GetOSProcessorArchitecture()
33 {
34 string Architecture = (string)Registry.GetValue(REGKEY_ARCHITECTURE, REGKEY_ARCHITECTURE_KEY, "x86");
35
36
37 if (Architecture == "x86")
38 {
39 return "x86";
40 }
41 else
42 {
43 return "x64";
44 }
45 }
46
47 #region IMorrowindPathHelper Members
48 private string _MorrowindInstallPath;
49 public string MorrowindInstallPath { get { return _MorrowindInstallPath; } set { _MorrowindInstallPath = value; } }
50 #endregion
51 }
52 }

  ViewVC Help
Powered by ViewVC 1.1.22