Advertisement
djshadowxm81

Untitled

Mar 15th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. try
  2.             {
  3.                 using (RegistryKey key = Registry.LocalMachine.OpenSubKey("HKEY_USERS\\"+sidString+"\\Software\\SAMP"))
  4.                 {
  5.                     if (key != null)
  6.                     {
  7.                         Object o = key.GetValue("PlayerName");
  8.                         if (o != null)
  9.                         {
  10.                             String playerName = new String(o as String);  //"as" because it's REG_SZ...otherwise ToString() might be safe(r)
  11.                             txtPlayerName.Text = playerName;
  12.                         }
  13.                     }
  14.                 }
  15.             }
  16.             catch (Exception ex)  //just for demonstration...it's always best to handle specific exceptions
  17.             {
  18.                 //react appropriately
  19.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement