Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get the windows Path.

Status
Not open for further replies.

vacunita

Programmer
Aug 2, 2001
9,166
MX
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
 
this might be a stupid question, but how do you use them? I'm getting a "Undeclared Identifier" error when i try to use them.
 
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
 
Hi guys,

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
 
Check this out Vacunita,

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top