The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream




    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,680 other followers

Archive for the ‘Delphi’ Category

Indy: getting response despite exceptions or 4xx HTTP status codes

Posted by jpluimers on 2016/12/07

Formy snippet archive (thanks Walter Prins for answering and Oliver Funcke for asking and elaborating on the answer):

in the case of error, you can get what would’ve normally been in the contentstream from the ExceptionObj.ErrorMessage property.  So you can use something like the following if you want to get the content response regardless of http response code (untested):

  FResponseStream: TStringStream;
  FRequestURL, Content : String;
  //.... etc etc
    FIdHTTP.Get(FRequestURL, FResponseStream);
    Content := FResponseStream.DataString;
    on E:EIdHTTPProtocolException do
      Content := E.ErrorMessage; 
  // At this point, "Content" contains the response body, both for 
  // successful (200) as well as other response codes.
  //.... etc etc


You can even do it simpler:

Response := IdHTTP.Get('http://host/path', [404]);

Source: delphi – Indy and REST – Can I prevent exceptions? – Stack Overflow



Posted in Delphi, Delphi 10 Seattle, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 1 Comment »

WinSCP can be embedded and scripted as can PSFTP but not FileZilla

Posted by jpluimers on 2016/12/01

In a quest to perform SFTP in Delphi next to FTP, I first researched what I was up against. A tiny voice in the back of my head said “SFTP is totally unlike FTP” and it was right: SFTP means SSH File Transfer Protocol, not Simple File Transfer Protocol nor FTP over SSH nor FTP over SSL aka FTPS – the latter is supported by Indy but the former isn’t.

I decided against SecureBlackBox (providing SFTPBlackbox) and IPWorks (SSH) as I tried both a while ago for S/MIME support and was disappointed about both the lack of features and documentation; in the end I went for wrapping OpenSSL for the “encrypt-then-sign” process and Indy for the SSMTP part. The merger of the SecureBlackBox and IPWorks made me even less happy.

The Chilkat alternative for SFTP isn’t too compelling either: ActiveX or DLL black-box without a lot of insight on how many people do use it.

So when I had to do SFTP and knew there are no free or open source SFTP components for Delphi available I opted for thinking outside the Delphi realm.

My basic idea was to embed either of these:

  1. Filezilla (as Filezilla on Windows is waaaay faster than WinSCP)
  2. WinSCP (a Windows SCP and SFTP client written in C++ Builder)
  3. PSFTP (the Putty SFTP client)


FileZilla internally uses FzSFtp.exe which is based on PSFTP code (but with some buffers making it faster than PSFTP or WinSCP).

According to the author, neither FzSFtp.exe nor FileZilla can be automated:

FileZilla cannot make any automated transfers at all. Neither FileZilla.exe nor fzsftp.exe (is for SFTP) can be used for any batch processing.

Source: run filezilla tzsftp from batch command line – FileZilla Forums

The WinSCP author commented in a similar fashion:

FileZilla does not have any command line arguments (nor any other way) that allow automatic transfer.

Source: windows – Command line option to download file in FileZilla – Stack Overflow

In addition, FileZilla is always a GUI program, so running it as a console app (which I’d prefer) would be impossible.


WinSCP can be automated in two ways:

  1. The WinSCP.exe command-line allows for a /console and /script switch enabling scripting mode that you can use for Scripting and Task Automation :: WinSCP
  2. A wrapper around WinSCP.exe is availble as WinSCP .NET Assembly and COM Library :: WinSCP which requires both .NET to be installed and (from Delphi) calling through COM which I don’t like much

Since I already had good Delphi wrapping code round starting/waiting-for running processes, I’d opt for using scripting.

There used to be wrapping code around: Use with Delphi :: Support Forum :: WinSCP


These Using PSFTP to transfer files securely links should get me going:

Chapter 6: Using PSFTP to transfer files securely

Practical examples:

Source locations

For my own reference, the open source locations:

Some semi-random Delphi SSL related postss

During the search above I found the below links that will be useful to me one day:


Posted in .NET, Delphi, Development, Software Development, SSH, TCP | 5 Comments »

String resources and the $TypedAddress Compiler Directive require a PResStringRec typecast

Posted by jpluimers on 2016/12/01

Thanks Alexey for answering and Horácio for asking:

Use type-cast PResStringRec(@SArgumentNil_NilValue_Collection)


via: Hey guys, When I switch on $TypedAddress Compiler Directive, it is no longer…

Posted in Delphi, Delphi 10 Seattle, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development, Uncategorized | Leave a Comment »

Actual source for DisableAlignPropertyEditor

Posted by jpluimers on 2016/11/30

Since Uwe Schuster only published a screenshot, I NewOCR-ed it and created the accompanying .dproj file (only because it’s an easy way for the DLL to require the designide package so you can use the DesignIntf and ToolsAPI units.

Uwe only posted these:

Anyway, the sources are at, but the main source is this:

library DisableAlignPropertyEditor;

  Originally only as jpg image by Uwe Schuster.


  LastRegisterPropertyEditorProc: TRegisterPropertyEditorProc = nil;

procedure NewRegisterPropertyEditor(PropertyType: PTypeInfo; ComponentClass: TClass; const PropertyName: string; EditorClass: TPropertyEditorClass);
  if Assigned(EditorClass) then
    if SameText('TAlignProperty', EditorClass.ClassName) then
  LastRegisterPropertyEditorProc(PropertyType, ComponentClass, PropertyName, EditorClass);

procedure wizardTerminate;
  RegisterPropertyEditorProc := LastRegisterPropertyEditorProc;

function wizardInit(const BorlandIDEServices: IBorlandIDEServices; RegisterProc: TWizardRegisterProc; var Terminate: TWizardTerminateProc): Boolean; stdcall;
  LastRegisterPropertyEditorProc := RegisterPropertyEditorProc;
  RegisterPropertyEditorProc := NewRegisterPropertyEditor;
  Terminate := wizardTerminate;
  Result := True;

  wizardInit name WizardEntryPoint;



Read the rest of this entry »

Posted in Delphi, Delphi 10.1 Berlin (BigBen), Development, Software Development | 2 Comments »

Can some recommend a good tool to build MSI package? I use Inno Setup…

Posted by jpluimers on 2016/11/30

For my G+ Link archive:

Can some recommend a good tool to build MSI package?I use Inno Setup but only to build EXE file.Thanks,  – Chris Z. – Google+

Source: Can some recommend a good tool to build MSI package? I use Inno Setup but only…


Posted in Delphi, Development, Installer-Development, Software Development | Leave a Comment »

%d bloggers like this: