Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:21:12+00:00 2026-06-14T04:21:12+00:00

I enumerated the desktops on my system (I’m using SysInternals Desktops , so I

  • 0

I enumerated the desktops on my system (I’m using SysInternals Desktops, so I knew I had extras) using:

EnumDesktops(Nothing, AddressOf EnumDesktopsProc, Nothing)

with these declarations:

Private Declare Auto Function EnumDesktops Lib "User32" (ByVal hWinSta As IntPtr, ByVal edp As EnumDesktopProc, ByVal lParam As IntPtr) As Boolean
Private Declare Auto Function OpenDesktop Lib "User32" (<MarshalAs(UnmanagedType.LPTStr)> ByVal DesktopName As String, ByVal dwFlags As Integer, <MarshalAs(UnmanagedType.Bool)>ByVal fInherit As Boolean, ByVal dwDesiredAccess As AccessMask) As DesktopHandle

Private desktopNames As New List(Of String)

Private Delegate Function EnumDesktopProc(<MarshalAs(UnmanagedType.LPTStr)>ByVal DesktopName As String, ByVal lParam As IntPtr) As Boolean

Private Function EnumDesktopsProc(
          ByVal DesktopName As String,
          ByVal lParam As IntPtr
        ) As Boolean

    desktopNames.Add(DesktopName)
    Return True
End Function

I retrieved:

"WinSta0"
"Service-0x0-3e7$"
"Service-0x0-3e4$"
"Service-0x0-3e5$"
"SAWinSta"
"__X78B95_89_IW"
"Service-0x0-119d1e$"
"Service-0x0-4e05f$"

And when I attempted to open them with:

OpenDesktop(DesktopName, 0, False, AccessMask.DESKTOP_ENUMERATE)

(where AccessMask is a big Enum duplicating the data here and here, and DesktopHandle is a SafeHandle)

they all return NULL (Nothing) and GetLastWin32Error returns 2 "The system cannot find the file specified.". Why?

I checked alternate declarations for OpenDesktop and different AccessMask values with no effect (except when the declaration was actually wrong). I note I could get a different error when adding a “path” to the DesktopName, specifically 161 "The specified path is invalid."

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:21:13+00:00Added an answer on June 14, 2026 at 4:21 am

    The documentation for EnumDesktops is at least misleading, if not wrong. Passing NULL (Nothing) as the first parameter is returning the desktops of the “Session 0” window station. You need to use the result from GetProcessWindowStation(). I.e. change the first line above to:

    Private Declare Auto Function GetProcessWindowStation Lib "User32" () As IntPtr
    
    EnumDesktops(GetProcessWindowStation(), AddressOf EnumDesktopsProc, Nothing)
    

    (There is a user comment added to the EnumDesktops documentation but I missed it, so I thought others might too.)

    Note the documentation for GetProcessWindowStation explicitly says it does not need closing, so it doesn’t need wrapping in a SafeHandle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I enumerated the RAS capable devices using RasEnumDevices and I am getting the DeviceName
I have an enumerated type, StackID , and I am using the enumeration to
I was previously using How can a formcollection be enumerated in ASP.NET MVC? 's
Hibernates is generating a VARBINARY column with JPA @Enumerated annotation. I'm using SQL Server
I asked a previous question about mapping an enumerated value on a table using
I've tried using the grab all of the process IDs enumerated by the desktop
It's possible to define enumerations in JPA using either @Enumerated(EnumType.ORDINAL) or @Enumerated(EnumType.STRING) I wonder
I enumerated directories into a ListBox using this: private void TE_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
Possible Duplicate: The query results cannot be enumerated more than once? I am using
Example: batchTag is an enumerated type attribute of a batchRange, with values like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.