コード例 #1
0
        public static void Main(string[] args)
        {
            try
            {
                Application.ThreadException += Application_ThreadException;
                AppDomain.CurrentDomain.UnhandledException +=
                    CurrentDomain_UnhandledException;

                if (args.Length > 0)
                {
                    const string search = "--file=";

                    if (args[0].IndexOf(search) == 0)
                    {
                        string path = String.Join(" ", args);

                        path = path.Substring(search.Length, path.Length - search.Length);

                        try
                        {
                            DriveService.OpenGoogleDoc(path);
                        }
                        catch (Exception exception)
                        {
                            Log.Error(exception, false);
                        }

                        return;
                    }
                }

                Log.Information("Starting DriveProxy.Service.exe");

                if (ServicePipe.IsServerRunning(true))
                {
                    throw new LogException(ServicePipe.ProcessName + " is already running.", false, false);
                }

                Debugger.Launch();

                DriveService.Init();

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

                MainForm = new MainForm();

                Application.Run(MainForm);
            }
            catch (Exception exception)
            {
                Log.Error(exception, false);
            }
            finally
            {
                Log.Warning("Exiting DriveProxy.Service.exe");
            }
        }