2025-03-28 09:49:56 +08:00

92 lines
3.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SuperMap.RealEstate.SecurityDevice.Setup.npPlugin
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
void CreateCommandLine_CopyFile(string targetPath, StreamWriter stringBuilder)
{
string _sourcePath = Environment.CurrentDirectory + "\\";
string _targetPath = targetPath;// +_targetDirectory;
if (!Directory.Exists(_targetPath))
Directory.CreateDirectory(_targetPath);
stringBuilder.WriteLine("echo 正在复制文件到" + _targetPath + "...");
string[] _SourceFileCollection = new string[]
{
"npsyunew6.dll"//, "SecurityDevice.Core.dll","SecurityDevice.Plugin.dll",
//"SecurityDevice.Plugin.dll","SecurityDevice.UsbKey.dll"
};
foreach (string _FileName in _SourceFileCollection)
stringBuilder.WriteLine("copy /y " + _FileName + " \"" + _targetPath + "\"");
}
private void buttonSetup_Click(object sender, EventArgs e)
{
Install();
}
public void Install()
{
try
{
ShowMessageDesc(Environment.Is64BitProcess ? "MozillaPlugins[x64_SysWOW32]" : "MozillaPlugins[x86]");
Environment.SpecialFolder _SpecialFolder = Environment.Is64BitProcess ? Environment.SpecialFolder.SystemX86 : Environment.SpecialFolder.System;
string _sourcePath = Environment.CurrentDirectory + "\\npsyunew6.dll";
string _targetPath = Environment.GetFolderPath(_SpecialFolder) + "\\npsyunew6.dll";
ShowMessageDesc("正在复制文件...");
ShowMessageDesc(_targetPath);
File.Copy(_sourcePath, _targetPath, true);
ShowMessageDesc("复制1个文件");
ShowMessageDesc("正在写入注册表...");
string _registryPath = Environment.Is64BitProcess ? "Wow6432Node\\MozillaPlugins\\@RealEstate/npSecurityDevice" : "MozillaPlugins\\@RealEstate/npSecurityDevice";
RegistryHelper.Write(_registryPath, "Path", _targetPath);
_registryPath += "\\MimeTypes\\application/npsyunew6-plugin";
RegistryHelper.Write(_registryPath, "Description", "usbkey2000的Chrome和FireFox插件");
ShowMessageDesc("完成");
}
catch (Exception ex)
{
MessageBox.Show("如果您关闭Chrome或FireFox浏览器\r\n"+ex.Message);
//Application.Exit();
Environment.ExitCode = 2;
}
}
void ShowMessageDesc(string value)
{
textBoxResult.AppendText(value + "\n");
Application.DoEvents();
}
public string Log
{
get
{
return textBoxResult.Text;
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}