Recent

Author Topic: get home/my documents directory on Linux/Windows?  (Read 10039 times)

Zomis

  • Jr. Member
  • **
  • Posts: 95
get home/my documents directory on Linux/Windows?
« on: November 17, 2006, 11:30:41 am »
How to get the home-directory / My Documents directory in Linux/Windows?

Zomis

  • Jr. Member
  • **
  • Posts: 95
RE: get home/my documents directory on Linux/Windows?
« Reply #1 on: November 19, 2006, 07:33:22 pm »
I use GetEnvironmentVariable('HOME') for Linux,
And for Windows I've discovered CSIDL_PERSONAL and GetSpecialDir() in Sysutils, but even though SysUtils is in my Uses clause, It says "Identifer not found: CSIDL_PERSONAL"...?

pch

  • Jr. Member
  • **
  • Posts: 51
    • http://ap-i.net
RE: get home/my documents directory on Linux/Windows?
« Reply #2 on: November 19, 2006, 08:49:04 pm »
For Linux I use homedir:=expandfilename('~/');

For Windows:
Code: [Select]

var
    PIDL : PItemIDList;
    Folder : array[0..MAX_PATH] of Char;
    const CSIDL_PERSONAL = $0005;
begin
SHGetSpecialFolderLocation(0, CSIDL_PERSONAL, PIDL);
SHGetPathFromIDList(PIDL, Folder);
homedir:=Folder;

Zomis

  • Jr. Member
  • **
  • Posts: 95
RE: get home/my documents directory on Linux/Windows?
« Reply #3 on: November 19, 2006, 09:05:51 pm »
Thanks... Your code made me also notice that I used {$ifdef WIN} instead of {$ifdef WIN32} for the condition for my uses Windows;

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: get home/my documents directory on Linux/Windows?
« Reply #4 on: November 20, 2006, 04:12:58 pm »
Take also a look at GetAppConfigDir and related functions.