@ -1,6 +1,5 @@
using CleanFlashCommon ;
using CleanFlashCommon ;
using System ;
using System ;
using System.Text ;
using System.Collections.Generic ;
using System.Collections.Generic ;
using System.IO ;
using System.IO ;
using System.Reflection ;
using System.Reflection ;
@ -8,29 +7,20 @@ using System.Diagnostics;
using SharpCompress.Archives.SevenZip ;
using SharpCompress.Archives.SevenZip ;
using SharpCompress.Common ;
using SharpCompress.Common ;
using SharpCompress.Readers ;
using SharpCompress.Readers ;
using System.Runtime.InteropServices ;
using IWshRuntimeLibrary ;
namespace CleanFlashInstaller {
namespace CleanFlashInstaller {
public class Installer {
public class Installer {
public static void RegisterActiveX ( string filename ) {
public static void RegisterActiveX ( string filename ) {
string relativeFilename = Path . GetFileName ( filename ) ;
Directory . SetCurrentDirectory ( Path . GetDirectoryName ( filename ) ) ;
ProcessStartInfo info = new ProcessStartInfo {
ExitedProcess process = ProcessUtils . RunProcess (
new ProcessStartInfo {
FileName = "regsvr32.exe" ,
FileName = "regsvr32.exe" ,
Arguments = "/s " + Path . GetFileName ( filename ) ,
UseShellExecute = false ,
UseShellExecute = false ,
CreateNoWindow = true
CreateNoWindow = true
} ;
Directory . SetCurrentDirectory ( Path . GetDirectoryName ( filename ) ) ;
info . Arguments = "/s /u " + relativeFilename ;
ExitedProcess process = ProcessUtils . RunProcess ( info ) ;
if ( ! process . IsSuccessful ) {
throw new InstallException ( string . Format ( "Failed to unregister ActiveX plugin: error code {0}\n\n{1}" , process . ExitCode , process . Output ) ) ;
}
}
) ;
info . Arguments = "/s " + relativeFilename ;
process = ProcessUtils . RunProcess ( info ) ;
if ( ! process . IsSuccessful ) {
if ( ! process . IsSuccessful ) {
throw new InstallException ( string . Format ( "Failed to register ActiveX plugin: error code {0}\n\n{1}" , process . ExitCode , process . Output ) ) ;
throw new InstallException ( string . Format ( "Failed to register ActiveX plugin: error code {0}\n\n{1}" , process . ExitCode , process . Output ) ) ;
@ -85,24 +75,16 @@ namespace CleanFlashInstaller {
}
}
public static void CreateShortcut ( string folder , string executable , string name , string description ) {
public static void CreateShortcut ( string folder , string executable , string name , string description ) {
Type t = Type . GetTypeFromCLSID ( new Guid ( "72C24DD5-D70A-438B-8A42-98424B88AFB8" ) ) ;
WshShell wsh = new WshShell ( ) ;
dynamic shell = Activator . CreateInstance ( t ) ;
IWshShortcut shortcut = wsh . CreateShortcut ( Path . Combine ( folder , name + ".lnk" ) ) as IWshShortcut ;
try {
shortcut . Arguments = "" ;
var lnk = shell . CreateShortcut ( Path . Combine ( folder , name + ".lnk" ) ) ;
shortcut . TargetPath = executable ;
shortcut . WindowStyle = ( int ) WshWindowStyle . WshNormalFocus ;
try {
shortcut . Description = description ;
lnk . TargetPath = executable ;
shortcut . WorkingDirectory = Path . GetDirectoryName ( executable ) ;
lnk . IconLocation = executable ;
shortcut . IconLocation = executable ;
lnk . Description = description ;
shortcut . Save ( ) ;
lnk . WorkingDirectory = folder ;
lnk . Save ( ) ;
} finally {
Marshal . FinalReleaseComObject ( lnk ) ;
}
} finally {
Marshal . FinalReleaseComObject ( shell ) ;
}
}
}
private static void InstallFromArchive ( SevenZipArchive archive , IProgressForm form , InstallFlags flags ) {
private static void InstallFromArchive ( SevenZipArchive archive , IProgressForm form , InstallFlags flags ) {