середа, 2 жовтня 2019 р.

Delphi helpful thing you should have

On my opinion, every Delphi coder should have such things installed in its IDE:

CnPack
IDE Fix Pack
DDevExtensions
DDevExtensions fork for Delphi 10.4+




You have to add "android:requestLegacyExternalStorage="true"" in the AndroidManifest.template.xml


This component has as main purpose, to facilitate the request of resource permissions on Android. With just a few lines of code it is possible to facilitate this work in mobile Android applications.


Library to create demo versions of Delphi and CBuilder apps: time-limited, feature-limited, limited to num of uses or num of concurrent network users.Supported on platforms: Windows, OS X, iOS, Android

Message Bus Pattern for Delphi. Send (publish) Message of any type in one place and receive it (subscribe) in many places.

QRCode supported Arabic text:

DelphiServiceManager

Service manager classes by Gurus Ritsaert Hornstra and Darian Miller. I (Tommi Prami) did some tweaking and refactoring. Slapped on premissive MIT licence if no objections (Original didn't have any).

https://github.com/TommiPrami/DelphiServiceManager


Tip: If you use the Offline Installer, RAD Studio will not be able to access the GetIt Package Manager until you manually switch to "online mode". To do this, we recommend using the GetItCmd.exe tool: GetItCmd.exe -c=useonline

Download links:

You can download the 10.3.3. version via:
30896 RAD Studio, Delphi, C++Builder 10.3.3 ISO (embarcadero.com)

You can download the 10.4.1. version via:
WEB: https://altd.embarcadero.com/download/radstudio/10.4/RADStudio-10-4-1-esd-1461.exe
ISO: https://altd.embarcadero.com/download/radstudio/10.4/radstudio_10_4_101461a.iso


DelphiPraxis · GitHub - interesting Delphi libraries


Disable Ctrl+D auto formating text.



Warning options
https://marc.durdin.net/2012/05/delphi-xe2s-hidden-hints-and-warnings-options/

середа, 7 серпня 2019 р.

How to Fix Windows Error Code 14xx (1400, 1410, 1411 etc) in your 32 bit multithreaded service application

We got some strange kinds of error in our 32 bit multithreaded service on Windows x64 Server 2012. After some time (actually few hours after restart the system) properly working, the service starts to push errors like "System error. Error code 1400". The solution below fixed our issue.
This is a "desktop heap" problem. A very good discussion can be found here:
Note that this only applies to programs that are running as services, because the default desktop heap size for services is so much smaller than that for applications.
In our case, we were able to launch about 100 child processes before running out of resources without the change. With the change, this number can be increased considerably.
This is the answer we've given to our end users on our knowledgebase:
WARNING: this affects the desktop heap of all services! Do not make it larger than necessary or you will push the system to consume more resource and you may bump up against problems in the total available desktop heap size.
If you find that you cannot open more than about 100 total projects, even on a very large RAM server, you may have run into a limit of the Windows "desktop heap size".
The problem is that service sessions under windows (where the services run) have less of this "desktop heap" space available for creating windows.
The short version is:
  • Services get smaller desktop heaps than interactive sessions.
  • Desktop heap size limits the number of windows
  • Each sub-server creates one or more “windows” even if we can’t see them.
Solution:
  1. Backup your registry before making any changes!
  2. Run regedit.exe as administrator
  3. Edit the registry value:
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows
    
  4. You will see a string like:
    %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,768 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4 ProfileControl=Off MaxRequestThreads=16
    
The critical bit is:
SharedSection=1024,20480,768
The second number (20480) is the size for interactive sessions. The third number (768) is the size of non-interactive (services) sessions. Note how the third number is 26x smaller than the second. Experimentally, we found that changing this to:
SharedSection=1024,20480,2048
Increased the project limit from 106 to 270, almost perfectly scaling with the heap size. Pick a value that reflects the maximum number of projects that you expect to be opened simultaneously by all users on the system. Do not make this value larger than necessary, and no larger than 8192, as each service in your system will consume more of a precious resource.
You will need to reboot for these new settings to take effect.
Another articles could be interesting to read:

понеділок, 29 липня 2019 р.

How to forget to restore a cursor in your Delphi application used an interface

Belowe is a clever way how to forget to restore a cursor in your Delphi application used an interface: unit autoCursor; interface uses Controls;
type
  ICursor
= interface(IInterface)
 
['{F5B4EB9C-6B74-42A3-B3DC-5068CCCBDA7A}']
 
end;
function __SetCursor(const aCursor: TCursor): ICursor;
implementation
uses Forms;
type
  TAutoCursor
= class(TInterfacedObject, ICursor)
  private
    FCursor
: TCursor;
  public
   
constructor Create(const aCursor: TCursor);
   
destructor Destroy; override;
 
end; { TAutoCursor }
constructor TAutoCursor.Create(const aCursor: TCursor);
begin
  inherited Create
;
  FCursor
:= Screen.Cursor;
  Screen
.Cursor := aCursor;
end; destructor TAutoCursor.Destroy;
begin
  Screen
.Cursor := FCursor;
  inherited
;
end;
function __SetCursor(const aCursor: TCursor): ICursor;
begin
  Result
:= TAutoCursor.Create(aCursor);
end;
end. and using the code above: uses
   autoCursor
;
procedure TForm1.Button1Click(Sender: TObject);
var
  Obj
: TSomeObject;
begin
 
__SetCursor(crHourGlass);

  Obj
:= TSomeObject.Create;
  try
   
// do something
  finally
    Obj
.Free;
 
end;
end;