Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Referencing the current desktop (vb6)

    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?
    "Heading for the deep end"

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Referencing the current desktop (vb6)

    Allan, I think that you want to use the SHGetSpecialFolderLocation API call:
    GetSpecialfolder(CSIDL_DESKTOP)
    See this example on allapi.net. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Referencing the current desktop (vb6)

    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.
    Charlotte

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Referencing the current desktop (vb6)

    Yep! You definitely want to go the API route and let someone else solve it. Profile paths change every time Bill needs more money! <img src=/S/bash.gif border=0 alt=bash width=35 height=39>
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: Referencing the current desktop (vb6)

    Thanks all for the above pointers. I have the example and I'll see what I make of it.
    "Heading for the deep end"

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Referencing the current desktop (vb6)

    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.

Posting Permissions

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