diff options
| author | Alex-TIMEHACK <[email protected]> | 2017-07-01 22:17:57 +0100 |
|---|---|---|
| committer | Alex-TIMEHACK <[email protected]> | 2017-07-01 22:17:57 +0100 |
| commit | da6e7a7e8b3d8944d9139d4e2bb3ecfa2122840b (patch) | |
| tree | c980ac4786a2528a9d98290f099c8a388dbfad9a /TimeHACK.Engine | |
| parent | 971683c5f7116d754d209a9debac8e0a214889dc (diff) | |
| download | histacom2-da6e7a7e8b3d8944d9139d4e2bb3ecfa2122840b.tar.gz histacom2-da6e7a7e8b3d8944d9139d4e2bb3ecfa2122840b.tar.bz2 histacom2-da6e7a7e8b3d8944d9139d4e2bb3ecfa2122840b.zip | |
Moar stuff
Diffstat (limited to 'TimeHACK.Engine')
| -rw-r--r-- | TimeHACK.Engine/FileAssociation.cs | 50 | ||||
| -rw-r--r-- | TimeHACK.Engine/SaveSystem.cs | 24 | ||||
| -rw-r--r-- | TimeHACK.Engine/StartMenuBackend.cs | 48 | ||||
| -rw-r--r-- | TimeHACK.Engine/TimeHACK.Engine.csproj | 2 |
4 files changed, 74 insertions, 50 deletions
diff --git a/TimeHACK.Engine/FileAssociation.cs b/TimeHACK.Engine/FileAssociation.cs new file mode 100644 index 0000000..25fe895 --- /dev/null +++ b/TimeHACK.Engine/FileAssociation.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.InteropServices; +using Microsoft.Win32; + +namespace TimeHACK.Engine +{ + public class FileAssociation + { + // Associate file extension with progID, description, icon and application + public static void Associate(string extension, + string progID, string description, string icon, string application) + { + Registry.ClassesRoot.CreateSubKey(extension).SetValue("", progID); + if (progID != null && progID.Length > 0) + using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(progID)) + { + if (description != null) + key.SetValue("", description); + if (icon != null) + key.CreateSubKey("DefaultIcon").SetValue("", ToShortPathName(icon)); + if (application != null) + key.CreateSubKey(@"Shell\Open\Command").SetValue("", + ToShortPathName(application) + " \"%1\""); + } + } + + // Return true if extension already associated in registry + public static bool IsAssociated(string extension) + { + return (Registry.ClassesRoot.OpenSubKey(extension, false) != null); + } + + [DllImport("Kernel32.dll")] + private static extern uint GetShortPathName(string lpszLongPath, + [Out] StringBuilder lpszShortPath, uint cchBuffer); + + // Return short path format of a file name + private static string ToShortPathName(string longName) + { + StringBuilder s = new StringBuilder(1000); + uint iSize = (uint)s.Capacity; + uint iRet = GetShortPathName(longName, s, iSize); + return s.ToString(); + } + } +} diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs index e217bf4..7a6eed0 100644 --- a/TimeHACK.Engine/SaveSystem.cs +++ b/TimeHACK.Engine/SaveSystem.cs @@ -14,6 +14,8 @@ namespace TimeHACK.Engine public static FileSystemFolderInfo filesystemflinfo { get; set; } public static Boolean DevMode = false; + public static FileAssociation IconChanger = new FileAssociation(); + public static string GameDirectory { get @@ -118,7 +120,7 @@ namespace TimeHACK.Engine save.ExperiencedStories = new List<string>(); save.CurrentOS = "95"; CurrentSave = save; - + CheckFiles(); SaveGame(); } @@ -143,6 +145,26 @@ namespace TimeHACK.Engine if (CurrentSave.CurrentOS != "95") SaveDirectoryInfo(ProfileSettingsDirectory, false, "Documents and Settings", true); SaveDirectoryInfo(ProfileProgramsDirectory, true, "Program Files", true); SaveDirectoryInfo(ProfileWindowsDirectory, true, "Windows", true); + + CreateWindowsDirectory(); + } + + public static void CreateWindowsDirectory() + { + SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "System"), true, "System", true); + SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Config"), true, "Config", true); + SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Cursors"), true, "Cursors", true); + SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Fonts"), true, "Fonts", true); + SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Help"), true, "Help", true); + SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Temp"), true, "Temp", true); + + CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "Calc.exe"), "Calculator"); + CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "explorer.exe"), "windowsexplorer"); + } + + public static void CreateWindowsFile(String filepath, String contents) + { + File.WriteAllText(filepath, contents); } public static void SaveDirectoryInfo(String directory, Boolean isProtected, String label, Boolean allowback) diff --git a/TimeHACK.Engine/StartMenuBackend.cs b/TimeHACK.Engine/StartMenuBackend.cs deleted file mode 100644 index a500e0d..0000000 --- a/TimeHACK.Engine/StartMenuBackend.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace TimeHACK.Engine -{ - class StartMenuBackend - { - //public void CreateMenu(ref Panel thePanel, String OSStyle, Image SideImage) - //{ - // // Init the Start Menu - - // MenuStrip startmenuitems = new MenuStrip(); - // PictureBox sideimage = new PictureBox(); - - // switch (OSStyle) - // { - // case "95": - // case "98": - // case "2000": - // case "ME": - // sideimage.Image = SideImage; - // sideimage.Dock = DockStyle.Left; - // startmenuitems.Dock = DockStyle.Fill; - - // AddWinClassicItemsToMenuStrip(ref startmenuitems); - // break; - // } - - - //} - - //public void AddWinClassicItemsToMenuStrip(ref MenuStrip toAddTo) - //{ - // ToolStripMenuItem ProgramsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - // ToolStripMenuItem DocumentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - // ToolStripMenuItem SettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - // ToolStripMenuItem FindToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - // ToolStripMenuItem HelpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - //} - - - } -} diff --git a/TimeHACK.Engine/TimeHACK.Engine.csproj b/TimeHACK.Engine/TimeHACK.Engine.csproj index f9ed679..fef9500 100644 --- a/TimeHACK.Engine/TimeHACK.Engine.csproj +++ b/TimeHACK.Engine/TimeHACK.Engine.csproj @@ -48,9 +48,9 @@ <Compile Include="BSODCreator.cs" /> <None Include="packages.config" /> <None Include="Resources\WinClassic\Window\pjBg6mKP.bin" /> + <Compile Include="FileAssociation.cs" /> <Compile Include="FileDialogBoxManager.cs" /> <Compile Include="SaveSystem.cs" /> - <Compile Include="StartMenuBackend.cs" /> <Compile Include="TaskBarController.cs" /> <Compile Include="Template\Win9XBSOD.cs"> <SubType>Form</SubType> |
