Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.Runtime.InteropServices;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string numuti; //on définit "numuti" comme étant une chaine de caractères (vous l'appelez comme vous le voulez)
- numuti = numeroUtilisateur(); //on dit que "numuti" est le résultat de l'exécution de la fonction numeroUtilisateur(), soit le numéro donné par le logiciel pour identifier votre ordinateur
- textBox1.Text = code(numuti); //on met dans la textBox1 le texte correspondant à l'exécution de la fonction code depuis la valeur de votre numéro d'ordinateur, qui est numuti
- }
- public static string code(string numeroUtilisateur)
- {
- string str = "";
- int num = 0;
- for (int i = 0; i < numeroUtilisateur.Length; i++)
- {
- if (numeroUtilisateur[i] != '-')
- {
- str = str + "BCDFGHJKMPQRTVWXY2346789"[Convert.ToInt16((int)(numeroUtilisateur[i] + i)) % 0x17];
- num++;
- if ((num % 3) == 0)
- {
- str = str + "-";
- }
- }
- }
- if (str.LastIndexOf('-') == (str.Length - 1))
- {
- str = str.Substring(0, str.Length - 1);
- }
- return str;
- }
- public static string numeroUtilisateur()
- {
- string str = "";
- uint volumeSerialNumber = 0;
- uint maximumComponentLength = 0;
- StringBuilder volumeNameBuffer = new StringBuilder(0x100);
- uint fileSystemFlags = 0;
- StringBuilder fileSystemNameBuffer = new StringBuilder(0x100);
- long num4 = GetVolumeInformation(@"C:\", volumeNameBuffer, (uint)volumeNameBuffer.Capacity, ref volumeSerialNumber, ref maximumComponentLength, ref fileSystemFlags, fileSystemNameBuffer, (uint)fileSystemNameBuffer.Capacity);
- string str2 = Convert.ToString(volumeSerialNumber);
- int num5 = 0;
- num5 = 0;
- while (num5 < str2.Length)
- {
- str = str + "BCDFGHJKMPQRTVWXY2346789"[Convert.ToInt16(str2[num5]) % 0x17];
- if (((num5 + 1) % 3) == 0)
- {
- str = str + "-";
- }
- num5++;
- }
- if ((num5 % 3) == 0)
- {
- str = str + "ABC";
- }
- if ((num5 % 3) == 1)
- {
- str = str + "AB";
- }
- if ((num5 % 3) == 2)
- {
- str = str + "A";
- }
- return ("M60-" + str);
- }
- [DllImport("kernel32.dll")]
- private static extern long GetVolumeInformation(string PathName, StringBuilder VolumeNameBuffer, uint VolumeNameSize, ref uint VolumeSerialNumber, ref uint MaximumComponentLength, ref uint FileSystemFlags, StringBuilder FileSystemNameBuffer, uint FileSystemNameSize);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement