Tony Foale wrote:
I posted a similar query to this list quite a while back to find the name of the MyDocuments dir. in the any language OS. The following is the function that I now use as a result of the replies.
-------------------
function GetMyDocs: string ;
// Needs "shlobj, windows" in USES clause
var
ppidl: PItemIdList;
PerDir: string;
begin
ppidl := nil;
SHGetSpecialFolderLocation(0, CSIDL_PERSONAL, ppidl);
SetLength(perdir, MAX_PATH);
if not SHGetPathFromIDList(ppidl, PChar(perdir)) then
raise exception.create('Could not find your default documents folder');
//endif
SetLength(perdir, lStrLen(PChar(perdir))); Result := perdir ;
end;

And that's exactly why, when you asked about the My Documents directory in July, I posted a function that used ShGetFolderPath, not ShGetSpecialFolderLocation. The "Location" functions make it very easy to introduce memory leaks when you're not paying attention to how the function works. The code that Maarten de Jong posted in response to your question used the Location version, but it also freed the PIDL properly. For examples of all the Path and Location functions, see this article on my Web site:


http://www.cs.wisc.edu/~rkennedy/my-documents

To get the programmes folder just substitute CSIDL_PROGRAMS for CSIDL_PERSONAL

No, Csidl_Programs gets you a folder in your Start menu.

--
Rob

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to