I need a way to get the path to "My Documents", "Desktop" and 'Windows' I now that with EXEname i get my application path, but how do i get the other three paths.
You can get the desktop folder with the windows API SHGetDesktopFolderLocation, the windows directory with API GetWindowsDirectory, and SHGetSpecialFolderLocation will give you recently used documents, but I'm not sure how you can get their "my documents" directory. TealWren
Oh, first of all I told you the wrong thing for the desktop - it's just SHGetDesktopFolder but it's declared in ShlObj so you just have to add ShlObj to your uses clause. SHGetSpecialFolderLocation is in that one too, and GetWindowsDirectory is in Windows.
So, add ShlObj and Windows to your uses clause and it should work. TealWren
Could you please give me an example of how to use the
because I cant find anything about them in the helpfile
(which I find very annoying myself). I was looking
to add those strings to an combobox. Now is the actual
adding not that hard, but cant get those functions to work
(which I also find very annoying) Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
This procdure gets the desktop directory, the my documents directoryp, and the favorites directory.
procedure TForm1.Button1Click(Sender: TObject);
const
RunKey = '.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders';
var
Registry: TRegistry;
MyDocsDir, DeskTopDir, FavsDir: String;
begin
Registry := TRegistry.Create;
try
Registry.RootKey := HKEY_USERS;
if Registry.OpenKey(RunKey, FALSE) then
begin
MyDocsDir := Registry.ReadString('Personal');
DeskTopDir := Registry.ReadString('Desktop');
FavsDir := Registry.ReadString('Favorites');
end
finally
Registry.Free;
ComboBox1.Items.Add(MyDocsDir); // Example useage
ComboBox1.Items.Add(DeskTopDir); // Example useage
ComboBox1.Items.Add(FavsDir); // Example useage
end;
end;
Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.