WINDOWS10: Finding a Folder
Posted: Tue Feb 21, 2017 12:09 pm
I have pensioned off my aging Windows 7 PC and moved to a newer machine that includes a rather small but very fast solid state drive for OS, programs and related storage. This disk is C:
I have a 1TB drive (D:) for files and data and assigned my Documents, Music etc to this drive.
Windows 10 makes the reassignment very easy... just a few clicks.
Although my Documents directory supposedly now lives on D: the utility I have used for years still returns C: and
another application (LibreOffice) also still defaults to C:
Can anyone tell me how to correctly detect the location of the currently assigned 'Documents' directory that will work with Windows 7 and 10
Thanks
RichardL
I have a 1TB drive (D:) for files and data and assigned my Documents, Music etc to this drive.
Windows 10 makes the reassignment very easy... just a few clicks.
Although my Documents directory supposedly now lives on D: the utility I have used for years still returns C: and
another application (LibreOffice) also still defaults to C:
Can anyone tell me how to correctly detect the location of the currently assigned 'Documents' directory that will work with Windows 7 and 10
Thanks
RichardL
Code: Select all
Procedure.s SpecialFolder(CSIDL.l) ; Ask Windows where it keeps various important files
;http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494(v=vs.85).aspx
; Returns the path to a specified system directory.
; The calling parameter options can be found by looking in the Constants Explorer for #CDIDL_xxxxxx area.
Protected *itemid.ITEMIDLIST
Protected Location$ = Space(#MAX_PATH)
If SHGetSpecialFolderLocation_(0,CSIDL,@*itemid) = #NOERROR
If SHGetPathFromIDList_(*itemid,@Location$)
Debug "OK: "+Trim(Location$) + "\"
ProcedureReturn Trim(Location$) + "\"
Else
Debug "ERROR: SHGetPathFromIDList() returned an error"
EndIf
Else
Debug "ERROR: SHGetSpecialFolderLocation() returned an error"
EndIf
ProcedureReturn ""
EndProcedure
k$ = "#CSIDL_DESKTOP:" + Chr(9)+ SpecialFolder(#CSIDL_DESKTOP) + Chr(10)
k$ + "#CSIDL_COMMON_PICTURES:"+ Chr(9)+ SpecialFolder(#CSIDL_COMMON_PICTURES) + Chr(10)
k$ + "#CSIDL_PROGRAMS:" + Chr(9)+ SpecialFolder(#CSIDL_PROGRAMS) + Chr(10)
k$ + "#CSIDL_HISTORY:" + Chr(9)+ SpecialFolder(#CSIDL_HISTORY) + Chr(10)
k$ + "#CSIDL_DOCUMENTS:" + Chr(9)+ SpecialFolder(#CSIDL_PERSONAL) + Chr(10)
k$ + "--------------------------------"
MessageRequester("Program Files",k$)