|
@@ -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 );
|
|
|
}
|
|
|
}
|
|
|
}
|