Msquare
asked on
Find directory of "My Documents" or local equivalent
I need to specify a subdirectory relative to the "My documents" path. I'd like to do that with hardcoding the path. Initially I tried
Type DirPath = '%HOMEDRIVE%%HOMEPATH%\My Documents\Admin\logs\' ;
Well, I get "illegal filename" when using the %HOMEDRIVE% stuff. I cant use the GetEnviromentVariable (as recomended in many answers on EE) as this is Delphi5 and it isnt in help (or is there a unit that isnt covered in Help?) so I assume that is D6 or above.
Also, what is the trick to get the name of "My Documents" ? It is "Dokumenter" on Danish Windows as an example (and I did discover it in the registry one time long ago) The whole path for MyDocuments would do nicely (and thus ellminate the need for HOMEDRIVE/PATH)
Delphi 5, running on Windows XP
Type DirPath = '%HOMEDRIVE%%HOMEPATH%\My Documents\Admin\logs\' ;
Well, I get "illegal filename" when using the %HOMEDRIVE% stuff. I cant use the GetEnviromentVariable (as recomended in many answers on EE) as this is Delphi5 and it isnt in help (or is there a unit that isnt covered in Help?) so I assume that is D6 or above.
Also, what is the trick to get the name of "My Documents" ? It is "Dokumenter" on Danish Windows as an example (and I did discover it in the registry one time long ago) The whole path for MyDocuments would do nicely (and thus ellminate the need for HOMEDRIVE/PATH)
Delphi 5, running on Windows XP
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ZhaawZ, why do you provide the same solution as dinilud?
It's not really the same. It may seem similar, but different functions are used. I think it's good to know that there are more than 1 ways to get the result, isn't it?
I'm sorry if I offended you with that - I didn't want to...
The sollution you gave uses SHGetSpecialFolderLocation () AND SHGetPathFromIDList() functions to get the past, while it's possible to use one function instead - SHGetSpecialFolderPath().
I'm sorry if I offended you with that - I didn't want to...
The sollution you gave uses SHGetSpecialFolderLocation
... to get the path*, while ...
ASKER
Thanks to both. I choose the latter version as it seems shorter. Also had to adapt the answer https://www.experts-exchange.com/questions/20324781/convert-from-buffer-to-string-and-from-string-to-buffer.html to get it all tied up. It works now.
I'll split this 1:2 (if I can)
I'll split this 1:2 (if I can)
ZhaawZ, I never suggested a solution.
It just seems too happen so often on EE that people give a duplicate answer just to get the points. It's very annoying.
It just seems too happen so often on EE that people give a duplicate answer just to get the points. It's very annoying.
Sorry, didn't notice that sollution was from dinilud, not from you (I was too sleepy probably).
About the answer - as I said, it's not the same...
About the answer - as I said, it's not the same...
ASKER
Well, not part of this question ... but I just note that the "FAQ/Rulebook" says the process in EE is to receive several answers and the questioner gets to choose the best one. :-)
https://www.experts-exchange.com/help.jsp#hi38
If you want to discuss if the answers are too close to each other ... (do it somewhere else on this site?)
I do have a microscopic followup ... how do I find more "goodies" in ShlObj ? OK, ok, I looked in the source for the unit, and it clearly requires a Windows SDK or suchlike. Never mind, I'll ask in a seperate question if/when I have the need/time to go down that path.
https://www.experts-exchange.com/help.jsp#hi38
If you want to discuss if the answers are too close to each other ... (do it somewhere else on this site?)
I do have a microscopic followup ... how do I find more "goodies" in ShlObj ? OK, ok, I looked in the source for the unit, and it clearly requires a Windows SDK or suchlike. Never mind, I'll ask in a seperate question if/when I have the need/time to go down that path.