• Referencing the current desktop (vb6)

    Author
    Topic
    #366912

    I am trying to write a small vb application and I want to be able to set a filelistbox to show the desktop. As the setup uses profiles, the address is:

    c:windowsprofileusernamedesktop

    Is there a way I can get a reference to the current desktop no matter which profile is used or if no profile is used?

    Viewing 2 reply threads
    Author
    Replies
    • #570545

      Allan, I think that you want to use the SHGetSpecialFolderLocation API call:
      GetSpecialfolder(CSIDL_DESKTOP)
      See this example on allapi.net. –Sam

    • #570557

      Definitely look at Sam’s suggestion. In Windows 2000 and later, the profiles don’t live under the Windows folder at all, they’re found under Documents and Settings by user name.

    • #570574

      Yep! You definitely want to go the API route and let someone else solve it. Profile paths change every time Bill needs more money! bash

      • #570791

        Thanks all for the above pointers. I have the example and I’ll see what I make of it.

        • #570942

          Assuming your target machine has the Windows Script Host still installed (not removed to prevent VBS catastrophes), you can do it this way:

          Function strDesktopFolder() As String
          ‘ Set a reference to Windows Script Host Object Model
          Dim wshShell As New IWshShell_Class
          strDesktopFolder = wshShell.SpecialFolders(“Desktop”)
          Set wshShell = Nothing
          End Function

          This probably is no more efficient than using Win32API, and has the risk of being less portable, but it’s easy to understand.

    Viewing 2 reply threads
    Reply To: Referencing the current desktop (vb6)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: