Recent

Author Topic: [SOLVED]Identifier (Public Property) not found  (Read 820 times)

VinDerKlaus

  • New Member
  • *
  • Posts: 27
[SOLVED]Identifier (Public Property) not found
« on: February 09, 2020, 04:21:09 pm »
Good Day Friends,

I try to transfer from GUI application to Program but get error:

Quote
Error: identifier not found "Handle"

Handle is Public Property in parameters of below code:

Code: Pascal  [Select][+][-]
  1. SHGetFolderPath(Handle, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, usr) = 0

Handle is part of package LCLBase (lcl\controls.pp).

This is my uses section:

Code: Pascal  [Select][+][-]
  1.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  2.   cthreads,
  3.   {$ENDIF}{$ENDIF}
  4.   Classes,
  5.   { you can add units after this }
  6.   SysUtils, Controls, Graphics, Dialogs, StdCtrls, Interfaces, fileutil,
  7.   shlobj;

I made sure to add LCL to Required Packages in Project Inspector.

So I can't discover why this works in GUI application, but not in Program. Any thought?

Thank you and have nice day
« Last Edit: February 10, 2020, 01:23:53 am by VinDerKlaus »

balazsszekely

  • Guest
Re: Identifier (Public Property) not found
« Reply #1 on: February 09, 2020, 05:59:49 pm »
You can replace handle with 0 in a console application. This should return the current user's desktop folder:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}
  7.   cthreads,
  8.   {$ENDIF}
  9.   Classes,
  10.   shlobj
  11.   { you can add units after this };
  12.  
  13. function GetSpecialFolder(const CSIDL: LongInt): string;
  14. var
  15.   Buffer: array[0..MaxPathLen] of WideChar;
  16. begin
  17.   Result := '';
  18.   if SHGetFolderPathW(0, CSIDL, 0, SHGFP_TYPE_CURRENT, Buffer) = S_OK then
  19.     Result := Buffer;
  20. end;
  21.  
  22. begin
  23.   Writeln(GetSpecialFolder(CSIDL_DESKTOPDIRECTORY));
  24.   Readln;
  25. end.

PS: SHGetFolderPath is obsolete, you should replace it with SHGetFolderPathW.

VinDerKlaus

  • New Member
  • *
  • Posts: 27
Re: Identifier (Public Property) not found
« Reply #2 on: February 10, 2020, 01:20:40 am »
Thank you, this works now.

 

TinyPortal © 2005-2018