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:
Const PT_LOCAL As UInteger = 0 Const PT_TEMPORARY As UInteger = 1 Const PT_ROAMING As UInteger = 2 Const PT_MANDATORY As UInteger = 4 ''' <summary> ''' Determines the type of Windows profile being used by the user ''' </summary> ''' <param name="pdwflags">Output parameter</param> <System.Runtime.InteropServices.DllImportAttribute("Userenv.dll", EntryPoint:="GetProfileType")> _ Public Shared Function GetProfileType(ByRef pdwflags As UInteger) As Boolean End Function
and here is an example of how to use it in a method:
vb.net Code:
Dim ProfileType As UInteger GetProfileType(ProfileType) Select Case ProfileType Case PT_LOCAL MessageBox.Show("Using a local profile") Case PT_TEMPORARY MessageBox.Show("Using a temporary profile") Case PT_ROAMING MessageBox.Show("Using a roaming profile") Case PT_MANDATORY MessageBox.Show("Using a mandatory profile") End Select
Tested on Windows XP 32 bit and Windows 7 64 bit




Reply With Quote