示例#1
0
        private static void RunIPCServer()
        {
            const string ChannelName = "PokudaSearchIPC";

            try {
                //チャンネルが存在しない場合は起動
                _serverChannel = new IpcServerChannel(ChannelName);
                ChannelServices.RegisterChannel(_serverChannel, true);
                AppObject.Logger.Info(_serverChannel.GetChannelUri());

                //イベントを登録
                _shareInfo           = new IPCShareInfo();
                _shareInfo.ProcessId = Process.GetCurrentProcess().Id;
                _shareInfo.OnSend   += new IPCShareInfo.CallEventHandler(ShareInfo_OnSend);
                RemotingServices.Marshal(_shareInfo, "path", typeof(IPCShareInfo));
            } catch {
                //スルー
            }
        }
示例#2
0
        static void Main()
        {
            //デスクトップをデフォルトとする。
            string defaultPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            string[] args = System.Environment.GetCommandLineArgs();
            if (args.Length > 2)
            {
                string option  = args[1].ToLower();
                string tmpPath = StringUtil.NullToBlank(args[2]);
                if (option == FilerOption)
                {
                    if (Directory.Exists(tmpPath))
                    {
                        //引数のパスでファイラを起動
                        defaultPath = tmpPath;
                    }
                }
                else if (option == SingleFilerOption ||
                         option == SingleFilerMainOption ||
                         option == SingleFilerSubOption)
                {
                    //既にプロセスが存在するか?
                    var processArray = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
                    if (processArray.Length > 1)
                    {
                        //すでに起動している場合は、パスを渡して終了。

                        //プロセス間通信
                        var clientChannel = new IpcClientChannel();
                        ChannelServices.RegisterChannel(clientChannel, true);

                        var          url       = "ipc://PokudaSearchIPC/path";
                        IPCShareInfo shareInfo = (IPCShareInfo)Activator.GetObject(typeof(IPCShareInfo), url);
                        User32.SetForegroundWindow(Process.GetProcessById(shareInfo.ProcessId).MainWindowHandle);
                        shareInfo.SendInfo(option, tmpPath);

                        return;
                    }
                    else
                    {
                        if (Directory.Exists(tmpPath))
                        {
                            //引数のパスでファイラを起動
                            defaultPath = tmpPath;
                        }
                    }
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //x86,x64 dllの切替処理
            AppDomain.CurrentDomain.AssemblyResolve += Resolver;

            //起動時に初期処理
            InitializeAnalyzer();
            if (Properties.Settings.Default.RunIPC)
            {
                RunIPCServer();
            }

            Microsoft.Win32.SystemEvents.PowerModeChanged +=
                new Microsoft.Win32.PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);

            AppObject.DefaultPath = defaultPath;
            AppObject.BootMode    = AppObject.BootModes.Filer;

            AppObject.Frame = new MainFrameForm();
            Application.Run(AppObject.Frame);
        }