Advertisement
HytsuK

Getting Windows 10 User Name and Picture/TIle

Feb 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.02 KB | None | 0 0
  1. Imports System.Runtime.InteropServices
  2. Imports System.Text
  3.  
  4. Public Class Form1
  5.     <DllImport("shell32", EntryPoint:="#261", CharSet:=CharSet.Unicode, PreserveSig:=False)>
  6.     Public Shared Sub getusertilepath(username As String, whatever As UInt32, picpath As StringBuilder, maxlenght As Integer)
  7.     End Sub
  8.     Public Function getusertilepath(username As String) As String
  9.         Dim name As StringBuilder
  10.         name = New StringBuilder(1000)
  11.         getusertilepath(username, 2147483648, name, name.Capacity)
  12.         Return name.ToString
  13.     End Function
  14.     Public Function getuserpic(username As String) As Image
  15.         Return Image.FromFile(getusertilepath(username))
  16.     End Function
  17.  
  18.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  19.         PictureBox1.Image = getuserpic(System.Security.Principal.WindowsIdentity.GetCurrent().Name)
  20.         Label1.Text = Environment.UserName
  21.     End Sub
  22. End Class
  23.  
  24. https://www.youtube.com/watch?v=PPdSAVLOMa4&t=431s
  25. check the video for info
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement