الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كود يمكن تطويره ليكشف مهارتك

مغلق
بدأه mossa في 27 أبريل 2005 · 0 رد · 372 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1

كتبت هذا الكود لبرنامج anti-virus ليجلب الملفات الشغالة وملفات بدء التشغيل ولكن هناك مشكلة

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;
using System.IO;
using Microsoft.Win32;

namespace myProcess
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
  private System.Windows.Forms.ListBox listBox1;
  private System.Windows.Forms.Button button1;
  /// <summary>
  /// Required designer variable.
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Form1()
  {
 	 //
 	 // Required for Windows Form Designer support
 	 //
 	 InitializeComponent();

 	 //
 	 // TODO: Add any constructor code after InitializeComponent call
 	 //
  }

  /// <summary>
  /// Clean up any resources being used.
  /// </summary>
  protected override void Dispose( bool disposing )
  {
 	 if( disposing )
 	 {
    if (components != null) 
    {
   	 components.Dispose();
    }
 	 }
 	 base.Dispose( disposing );
  }

  #region Windows Form Designer generated code
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {
 	 this.listBox1 = new System.Windows.Forms.ListBox();
 	 this.button1 = new System.Windows.Forms.Button();
 	 this.SuspendLayout();
 	 // 
 	 // listBox1
 	 // 
 	 this.listBox1.Dock = System.Windows.Forms.DockStyle.Bottom;
 	 this.listBox1.Location = new System.Drawing.Point(0, 35);
 	 this.listBox1.Name = "listBox1";
 	 this.listBox1.Size = new System.Drawing.Size(536, 459);
 	 this.listBox1.TabIndex = 0;
 	 // 
 	 // button1
 	 // 
 	 this.button1.Location = new System.Drawing.Point(464, 8);
 	 this.button1.Name = "button1";
 	 this.button1.Size = new System.Drawing.Size(64, 24);
 	 this.button1.TabIndex = 1;
 	 this.button1.Text = "Fill";
 	 this.button1.Click += new System.EventHandler(this.button1_Click);
 	 // 
 	 // Form1
 	 // 
 	 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
 	 this.ClientSize = new System.Drawing.Size(536, 494);
 	 this.Controls.Add(this.button1);
 	 this.Controls.Add(this.listBox1);
 	 this.Name = "Form1";
 	 this.Text = "Form1";
 	 this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// The main entry point for the application.
  /// </summary>
  [STAThread]
  static void Main() 
  {
 	 Application.Run(new Form1());
  }

  private void button1_Click(object sender, System.EventArgs e)
  {
 	 this.Cursor = Cursors.WaitCursor;
 	 listBox1.Items.Clear();
 	 foreach(Process a in Process.GetProcesses())
 	 {
    try
    {
   	 if (File.Exists(a.MainModule.FileName))
   	 listBox1.Items.Add(a.MainModule.FileName);
    }
    catch{}
 	 }
           
 	 RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
 	 string[] val = rk.GetValueNames();
 	 string[] file = new string[val.Length];
 	 for (int i = 0; i < val.Length; i++)
 	 {
    file = (string)rk.GetValue(val);
 	 }
 	 foreach(string g in file)
 	 {
    string r = get_file(g);
    if (r != "")
   	 listBox1.Items.Add(r);

 	 }

 	 rk.Close();

 	 rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
 	 string[] val1 = rk.GetValueNames();
 	 string[] file1 = new string[val1.Length];
 	 for (int i = 0; i < val1.Length; i++)
 	 {
    file1 = (string)rk.GetValue(val1);
 	 }
 	 foreach(string g in file1)
 	 {
    string r = get_file(g);
    if (r != "")
   	 listBox1.Items.Add(r);

 	 }

 	 rk.Close();

 	 this.Cursor = Cursors.Default;

  }
  private string get_file(string file)
  {
 	 if (file[0] == '"')
 	 {
    file = file.Substring(1);
    int pos = file.IndexOf('"');
    file = file.Substring(0, pos );
    return (File.Exists(file)? file: "");
 	 }
 	 else if (!File.Exists(file))
 	 {
    int pos = file.Length-1;
    
    while (!File.Exists(file) && (pos > 0))
    {
   	 pos = file.LastIndexOf(' ', pos) - 1;
   	 file = file.Substring(0, (pos > 0)? pos + 1 : 0);
    }
    return file;
 	 }
 	 else
    return file;
  }
	}
}

والمشكله هي وجود ملفات مسجلة مع معاملاتها (كيف أطور الكود أكثر ليمكنه)

معرفة الملفات التي تكتب بدون مسار

مثل

rundll.exe -bluetooth

وهناك العديد من المشاكل إذا أردتم حلها

مثل كيفية قراءة إختصارات0 windows ذات الإمتداد lnk لإيجاد الملف المشار إلية

وشكراً

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر ساعة · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…