Re: [Lazarus] Getting common documents folders

2015-05-28 Thread Richard Mace
Perfect

Thank you
On 27 May 2015 22:39, silvioprog silviop...@gmail.com wrote:

 On Wed, May 27, 2015 at 6:21 PM, Michael Van Canneyt 
 mich...@freepascal.org wrote:


 On Wed, 27 May 2015, Glaucos Ginez wrote:

  Hi, you can use GetEnvironmentVariable('LocalAppData')

 2015-05-27 14:53 GMT-04:00 Richard Mace richard.m...@gmail.com:
   Hi All,
 I need to use/get a common windows folder (in Win XP,Vista,7,8 and 8.1)
 that all users will have
 read/write access to by default.
 I think it is CSIDL_COMMON_DOCUMENTS

 Any ideas how I can code this in Lazarus?


 You can use the shfolder unit. It contains the necessary constants and
 calls to retrieve the location.

 Michael.


 Here in Brazil, on Lazarus-BR group, an member (Joao Marcelo Vaz) sent an
 very nice tip:

 uses
   windirs;

 ...

   ShowMessage(GetWindowsSpecialDir(CSIDL_COMMON_DOCUMENTS));

 =)

 --
 Silvio Clécio
 My public projects - github.com/silvioprog

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Getting common documents folders

2015-05-28 Thread Michael Van Canneyt



On Wed, 27 May 2015, silvioprog wrote:


On Wed, May 27, 2015 at 6:21 PM, Michael Van Canneyt mich...@freepascal.org 
wrote:

  On Wed, 27 May 2015, Glaucos Ginez wrote:

Hi, you can use GetEnvironmentVariable('LocalAppData')

2015-05-27 14:53 GMT-04:00 Richard Mace richard.m...@gmail.com:
      Hi All,
I need to use/get a common windows folder (in Win XP,Vista,7,8 and 
8.1) that all users will have
read/write access to by default.
I think it is CSIDL_COMMON_DOCUMENTS

Any ideas how I can code this in Lazarus?


  You can use the shfolder unit. It contains the necessary constants and
  calls to retrieve the location.

  Michael.


Here in Brazil, on Lazarus-BR group, an member (Joao Marcelo Vaz) sent an very 
nice tip:

uses
  windirs;

...

  ShowMessage(GetWindowsSpecialDir(CSIDL_COMMON_DOCUMENTS));

=)


Right, I could not find that unit !
I knew there was another one, but could not find it, looking in 
packages/winunits-base :(

Michael.--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Getting common documents folders

2015-05-27 Thread Richard Mace
Hi All,
I need to use/get a common windows folder (in Win XP,Vista,7,8 and 8.1)
that all users will have read/write access to by default.
I think it is CSIDL_COMMON_DOCUMENTS

Any ideas how I can code this in Lazarus?

Many thanks

Richard
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Getting common documents folders

2015-05-27 Thread Glaucos Ginez
Hi, you can use GetEnvironmentVariable('LocalAppData')

2015-05-27 14:53 GMT-04:00 Richard Mace richard.m...@gmail.com:

 Hi All,
 I need to use/get a common windows folder (in Win XP,Vista,7,8 and 8.1)
 that all users will have read/write access to by default.
 I think it is CSIDL_COMMON_DOCUMENTS

 Any ideas how I can code this in Lazarus?

 Many thanks

 Richard

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Getting common documents folders

2015-05-27 Thread Bart
On 5/27/15, Richard Mace richard.m...@gmail.com wrote:

 Hi All,
 I need to use/get a common windows folder (in Win XP,Vista,7,8 and 8.1)
 that all users will have read/write access to by default.
 I think it is CSIDL_COMMON_DOCUMENTS

Copied from winlazfileutils.inc (used by LazFieUtils unit):

Procedure InitDLL;
Var
  pathBuf: array[0..MAX_PATH-1] of char;
  pathLength: Integer;
begin
  { Load shfolder.dll using a full path, in order to prevent spoofing
(Mantis #18185)
Don't bother loading shell32.dll because shfolder.dll itself
redirects SHGetFolderPath
to shell32.dll whenever possible. }
  pathLength:=GetSystemDirectory(pathBuf, MAX_PATH);
  if (pathLength0) and (pathLengthMAX_PATH-14) then {
14=length('\shfolder.dll'#0) }
  begin
StrLCopy(@pathBuf[pathLength],'\shfolder.dll',MAX_PATH-pathLength-1);
CFGDLLHandle:=LoadLibrary(pathBuf);

if (CFGDLLHandle0) then
begin
  
Pointer(ShGetFolderPathW):=GetProcAddress(CFGDLLHandle,'SHGetFolderPathW');
  If @ShGetFolderPathW=nil then
  begin
FreeLibrary(CFGDLLHandle);
CFGDllHandle:=0;
  end;
end;
  end;
  If (@ShGetFolderPathW=Nil) then
Raise Exception.Create('Could not determine SHGetFolderPathW Function');
end;

function GetWindowsSpecialDirW(ID :  Integer) : String;
Var
  APath : Array[0..MAX_PATH] of WideChar;
  WS: WideString;
  Len: SizeInt;
begin
  Result := '';
  if (CFGDLLHandle = 0) then
InitDLL;
  If (SHGetFolderPathW  Nil) then
  begin
FillChar(APath{%H-}, SizeOf(APath), #0);
if SHGetFolderPathW(0,ID or CSIDL_FLAG_CREATE,0,0,@APATH[0]) = S_OK then
begin
  Len := StrLen(APath);
  SetLength(WS, Len);
  System.Move(APath[0], WS[1], Len * SizeOf(WideChar));
  Result := AppendPathDelim(Utf16ToUtf8(WS));
end;
  end
  else
Result := SysToUtf8(GetWindowsSpecialDir(ID)); // only needed for Win9x
end;

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Getting common documents folders

2015-05-27 Thread silvioprog
On Wed, May 27, 2015 at 6:21 PM, Michael Van Canneyt mich...@freepascal.org
 wrote:


 On Wed, 27 May 2015, Glaucos Ginez wrote:

  Hi, you can use GetEnvironmentVariable('LocalAppData')

 2015-05-27 14:53 GMT-04:00 Richard Mace richard.m...@gmail.com:
   Hi All,
 I need to use/get a common windows folder (in Win XP,Vista,7,8 and 8.1)
 that all users will have
 read/write access to by default.
 I think it is CSIDL_COMMON_DOCUMENTS

 Any ideas how I can code this in Lazarus?


 You can use the shfolder unit. It contains the necessary constants and
 calls to retrieve the location.

 Michael.


Here in Brazil, on Lazarus-BR group, an member (Joao Marcelo Vaz) sent an
very nice tip:

uses
  windirs;

...

  ShowMessage(GetWindowsSpecialDir(CSIDL_COMMON_DOCUMENTS));

=)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Getting common documents folders

2015-05-27 Thread Michael Van Canneyt



On Wed, 27 May 2015, Glaucos Ginez wrote:


Hi, you can use GetEnvironmentVariable('LocalAppData')

2015-05-27 14:53 GMT-04:00 Richard Mace richard.m...@gmail.com:
  Hi All,
I need to use/get a common windows folder (in Win XP,Vista,7,8 and 8.1) that 
all users will have
read/write access to by default.
I think it is CSIDL_COMMON_DOCUMENTS

Any ideas how I can code this in Lazarus?


You can use the shfolder unit. It contains the necessary constants and
calls to retrieve the location.

Michael.--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus