Advertisement
Guest User

Untitled

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