Results 1 to 14 of 14

Thread: [RESOLVED] Get folders XP to Vista

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Resolved [RESOLVED] Get folders XP to Vista

    Looking adapt the follow code to work with XP and Vista
    (currently works for XP)

    vb Code:
    1. Private Function GetMyVideosFolder() As String
    2.     ' Get the path to the user's "My Videos" folder, creating it if it doesn't
    3.     ' already exist (issue: may create an extra English "My Videos" folder in
    4.     ' addition to the non-English one on localized Windows versions)
    5.    
    6.     Dim myDocs As String, sPath As String
    7.     Dim IDL As ITEMIDLIST
    8.    
    9.     If SHGetSpecialFolderLocation(Me.hWnd, CSIDL_DOCUMENTS, IDL) = 0 Then
    10.         sPath = Space(MAX_PATH)
    11.         If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then
    12.             myDocs = Left(sPath, InStr(sPath, vbNullChar) - 1) & ""
    13.         End If
    14.     End If
    15.     ' Get the path to "My Documents"
    16.  
    17.     If Dir(myDocs & "\My Videos", vbDirectory) = "" Then _
    18.         MkDir myDocs & "\My Videos"
    19.     ' If "My Videos" doesn't exist in "My Documents", create it
    20.        
    21.     GetMyVideosFolder = myDocs & "\My Videos"
    22. End Function

    Vista uses "Users" where XP uses "Documents and Settings"
    I even tried to make a folder in root called Documents and Settigs, but Vista will not allow this name used.

    Thanx

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Get folders XP to Vista

    I don't see the issue at all.

    You are detecting the name & location of the "My Documents" folder for the current user (the code up to line 14), which will work no matter what that folder is called, or what drive/folder it is in.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Re: Get folders XP to Vista

    In XP this works, but when I try with Vista I get

    Run-time error '75';
    Path/File access error
    Thanx

  4. #4
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Get folders XP to Vista

    I seen something similar somewhere and it had to do with setting rights
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Re: Get folders XP to Vista

    Quote Originally Posted by isnoend07
    I seen something similar somewhere and it had to do with setting rights
    Ya I have read that as well, but have ran the program "as administrator" still same result

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Get folders XP to Vista

    In Vista videos are supposed to go into the folder at CSIDL_MYVIDEO = &HE&

    This is only valid for Vista+ though.
    Last edited by dilettante; Feb 20th, 2008 at 10:52 PM.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Re: Get folders XP to Vista

    Quote Originally Posted by dilettante
    In Vista videos are supposed to go into the folder at CSIDL_MYVIDEO = &HE&

    This is only valid for Vista+ though.
    Is there a way to adapt prev code to work in both vista and xp?
    or should I just try and make a new folder in my app folder?

  8. #8
    Addicted Member
    Join Date
    Jul 2007
    Posts
    146

    Re: Get folders XP to Vista

    Quote Originally Posted by planethax
    Is there a way to adapt prev code to work in both vista and xp?
    or should I just try and make a new folder in my app folder?
    Hi,

    CSIDL_MYVIDEO = &HE works both on Vista and XP, to make sure I tested attached sample project on both OS's.

    CSIDL_MYDOCUMENTS = &HC doesn't work on vista, but if you use CSIDL_PERSONAL = &H5 it gives the proper folder on both OS's.

    Though XP allowed developers to save data to the app folder (Note: the installed application, as in "C:\Program Files\Your App"), Vista no longer does. You have no choice then to use the AppData folder, which also works both on XP and Vista and AFAIK W2K.

    I've written a sample module that takes care of all that, which you can change to your needs. (Attachement 2)

    HTH
    Attached Files Attached Files
    Jottum™
    XpVistaControls , (transparent) usercontrols for XP, Vista and 7 with W2K legacy support.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Re: Get folders XP to Vista

    Quote Originally Posted by Jottum
    Hi,

    CSIDL_MYVIDEO = &HE works both on Vista and XP, to make sure I tested attached sample project on both OS's.


    HTH
    Thank you, by modifying the first attachment (myspecialfolder)
    I implemented into my App, I have tested with XP and it still works.
    I will be able to test it later this evening on Vista.
    Will report back results.

    Thank you so much again.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Re: Get folders XP to Vista

    I sent app to a friend with vista, seem to still get same "run-time error 75"
    this is what I have in app

    vb Code:
    1. Option Explicit
    2.  
    3. Private Const USER_AGENT = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"
    4.  
    5. Private re As RegExp
    6. Private http As XMLHTTP
    7. Private highestPos As Double
    8.  
    9.  
    10. Private Declare Function SHGetSpecialFolderPath Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" (ByVal hwndOwner As Long, ByVal lpszPath As String, ByVal nFolder As Long, ByVal fCreate As Long) As Long
    11.  
    12. Public Enum CSIDL_VALUES
    13.  
    14.     CSIDL_MYVIDEO = &HE
    15.    
    16. End Enum
    17. Private Const MAX_PATH = 260
    18.  
    19. Private Function GetSpecialFolder(folder As Long) As String
    20.     Dim FolderPath As String * MAX_PATH
    21.     SHGetSpecialFolderPath 0, FolderPath, folder, 0
    22.     GetSpecialFolder = TrimNull(FolderPath)
    23. End Function
    24.  
    25. Private Function TrimNull(Str1 As String) As String
    26.     Dim Loc         As Integer
    27.    
    28.     Loc = InStr(Str1, Chr$(0))
    29.     If Loc <> 0 Then
    30.         TrimNull = Mid$(Str1, 1, Loc - 1)
    31.     Else
    32.         TrimNull = Str1
    33.     End If
    34. End Function
    35. Private Sub Command1_Click()
    36. ShellExecute hWnd, "explore", GetSpecialFolder(CSIDL_MYVIDEO), _
    37.     vbNullString, vbNullString, SW_SHOWNORMAL
    38.  
    39. End Sub

    Again, this still works for XP, just not Vista? (maybe I over looked something?)
    Thanx

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Get folders XP to Vista

    Allegedly, this works in both XP and Vista.

    I have no tested it.

  12. #12
    Addicted Member
    Join Date
    Jul 2007
    Posts
    146

    Re: Get folders XP to Vista

    Quote Originally Posted by planethax
    I sent app to a friend with vista, seem to still get same "run-time error 75"
    this is what I have in app

    [...]

    Again, this still works for XP, just not Vista? (maybe I over looked something?)
    Thanx
    Hi,

    I've tested your code, and both on XP and Vista it opens the MyVideo folder in Explorer for the current user.

    I'll attach the sample project again (it's not the same as the first) , perhaps you should compile it and send it to your friend and see what result he gets. If it works, something else is going on with your other code.

    HTH
    Attached Files Attached Files
    Jottum™
    XpVistaControls , (transparent) usercontrols for XP, Vista and 7 with W2K legacy support.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Re: Get folders XP to Vista

    I dont know why it didnt work the first time, maybe app didnt upload to my server right, I have now recheck and it works PERFECTLY with XP and VISTA.

    Thank you so Much!

  14. #14
    Addicted Member
    Join Date
    Jul 2007
    Posts
    146

    Re: Get folders XP to Vista

    Quote Originally Posted by planethax
    I dont know why it didnt work the first time, maybe app didnt upload to my server right, I have now recheck and it works PERFECTLY with XP and VISTA.

    Thank you so Much!
    My pleasure, glad you've got it working.

    Take care,
    Jottum™
    XpVistaControls , (transparent) usercontrols for XP, Vista and 7 with W2K legacy support.

Posting Permissions

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



Click Here to Expand Forum to Full Width