ویژوال 30 شارپ

سورس کدهای جالب سی شارپ فقط با یک نگاه

ویژوال 30 شارپ

سورس کدهای جالب سی شارپ فقط با یک نگاه

نمایش حجم درایو ها به صورت گرافیکی در ListView

 این کد فوق العاده زیبا و آسون هست.

این کد یه لیست ویو (ListView) داره که حجم درایوهای کامپیوترتان را به شکل چند تا نمودار دایره ای (به تعداد درایو ها) رسم می کنه. 

سعی کردم خیلی آسون بنویسمش. البته همون کد قبلیه فقط یکم تغییرش دادم.  

امیدوارم رضایت شما رو جلب کند. 

 

http://s1.picofile.com/file/6123689134/DriveSizeViewer_Listview.mp3.html

نمایش حجم درایو

کدی که امروز خدمتتان آوردم حجم درایو انتخاب شده رو به شکل یک نمودار دایره ای نشان می دهد.

دانلود کنید که واقعا قشنگه (آسون هم هست).


http://s1.picofile.com/file/6123690140/DriveSizeViewer.mp3.html

Reg Editor

// Create SubKey
Registry.LocalMachine.CreateSubKey(@"Software\Sinpin", RegistryKeyPermissionCheck.ReadWriteSubTree);

//Create Key and Set Value
RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"Software\Sinpin", true);      
reg.SetValue("DWord", "1", RegistryValueKind.DWord);
reg.SetValue("ExpandString", "1", RegistryValueKind.ExpandString);
reg.SetValue("QWord", "1", RegistryValueKind.QWord);
reg.SetValue("String", "1", RegistryValueKind.String);
reg.SetValue("Unknown", "1", RegistryValueKind.Unknown);

// Delete Key
reg.DeleteValue("DWOrd");

// Delete SubKey
Registry.LocalMachine.DeleteSubKey(@"Software\Sinpin");

// Read Key Value
string val = reg.GetValue("QWord").ToString();

// Retrieve All Keys
foreach (string s in reg.GetValueNames())
    MessageBox.Show(s);

Get All Windows Handle

using System.Runtime.InteropServices;

// The signature for the callback method.
public delegate bool CallBack(IntPtr hwnd, int lParam);

[DllImport("user32.dll")]
public static extern int EnumWindows(CallBack callback, int param);
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hWnd,
    StringBuilder lpString, int nMaxCount);

static void Main(string[] args)
{
    // Request that the operating system enumerate all windows,
    // and trigger your callback with the handle of each one.
    EnumWindows(DisplayWindowInfo, 0);
    Console.ReadLine();
}

// The method that will receive the callback. The second
// parameter is not used, but is needed to match the
// callback's signature.
public static bool DisplayWindowInfo(IntPtr hWnd, int lParam)
{
    int chars = 100;
    StringBuilder buf = new StringBuilder(chars);
    if (GetWindowText(hWnd, buf, chars) != 0)
    {
        Console.WriteLine(buf);
    }
    return true;
}