Napisałem sobie dodawanie pliku do autostartu, i jest problem. Pobiera on od 54,000k do 76,000k Zużycia Pamięci (CPU)...
Oto mój kod. Jest tutaj tylko autorun i właśnie on tyle pobiera...:
[code]
using System;
using System
.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.Win32;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static void startup()
{
string source = Application.ExecutablePath.ToString();
string destination = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
destination = System.IO.Path.Combine(destination, "Programik.exe");
try
{
System.IO.File.Copy(source, destination, false);
source = destination;
}
catch
{
}
try
{
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
if (registryKey.GetValue("NowyProgram") == null)
{
registryKey.SetValue("NowyProgram", destination);
}
registryKey.Close();
}
catch
{
}
}
private void Form1_Load(object sender, EventArgs e)
{
startup();
}
}
}
[/code]
Kod ogolnie działa, dodaje plik do autostartu, po uruchomieniu włącza sie program, ale zużycie procesora jest takie jak podałem wyżej.
Ma ktoś jakiś pomysł, jak to przepisać? Albo poda gotowy kod z którego korzysta i zabiera on mało CPU?