Advertisement
Guest User

Untitled

a guest
Nov 11th, 2011
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void button1_Click(object sender, EventArgs e)
  20.         {
  21.  
  22.         }
  23.  
  24.         public static string code(string numeroUtilisateur)
  25.         {
  26.             string str = "";
  27.             int num = 0;
  28.             for (int i = 0; i < numeroUtilisateur.Length; i++)
  29.             {
  30.                 if (numeroUtilisateur[i] != '-')
  31.                 {
  32.                     str = str + "BCDFGHJKMPQRTVWXY2346789"[Convert.ToInt16((int)(numeroUtilisateur[i] + i)) % 0x17];
  33.                     num++;
  34.                     if ((num % 3) == 0)
  35.                     {
  36.                         str = str + "-";
  37.                     }
  38.                 }
  39.             }
  40.             if (str.LastIndexOf('-') == (str.Length - 1))
  41.             {
  42.                 str = str.Substring(0, str.Length - 1);
  43.             }
  44.             return str;
  45.         }
  46.  
  47.  
  48.         public static string numeroUtilisateur()
  49.         {
  50.             string str = "";
  51.             uint volumeSerialNumber = 0;
  52.             uint maximumComponentLength = 0;
  53.             StringBuilder volumeNameBuffer = new StringBuilder(0x100);
  54.             uint fileSystemFlags = 0;
  55.             StringBuilder fileSystemNameBuffer = new StringBuilder(0x100);
  56.             long num4 = GetVolumeInformation(@"C:\", volumeNameBuffer, (uint)volumeNameBuffer.Capacity, ref volumeSerialNumber, ref maximumComponentLength, ref fileSystemFlags, fileSystemNameBuffer, (uint)fileSystemNameBuffer.Capacity);
  57.             string str2 = Convert.ToString(volumeSerialNumber);
  58.             int num5 = 0;
  59.             num5 = 0;
  60.             while (num5 < str2.Length)
  61.             {
  62.                 str = str + "BCDFGHJKMPQRTVWXY2346789"[Convert.ToInt16(str2[num5]) % 0x17];
  63.                 if (((num5 + 1) % 3) == 0)
  64.                 {
  65.                     str = str + "-";
  66.                 }
  67.                 num5++;
  68.             }
  69.             if ((num5 % 3) == 0)
  70.             {
  71.                 str = str + "ABC";
  72.             }
  73.             if ((num5 % 3) == 1)
  74.             {
  75.                 str = str + "AB";
  76.             }
  77.             if ((num5 % 3) == 2)
  78.             {
  79.                 str = str + "A";
  80.             }
  81.             return ("M60-" + str);
  82.         }
  83.  
  84.     }
  85. }
  86.  
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement