예제 #1
0
        static void Main(string[] args)
        {
            string dll = FindKeePassCommandDll();

            if (dll == null)
            {
                Console.WriteLine("Error locating KeePassCommandDll.dll");
                Environment.Exit(1);
                return;
            }
            KeePassEntry.Initialize(dll);

            KeePassEntry entry = null;
            string       title = "Sample Entry";

            try
            {
                entry = KeePassEntry.getfirst(title);
            }
            catch { }
            if (entry == null)
            {
                Console.WriteLine("KeePass is not started");
                Console.WriteLine("Has KeePassCommander.dll been copied to the directory containing KeePass.exe ?");
                Environment.Exit(2);
                return;
            }
            if (entry.Title != title)
            {
                Console.WriteLine("KeePass Entry not found: " + title);
                Environment.Exit(3);
            }

            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Console.WriteLine();
            Console.WriteLine("title     : " + entry.Title);
            Console.WriteLine("username  : "******"password  : "******"url       : " + entry.Url);
            Console.WriteLine("urlscheme : " + entry.UrlScheme);
            Console.WriteLine("urlhost   : " + entry.UrlHost);
            Console.WriteLine("urlport   : " + entry.UrlPort);
            Console.WriteLine("urlpath   : " + entry.UrlPath);
            Console.WriteLine("notes     : " + entry.Notes);
            Environment.Exit(0);
        }