[RESOLVED] Get folders XP to Vista
Looking adapt the follow code to work with XP and Vista
(currently works for XP)
vb Code:
Private Function GetMyVideosFolder() As String
' Get the path to the user's "My Videos" folder, creating it if it doesn't
' already exist (issue: may create an extra English "My Videos" folder in
' addition to the non-English one on localized Windows versions)
Dim myDocs As String, sPath As String
Dim IDL As ITEMIDLIST
If SHGetSpecialFolderLocation(Me.hWnd, CSIDL_DOCUMENTS, IDL) = 0 Then
sPath = Space(MAX_PATH)
If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then
myDocs = Left(sPath, InStr(sPath, vbNullChar) - 1) & ""
End If
End If
' Get the path to "My Documents"
If Dir(myDocs & "\My Videos", vbDirectory) = "" Then _
MkDir myDocs & "\My Videos"
' If "My Videos" doesn't exist in "My Documents", create it
GetMyVideosFolder = myDocs & "\My Videos"
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
Re: Get folders XP to Vista
I don't see the issue at all. :confused:
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.
Re: Get folders XP to Vista
In XP this works, but when I try with Vista I get
Quote:
Run-time error '75';
Path/File access error
Thanx
Re: Get folders XP to Vista
I seen something similar somewhere and it had to do with setting rights
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
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.
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?
2 Attachment(s)
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
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.
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:
Option Explicit
Private Const USER_AGENT = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"
Private re As RegExp
Private http As XMLHTTP
Private highestPos As Double
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
Public Enum CSIDL_VALUES
CSIDL_MYVIDEO = &HE
End Enum
Private Const MAX_PATH = 260
Private Function GetSpecialFolder(folder As Long) As String
Dim FolderPath As String * MAX_PATH
SHGetSpecialFolderPath 0, FolderPath, folder, 0
GetSpecialFolder = TrimNull(FolderPath)
End Function
Private Function TrimNull(Str1 As String) As String
Dim Loc As Integer
Loc = InStr(Str1, Chr$(0))
If Loc <> 0 Then
TrimNull = Mid$(Str1, 1, Loc - 1)
Else
TrimNull = Str1
End If
End Function
Private Sub Command1_Click()
ShellExecute hWnd, "explore", GetSpecialFolder(CSIDL_MYVIDEO), _
vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
Again, this still works for XP, just not Vista? (maybe I over looked something?)
Thanx
Re: Get folders XP to Vista
Allegedly, this works in both XP and Vista.
I have no tested it.
1 Attachment(s)
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
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!
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,