Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SHGetSetSettings (shell32)
 
.
Summary
Retrieves or sets Shell state settings.

C# Signature:

[DllImport("shell32.dll")]
public static extern void SHGetSetSettings(ref SHELLSTATE lpss, SSF dwMask, bool bSet);

VB.NET Signature:

<DllImport("shell32.dll")> Shared Sub SHGetSetSettings(ByRef lpss As SHELLSTATE, ByVal dwMask As SSF, ByVal bSet As Boolean)
End Sub

User-Defined Types (C#):

  [StructLayout(LayoutKind.Sequential)]
  public struct SHELLSTATE {
    public uint flags_1;
    public uint dwWin95Unused;
    public uint uWin95Unused;
    public int  lParamSort;
    public int  iSortDirection;
    public uint version;
    public uint uNotUsed;
    public uint flags_2;

    public bool fShowAllObjects {
      get {return (flags_1 & 0x00000001u) == 0x00000001u;}
      set {if (value) {flags_1 |= 0x00000001u;} else {flags_1 &= ~0x00000001u;}}
    }
    public bool fShowExtensions {
      get {return (flags_1 & 0x00000002u) == 0x00000002u;}
      set {if (value) {flags_1 |= 0x00000002u;} else {flags_1 &= ~0x00000002u;}}
    }
    public bool fNoConfirmRecycle {
      get {return (flags_1 & 0x00000004u) == 0x00000004u;}
      set {if (value) {flags_1 |= 0x00000004u;} else {flags_1 &= ~0x00000004u;}}
    }
    public bool fShowSysFiles {
      get {return (flags_1 & 0x00000008u) == 0x00000008u;}
      set {if (value) {flags_1 |= 0x00000008u;} else {flags_1 &= ~0x00000008u;}}
    }
    public bool fShowCompColor {
      get {return (flags_1 & 0x00000010u) == 0x00000010u;}
      set {if (value) {flags_1 |= 0x00000010u;} else {flags_1 &= ~0x00000010u;}}
    }
    public bool fDoubleClickInWebView {
      get {return (flags_1 & 0x00000020u) == 0x00000020u;}
      set {if (value) {flags_1 |= 0x00000020u;} else {flags_1 &= ~0x00000020u;}}
    }
    public bool fDesktopHTML {
      get {return (flags_1 & 0x00000040u) == 0x00000040u;}
      set {if (value) {flags_1 |= 0x00000040u;} else {flags_1 &= ~0x00000040u;}}
    }
    public bool fWin95Classic {
      get {return (flags_1 & 0x00000080u) == 0x00000080u;}
      set {if (value) {flags_1 |= 0x00000080u;} else {flags_1 &= ~0x00000080u;}}
    }
    public bool fDontPrettyPath {
      get {return (flags_1 & 0x00000100u) == 0x00000100u;}
      set {if (value) {flags_1 |= 0x00000100u;} else {flags_1 &= ~0x00000100u;}}
    }
    public bool fShowAttribCol {
      get {return (flags_1 & 0x00000200u) == 0x00000200u;}
      set {if (value) {flags_1 |= 0x00000200u;} else {flags_1 &= ~0x00000200u;}}
    }
    public bool fMapNetDrvBtn {
      get {return (flags_1 & 0x00000400u) == 0x00000400u;}
      set {if (value) {flags_1 |= 0x00000400u;} else {flags_1 &= ~0x00000400u;}}
    }
    public bool fShowInfoTip {
      get {return (flags_1 & 0x00000800u) == 0x00000800u;}
      set {if (value) {flags_1 |= 0x00000800u;} else {flags_1 &= ~0x00000800u;}}
    }
    public bool fHideIcons {
      get {return (flags_1 & 0x00001000u) == 0x00001000u;}
      set {if (value) {flags_1 |= 0x00001000u;} else {flags_1 &= ~0x00001000u;}}
    }
    public bool fWebView {
      get {return (flags_1 & 0x00002000u) == 0x00002000u;}
      set {if (value) {flags_1 |= 0x00002000u;} else {flags_1 &= ~0x00002000u;}}
    }
    public bool fFilter {
      get {return (flags_1 & 0x00004000u) == 0x00004000u;}
      set {if (value) {flags_1 |= 0x00004000u;} else {flags_1 &= ~0x00004000u;}}
    }
    public bool fShowSuperHidden {
      get {return (flags_1 & 0x00008000u) == 0x00008000u;}
      set {if (value) {flags_1 |= 0x00008000u;} else {flags_1 &= ~0x00008000u;}}
    }
    public bool fNoNetCrawling {
      get {return (flags_1 & 0x00010000u) == 0x00010000u;}
      set {if (value) {flags_1 |= 0x00010000u;} else {flags_1 &= ~0x00010000u;}}
    }

    public bool fSepProcess {
      get {return (flags_2 & 0x00000001u) == 0x00000001u;}
      set {if (value) {flags_2 |= 0x00000001u;} else {flags_2 &= ~0x00000001u;}}
    }
    public bool fStartPanelOn {
      get {return (flags_2 & 0x00000002u) == 0x00000002u;}
      set {if (value) {flags_2 |= 0x00000002u;} else {flags_2 &= ~0x00000002u;}}
    }
    public bool fShowStartPage {
      get {return (flags_2 & 0x00000004u) == 0x00000004u;}
      set {if (value) {flags_2 |= 0x00000004u;} else {flags_2 &= ~0x00000004u;}}
    }
    public bool fAutoCheckSelect {
      get {return (flags_2 & 0x00000008u) == 0x00000008u;}
      set {if (value) {flags_2 |= 0x00000008u;} else {flags_2 &= ~0x00000008u;}}
    }
    public bool fIconsOnly {
      get {return (flags_2 & 0x00000010u) == 0x00000010u;}
      set {if (value) {flags_2 |= 0x00000010u;} else {flags_2 &= ~0x00000010u;}}
    }
    public bool fShowTypeOverlay {
      get {return (flags_2 & 0x00000020u) == 0x00000020u;}
      set {if (value) {flags_2 |= 0x00000020u;} else {flags_2 &= ~0x00000020u;}}
    }
    public bool fShowStatusBar {
      get {return (flags_2 & 0x00000040u) == 0x00000040u;}
      set {if (value) {flags_2 |= 0x00000040u;} else {flags_2 &= ~0x00000040u;}}
    }
  }

  [Flags]
  public enum SSF : uint {
    SSF_SHOWALLOBJECTS       = 0x00000001,
    SSF_SHOWEXTENSIONS       = 0x00000002,
    SSF_HIDDENFILEEXTS       = 0x00000004,
    SSF_SERVERADMINUI    = 0x00000004,
    SSF_SHOWCOMPCOLOR    = 0x00000008,
    SSF_SORTCOLUMNS      = 0x00000010,
    SSF_SHOWSYSFILES     = 0x00000020,
    SSF_DOUBLECLICKINWEBVIEW = 0x00000080,
    SSF_SHOWATTRIBCOL    = 0x00000100,
    SSF_DESKTOPHTML      = 0x00000200,
    SSF_WIN95CLASSIC     = 0x00000400,
    SSF_DONTPRETTYPATH       = 0x00000800,
    SSF_MAPNETDRVBUTTON      = 0x00001000,
    SSF_SHOWINFOTIP      = 0x00002000,
    SSF_HIDEICONS        = 0x00004000,
    SSF_NOCONFIRMRECYCLE     = 0x00008000,
    SSF_FILTER           = 0x00010000,
    SSF_WEBVIEW          = 0x00020000,
    SSF_SHOWSUPERHIDDEN      = 0x00040000,
    SSF_SEPPROCESS       = 0x00080000,
    SSF_NONETCRAWLING    = 0x00100000,
    SSF_STARTPANELON     = 0x00200000,
    SSF_SHOWSTARTPAGE    = 0x00400000,
    SSF_AUTOCHECKSELECT      = 0x00800000,
    SSF_ICONSONLY        = 0x01000000,
    SSF_SHOWTYPEOVERLAY      = 0x02000000,
    SSF_SHOWSTATUSBAR    = 0x04000000
  }

User-Defined Types (VB.NET):

  <StructLayout(LayoutKind.Sequential)> Public Structure SHELLSTATE
    Public flags_1 As UInteger
    Public dwWin95Unused As UInteger
    Public uWin95Unused As UInteger
    Public lParamSort As Integer
    Public iSortDirection As Integer
    Public version As UInteger
    Public uNotUsed As UInteger
    Public flags_2 As UInteger

    Public Property fShowAllObjects() As Boolean
      Get
    Return (flags_1 And &H00000001UI) = &H00000001UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000001UI, flags_1 And Not &H00000001UI)
      End Set
    End Property
    Public Property fShowExtensions() As Boolean
      Get
    Return (flags_1 And &H00000002UI) = &H00000002UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000002UI, flags_1 And Not &H00000002UI)
      End Set
    End Property
    Public Property fNoConfirmRecycle() As Boolean
      Get
    Return (flags_1 And &H00000004UI) = &H00000004UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000004UI, flags_1 And Not &H00000004UI)
      End Set
    End Property
    Public Property fShowSysFiles() As Boolean
      Get
    Return (flags_1 And &H00000008UI) = &H00000008UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000008UI, flags_1 And Not &H00000008UI)
      End Set
    End Property
    Public Property fShowCompColor() As Boolean
      Get
    Return (flags_1 And &H00000010UI) = &H00000010UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000010UI, flags_1 And Not &H00000010UI)
      End Set
    End Property
    Public Property fDoubleClickInWebView() As Boolean
      Get
    Return (flags_1 And &H00000020UI) = &H00000020UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000020UI, flags_1 And Not &H00000020UI)
      End Set
    End Property
    Public Property fDesktopHTML() As Boolean
      Get
    Return (flags_1 And &H00000040UI) = &H00000040UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000040UI, flags_1 And Not &H00000040UI)
      End Set
    End Property
    Public Property fWin95Classic() As Boolean
      Get
    Return (flags_1 And &H00000080UI) = &H00000080UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000080UI, flags_1 And Not &H00000080UI)
      End Set
    End Property
    Public Property fDontPrettyPath() As Boolean
      Get
    Return (flags_1 And &H00000100UI) = &H00000100UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000100UI, flags_1 And Not &H00000100UI)
      End Set
    End Property
    Public Property fShowAttribCol() As Boolean
      Get
    Return (flags_1 And &H00000200UI) = &H00000200UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000200UI, flags_1 And Not &H00000200UI)
      End Set
    End Property
    Public Property fMapNetDrvBtn() As Boolean
      Get
    Return (flags_1 And &H00000400UI) = &H00000400UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000400UI, flags_1 And Not &H00000400UI)
      End Set
    End Property
    Public Property fShowInfoTip() As Boolean
      Get
    Return (flags_1 And &H00000800UI) = &H00000800UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00000800UI, flags_1 And Not &H00000800UI)
      End Set
    End Property
    Public Property fHideIcons() As Boolean
      Get
    Return (flags_1 And &H00001000UI) = &H00001000UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00001000UI, flags_1 And Not &H00001000UI)
      End Set
    End Property
    Public Property fWebView() As Boolean
      Get
    Return (flags_1 And &H00002000UI) = &H00002000UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00002000UI, flags_1 And Not &H00002000UI)
      End Set
    End Property
    Public Property fFilter() As Boolean
      Get
    Return (flags_1 And &H00004000UI) = &H00004000UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00004000UI, flags_1 And Not &H00004000UI)
      End Set
    End Property
    Public Property fShowSuperHidden() As Boolean
      Get
    Return (flags_1 And &H00008000UI) = &H00008000UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00008000UI, flags_1 And Not &H00008000UI)
      End Set
    End Property
    Public Property fNoNetCrawling() As Boolean
      Get
    Return (flags_1 And &H00010000UI) = &H00010000UI
      End Get
      Set(ByVal value As Boolean)
    flags_1 = IIf(value, flags_1 Or &H00010000UI, flags_1 And Not &H00010000UI)
      End Set
    End Property

    Public Property fSepProcess() As Boolean
      Get
    Return (flags_2 And &H00000001UI) = &H00000001UI
      End Get
      Set(ByVal value As Boolean)
    flags_2 = IIf(value, flags_2 Or &H00000001UI, flags_2 And Not &H00000001UI)
      End Set
    End Property
    Public Property fStartPanelOn() As Boolean
      Get
    Return (flags_2 And &H00000002UI) = &H00000002UI
      End Get
      Set(ByVal value As Boolean)
    flags_2 = IIf(value, flags_2 Or &H00000002UI, flags_2 And Not &H00000002UI)
      End Set
    End Property
    Public Property fShowStartPage() As Boolean
      Get
    Return (flags_2 And &H00000004UI) = &H00000004UI
      End Get
      Set(ByVal value As Boolean)
    flags_2 = IIf(value, flags_2 Or &H00000004UI, flags_2 And Not &H00000004UI)
      End Set
    End Property
    Public Property fAutoCheckSelect() As Boolean
      Get
    Return (flags_2 And &H00000008UI) = &H00000008UI
      End Get
      Set(ByVal value As Boolean)
    flags_2 = IIf(value, flags_2 Or &H00000008UI, flags_2 And Not &H00000008UI)
      End Set
    End Property
    Public Property fIconsOnly() As Boolean
      Get
    Return (flags_2 And &H00000010UI) = &H00000010UI
      End Get
      Set(ByVal value As Boolean)
    flags_2 = IIf(value, flags_2 Or &H00000010UI, flags_2 And Not &H00000010UI)
      End Set
    End Property
    Public Property fShowTypeOverlay() As Boolean
      Get
    Return (flags_2 And &H00000020UI) = &H00000020UI
      End Get
      Set(ByVal value As Boolean)
    flags_2 = IIf(value, flags_2 Or &H00000020UI, flags_2 And Not &H00000020UI)
      End Set
    End Property
    Public Property fShowStatusBar() As Boolean
      Get
    Return (flags_2 And &H00000040UI) = &H00000040UI
      End Get
      Set(ByVal value As Boolean)
    flags_2 = IIf(value, flags_2 Or &H00000040UI, flags_2 And Not &H00000040UI)
      End Set
    End Property
  End Structure

  <Flags()> Public Enum SSF As UInteger
    SSF_SHOWALLOBJECTS       = &H00000001
    SSF_SHOWEXTENSIONS       = &H00000002
    SSF_HIDDENFILEEXTS       = &H00000004
    SSF_SERVERADMINUI    = &H00000004
    SSF_SHOWCOMPCOLOR    = &H00000008
    SSF_SORTCOLUMNS      = &H00000010
    SSF_SHOWSYSFILES     = &H00000020
    SSF_DOUBLECLICKINWEBVIEW = &H00000080
    SSF_SHOWATTRIBCOL    = &H00000100
    SSF_DESKTOPHTML      = &H00000200
    SSF_WIN95CLASSIC     = &H00000400
    SSF_DONTPRETTYPATH       = &H00000800
    SSF_MAPNETDRVBUTTON      = &H00001000
    SSF_SHOWINFOTIP      = &H00002000
    SSF_HIDEICONS        = &H00004000
    SSF_NOCONFIRMRECYCLE     = &H00008000
    SSF_FILTER           = &H00010000
    SSF_WEBVIEW          = &H00020000
    SSF_SHOWSUPERHIDDEN      = &H00040000
    SSF_SEPPROCESS       = &H00080000
    SSF_NONETCRAWLING    = &H00100000
    SSF_STARTPANELON     = &H00200000
    SSF_SHOWSTARTPAGE    = &H00400000
    SSF_AUTOCHECKSELECT      = &H00800000
    SSF_ICONSONLY        = &H01000000
    SSF_SHOWTYPEOVERLAY      = &H02000000
    SSF_SHOWSTATUSBAR    = &H04000000
  End Enum

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

You can leave out properties of the structure and members of the enumeration that you don't need. That might keep your code more readable and lean which will also decrease the size of the compiled binary.

Tips & Tricks:

You may want to copy the code out of the edit mode of this page because the site software messes up line indentations.

Sample Code (C#):

    SHELLSTATE state = new SHELLSTATE();
    SHGetSetSettings(ref state, SSF.SSF_DOUBLECLICKINWEBVIEW, false); // get the current fDoubleClickInWebView flag
    state.fDoubleClickInWebView = !state.fDoubleClickInWebView; // toggle the fDoubleClickInWebView flag
    SHGetSetSettings(ref state, SSF.SSF_DOUBLECLICKINWEBVIEW, true); // set the new flag

Sample Code (VB.NET):

    Dim state As SHELLSTATE
    SHGetSetSettings(state, SSF.SSF_DOUBLECLICKINWEBVIEW, False) ' get the current fDoubleClickInWebView flag
    state.fDoubleClickInWebView = Not state.fDoubleClickInWebView ' toggle the fDoubleClickInWebView flag
    SHGetSetSettings(state, SSF.SSF_DOUBLECLICKINWEBVIEW, True) ' set the new flag

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions