How to parse nested JSON object in Delphi XE2?

Try this sample {$APPTYPE CONSOLE} {$R *.res} uses DBXJSON, System.SysUtils; Const StrJson= ‘{‘+ ‘ “products”: {‘+ ‘ “Men”s Sneakers”: {‘+ ‘ “instock”: false,’+ ‘ “size”: “423”,’+ ‘ “manufacturer”: “Adidas”,’+ ‘ “lastcheck”: “20120529”‘+ ‘ },’+ ‘ “Purse”: {‘+ ‘ “instock”: true,’+ ‘ “size”: “not applicable”,’+ ‘ “manufacturer”: “Prada”,’+ ‘ “lastcheck”: “20120528”‘+ ‘ },’+ ‘ “Men”s Hood”: … Read more

Why does CreateProcess give error 193 (%1 is not a valid Win32 app)

The most likely explanations for that error are: The file you are attempting to load is not an executable file. CreateProcess requires you to provide an executable file. If you wish to be able to open any file with its associated application then you need ShellExecute rather than CreateProcess. There is a problem loading one … Read more

How to define application version in one place for multiple applications?

You can create a VERSIONINFO resource, in a plain text file (eg., Versioninfo.rc) 1 VERSIONINFO FILEVERSION 2,0,0,0 PRODUCTVERSION 2,0,0,0 FILEOS 0x4 FILETYPE 0x1 { BLOCK “StringFileInfo” { BLOCK “040904E4” { VALUE “CompanyName”, “Your Company Name Here\0” VALUE “FileDescription”, “Your File Description Here\0” VALUE “FileVersion”, “2.0.0.0\0” VALUE “InternalName”, “Your Internal Name\0” VALUE “LegalCopyright”, “© Your Copyright … Read more

How to dynamically create controls aligned to the top but after other aligned controls?

Once again, DisableAlign and EnableAlign to the rescue: procedure TForm1.FormCreate(Sender: TObject); var I: Integer; P: TPanel; begin DisableAlign; try for I := 0 to 4 do begin P := TPanel.Create(Self); P.Caption := IntToStr(I); P.Align := alTop; P.Parent := Self; end; finally EnableAlign; end; end; Explanation: When alignment is enabled, every single addition of a control … Read more

Why cannot take address to a nested local function in 64 bit Delphi?

This trick was never officially supported by the language and you have been getting away with it to date due to the implementation specifics of the 32 bit compiler. The documentation is clear: Nested procedures and functions (routines declared within other routines) cannot be used as procedural values. If I recall correctly, an extra, hidden, … Read more