Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define TESTINGde
- using System;
- using System.Collections.Generic;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Text;
- using System.Threading;
- using System.IO;
- using System.Net;
- using System.Diagnostics;
- using System.Xml;
- using System.Xml.Serialization;
- using System.Configuration;
- using System.Globalization;
- using System.Reflection;
- using System.Data.Common;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Drawing.Design;
- using System.Drawing.Printing;
- using System.Drawing.Imaging;
- using System.Deployment;
- using System.Deployment.Application;
- using Microsoft.Win32;
- namespace CopyPathShellUtility {
- static class Program {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args) {
- try {
- if (args.Length == 0) {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
- return;
- }
- for (int i = 0; i < args.Length; i++) {
- args[i] = "\"" + args[i] + "\"";
- }
- Clipboard.SetText(string.Join(Environment.NewLine, args));
- #if TESTING
- string msgOK = Clipboard.GetText();
- MessageBox.Show(
- Form.ActiveForm,
- msgOK,
- Application.ProductName,
- MessageBoxButtons.OK,
- MessageBoxIcon.Information,
- MessageBoxDefaultButton.Button1);
- #endif
- string regKey = @"HKEY_CURRENT_USER\Software\CopyPathShellUtility\";
- for (int i = 0; i < args.Length; i++) {
- #if TESTING
- Trace.TraceInformation(string.Format("Copied path {0} to clipboard", args[i]));
- #endif
- Registry.SetValue(regKey, args[0], DateTime.Now);
- }
- }
- catch (Exception ex) {
- string msgError = ex.ToString();
- MessageBox.Show(
- Form.ActiveForm,
- msgError,
- Application.ProductName,
- MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment