20 Mart 2016 Pazar

c# windows product key

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            MessageBox.Show(LicenseCDKey64bit.ToString()+LicenseCDKey32bit.ToString());
        }
        public static string LicenseCDKey64bit
        {
            get
            {
                try
                {
                    RegistryKey key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
                                          RegistryView.Registry64);
                    string keyPath = @"Software\Microsoft\Windows NT\CurrentVersion";
                    byte[] rpk = (byte[])key.OpenSubKey(keyPath).GetValue("DigitalProductId");
                  
                    string serial = "";
                    const string possible = "BCDFGHJKMPQRTVWXY2346789";
                    for (int i = 0; i < 25; i++)
                    {
                        int accu = 0;
                        for (int a = 0; a < 15; a++)
                        {
                            accu <<= 8;
                            accu += rpk[66 - a];
                            rpk[66 - a] = (byte)(accu / 24 & 0xff);
                            accu %= 24;
                        }
                        serial = possible[accu] + serial;
                        if (i % 5 == 4 && i < 24)
                        {
                            serial = "-" + serial;
                        }
                    }
                    return serial;
                }
                catch
                {
                    string ErrorString = "";
                    return ErrorString;
                }
            }
        }
        public static string LicenseCDKey32bit
        {
            get
            {
                try
                {
                                   
                     byte[] rpk = (byte[])Registry.LocalMachine
                        .OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion")
                         .GetValue("DigitalProductId");
                    string serial = "";
                    const string possible = "BCDFGHJKMPQRTVWXY2346789";
                    for (int i = 0; i < 25; i++)
                    {
                        int accu = 0;
                        for (int a = 0; a < 15; a++)
                        {
                            accu <<= 8;
                            accu += rpk[66 - a];
                            rpk[66 - a] = (byte)(accu / 24 & 0xff);
                            accu %= 24;
                        }
                        serial = possible[accu] + serial;
                        if (i % 5 == 4 && i < 24)
                        {
                            serial = "-" + serial;
                        }
                    }
                    return serial;
                }
                catch
                {
                    string ErrorString = "";
                    return ErrorString;
                }
            }
        }
    }
}

19 Mart 2016 Cumartesi

c# mail gönderme kodu

 MailMessage Posta = new MailMessage();
            Posta.From = new MailAddress("myname@gmail.com","My name");
            //
            Posta.To.Add("deneme1@gmail.com");
            Posta.To.Add("deneme2@gmail.com");

         
            // Posta.Attachments.Add(new Attachment(@"C:\deneme.txt"));
         
            string konu = "konu";
            Posta.Subject = konu;
            //
            string icerik = "içerik";
            Posta.Body = icerik;
         
            SmtpClient smtp = new SmtpClient();
         
            smtp.Credentials = new System.Net.NetworkCredential("myname@gmail.com", "sifre");
            smtp.Port = 587;
            smtp.Host = "mail.gmail.com";
            //smtp.EnableSsl = true;
            object userState = ePosta;
            bool kontrol = true;
            try
            {
                smtp.SendAsync(Posta, (object)ePosta);
            }
            catch (SmtpException ex)
            {
                kontrol = false;
                System.Windows.Forms.MessageBox.Show(ex.Message, "Mail Gönderme Hatasi");
            }
            MessageBox.Show("mail gonderildi");

31 Ocak 2016 Pazar

Windows Server 2012 Remote CAL License nasıl

Windows Server 2012 Remote CAL License işlemleri
Yönetici olarak powershell açtıktan sonra girilecek komutlar

$obj=gwmi -namespace "Root/CIMV2/TerminlaServices" Win32_TerminalServiceSetting
$obj.ChangeMode(lisan türü)  //lisans türü user ise 4 device ise 2
$obj.ChangeMode(4)
$obj.GetSpecifiedLicenseServerList("server")
$obj.GetSpecifiedLicenseServerList() //komutu yaptığımız işlemi kontrol için