Results 1 to 4 of 4

Thread: Determine User's Windows Profile Type

  1. #1

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Determine User's Windows Profile Type

    Here is a quick bit of code I wrote that shows how to use the GetProfileType API to determine if the user is using a local, roaming, temporary, or mandatory windows profile. Just posting it here as there seems to be no examples of using this API from VB.NET on google (or pinvoke.net)

    Here are the API definitions I am using:
    vb.net Code:
    1. Const PT_LOCAL As UInteger = 0
    2. Const PT_TEMPORARY As UInteger = 1
    3. Const PT_ROAMING As UInteger = 2
    4. Const PT_MANDATORY As UInteger = 4
    5.  
    6. ''' <summary>
    7. ''' Determines the type of Windows profile being used by the user
    8. ''' </summary>
    9. ''' <param name="pdwflags">Output parameter</param>
    10. <System.Runtime.InteropServices.DllImportAttribute("Userenv.dll", EntryPoint:="GetProfileType")> _
    11. Public Shared Function GetProfileType(ByRef pdwflags As UInteger) As Boolean
    12. End Function

    and here is an example of how to use it in a method:

    vb.net Code:
    1. Dim ProfileType As UInteger
    2. GetProfileType(ProfileType)
    3.  
    4. Select Case ProfileType
    5.     Case PT_LOCAL
    6.                 MessageBox.Show("Using a local profile")
    7.     Case PT_TEMPORARY
    8.                 MessageBox.Show("Using a temporary profile")
    9.     Case PT_ROAMING
    10.                 MessageBox.Show("Using a roaming profile")
    11.     Case PT_MANDATORY
    12.                 MessageBox.Show("Using a mandatory profile")
    13. End Select

    Tested on Windows XP 32 bit and Windows 7 64 bit
    Last edited by chris128; Dec 16th, 2009 at 03:45 PM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  2. #2
    New Member
    Join Date
    Jan 2010
    Posts
    2

    Re: Determine User's Windows Profile Type

    Hi Chris -

    Is it possible to use this code to check the remote machine users profile type ?

    Any suggestins?

  3. #3

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Determine User's Windows Profile Type

    I dont think there is any way you can use this API to do that no, but I believe this API works by reading the value of the "State" value in the following registry key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\SID
    Replace that last part of the path ("SID") with the SID of the user that you want to get the profile type of.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4
    New Member
    Join Date
    Jan 2010
    Posts
    2

    Re: Determine User's Windows Profile Type

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width