Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

  • 6 odgovora
  • 5.514 pregleda

Najnovija ↓

Re: Startup aplikacije pri pokretanju OS-a 23.07.2008. u 19:34 · pre 222 meseca #2
Moze preko registry-a. Koristi sledeci property:

Code:

using Microsoft.Win32;

....

        public bool StartWithWindows
        {
            get
            {
                bool startWithWindows = false;
                try {
                    RegistryKey key = Registry.LocalMachine.CreateSubKey(key_startup);
                    if(key != null) {
                        string fileName = Convert.ToString(key.GetValue(value_startup, ""));
                        if(fileName == Application.ExecutablePath) {
                            startWithWindows = true;
                        } else {
                            key.DeleteValue(value_startup);
                        }
                    }
                } catch { }
                return startWithWindows;
            }
            set
            {
                try {
                    RegistryKey key = Registry.LocalMachine.CreateSubKey(key_startup);
                    if(key != null) {
                        if(value) {
                            key.SetValue(value_startup, Application.ExecutablePath);
                        } else {
                            key.DeleteValue(value_startup);
                        }
                    }
                } catch { }
            }
        }

        private string key_startup = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
        private string value_startup = System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath);

Kada mu stavis vrednost na true u registriju ce biti upisano da se aplikacija pokrene pri podizanju windowsa.
Re: Startup aplikacije pri pokretanju OS-a 23.07.2008. u 19:42 · pre 222 meseca #3
Imas u Windows desktop forumu temu o nacinima da se neka tema pokrece pri startup-u. Pogledaj tamo a onda samo implementiraj neki od tih nacina.
Potpis
Nebojsa Milanovic:
-Trumpa smatram vrhunskim predsednikom i voleo bih da živim u državi na čijem je on čelu
-Rusija ne laže, ne vodi osvajačke ratove
-Trump je svetla tačka u USA blatu
-Elon Musk, možda najpametniji i najtrezveniji Amerikanac
Re: Startup aplikacije pri pokretanju OS-a 25.07.2008. u 11:52 · pre 222 meseca
izmenjeno 1 put, poslednji put mega_michulin 25.07.2008. u 12:39
  1. mega_michulin25.07.2008. u 12:39zapis iz teksta poruke
#4
Unija san kod u aplikaciju i sve radi kako triba,zahvaljujen se svima na pomoci.
Re: Startup aplikacije pri pokretanju OS-a 25.07.2008. u 13:10 · pre 222 meseca #5
DarkMan ima bi jos jednu zamolbu.
Jeli znas mozda kako da modificiran kod koji si mi dao tako da aplikacija kad se pokrene, nepokrene se na desktopu vec da bude samo kao ikonica u donjem desnom kutu(system tray-u).
Re: Startup aplikacije pri pokretanju OS-a 25.07.2008. u 15:48 · pre 222 meseca #6
Evo ti mali primer za koriscenje tray ikone i koji u sebi sadrzi gore dati kod za pokretanje programa pri podizanju windowsa.

Code:

using System;
using System.Drawing;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using Microsoft.Win32;

namespace WindowsApplication1
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ContextMenuStrip cm = new ContextMenuStrip();
            cm.Items.Add("About...", null, new EventHandler(OnAbout));
            cm.Items.Add("-");
            cm.Items.Add("Configuration...", null, new EventHandler(OnConfiguration));
            cm.Items.Add("-");
            menuStartWithWindows = cm.Items.Add("Start With Windows", null, new EventHandler(OnStartWithWindows)) as ToolStripMenuItem;
            cm.Items.Add("-");
            cm.Items.Add("Exit", null, new EventHandler(OnExit));
            cm.Opening += new System.ComponentModel.CancelEventHandler(OnMenuOpening);

            NotifyIcon notifyIcon = new NotifyIcon();
            notifyIcon.ContextMenuStrip = cm;
            notifyIcon.Icon = Properties.Resources.app_icon;
            notifyIcon.MouseDoubleClick += new MouseEventHandler(OnAbout);
            notifyIcon.Visible = true;
            notifyIcon.Text = "Test";

            Application.Run();
            notifyIcon.Visible = false;
            notifyIcon.Dispose();
        }
        private static ToolStripMenuItem menuStartWithWindows = null;

        private static void OnAbout(object sender, EventArgs e)
        {
            MessageBox.Show("Test", "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private static void OnConfiguration(object sender, EventArgs e)
        {
            Form form = new Form();
            form.ShowDialog();
            form.Dispose();
        }

        private static void OnMenuOpening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            menuStartWithWindows.Checked = Program.StartWithWindows;
        }

        private static void OnStartWithWindows(object sender, EventArgs e)
        {
            Program.StartWithWindows = !Program.StartWithWindows;
        }

        private static void OnExit(object sender, EventArgs e)
        {
            Application.Exit();
        }

        public static bool StartWithWindows
        {
            get
            {
                bool startWithWindows = false;
                try {
                    RegistryKey key = Registry.LocalMachine.CreateSubKey(key_startup);
                    if(key != null) {
                        string fileName = Convert.ToString(key.GetValue(value_startup, ""));
                        if(fileName == Application.ExecutablePath) {
                            startWithWindows = true;
                        } else {
                            key.DeleteValue(value_startup);
                        }
                    }
                } catch { }
                return startWithWindows;
            }
            set
            {
                try {
                    RegistryKey key = Registry.LocalMachine.CreateSubKey(key_startup);
                    if(key != null) {
                        if(value) {
                            key.SetValue(value_startup, Application.ExecutablePath);
                        } else {
                            key.DeleteValue(value_startup);
                        }
                    }
                } catch { }
            }
        }

        private static string key_startup = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
        private static string value_startup = System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath);
    }
}
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme