Jelajahi Sumber

support for wide characters when using reipatcher setup

Scrublord1336 6 tahun lalu
induk
melakukan
fda09cf990

+ 16 - 7
src/XUnity.AutoTranslator.Setup/Program.cs

@@ -2,13 +2,13 @@
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
-using IWshRuntimeLibrary;
 using XUnity.AutoTranslator.Setup.Properties;
 
 namespace XUnity.AutoTranslator.Setup
 {
    class Program
    {
+      [STAThread]
       static void Main( string[] args )
       {
          var gamePath = Environment.CurrentDirectory;
@@ -122,13 +122,22 @@ namespace XUnity.AutoTranslator.Setup
       public static void CreateShortcut( string shortcutName, string shortcutPath, string targetFileLocation )
       {
          string shortcutLocation = Path.Combine( shortcutPath, shortcutName );
-         WshShell shell = new WshShell();
-         IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut( shortcutLocation );
 
-         shortcut.WorkingDirectory = Path.GetDirectoryName( targetFileLocation );
-         shortcut.TargetPath = targetFileLocation;
-         shortcut.Arguments = "-c \"" + Path.GetFileNameWithoutExtension( shortcutName ) + ".ini\"";
-         shortcut.Save();
+         // Create empty .lnk file
+         File.WriteAllBytes( shortcutName, new byte[ 0 ] );
+
+         // Create a ShellLinkObject that references the .lnk file
+         Shell32.Shell shl = new Shell32.Shell();
+         Shell32.Folder dir = shl.NameSpace( Path.GetDirectoryName( shortcutLocation ) );
+         Shell32.FolderItem itm = dir.Items().Item( shortcutName );
+         Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)itm.GetLink;
+
+         // Set the .lnk file properties
+         lnk.Path = targetFileLocation;
+         lnk.Arguments = "-c \"" + Path.GetFileNameWithoutExtension( shortcutName ) + ".ini\"";
+         lnk.WorkingDirectory = Path.GetDirectoryName( targetFileLocation );
+
+         lnk.Save( shortcutName );
       }
    }
 }

+ 3 - 3
src/XUnity.AutoTranslator.Setup/XUnity.AutoTranslator.Setup.csproj

@@ -8,15 +8,15 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <COMReference Include="IWshRuntimeLibrary.dll">
-      <Guid>f935dc20-1cf0-11d0-adb9-00c04fd58a0b</Guid>
+    <COMReference Include="Shell32.dll">
+      <Guid>50a7e9b0-70ef-11d1-b75a-00a0c90564fe</Guid>
       <VersionMajor>1</VersionMajor>
       <VersionMinor>0</VersionMinor>
       <WrapperTool>tlbimp</WrapperTool>
       <Lcid>0</Lcid>
       <Isolated>false</Isolated>
-      <Private>false</Private>
       <EmbedInteropTypes>true</EmbedInteropTypes>
+      <Private>false</Private>
     </COMReference>
   </ItemGroup>