Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/2/d43022721/htdocs/clickandbuilds/twmsblog/wp-content/themes/suffusion/functions/media.php on line 666

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/2/d43022721/htdocs/clickandbuilds/twmsblog/wp-content/themes/suffusion/functions/media.php on line 671

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/2/d43022721/htdocs/clickandbuilds/twmsblog/wp-content/themes/suffusion/functions/media.php on line 684

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/2/d43022721/htdocs/clickandbuilds/twmsblog/wp-content/themes/suffusion/functions/media.php on line 689

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/2/d43022721/htdocs/clickandbuilds/twmsblog/wp-content/themes/suffusion/functions/media.php on line 694
dummzeuch – twm's blog

dummzeuch

Migrating GExperts settings

 Delphi, GExperts  Comments Off on Migrating GExperts settings
Nov 302020
 

Somebody just asked me whether there is a simple way to migrate GExperts settings from Delphi XE7 to a new version.

The short answer is: No, but some experts (or rather: some functionality, because not everything is wrapped into an expert) have an ex- and import function.

I also started to write a general ex- and import function for GExperts but never finished it. Real life tends to intrude on open source programming. 😉

The long answer would be: Yes, you can do that by copying the registry entries and configuration files:

  • Export the GExperts registry key to a file
  • Edit that file to match the new Delphi version
  • Import the edited file into the registry.

The GExperts registry key is located under the registry key of the corresponding Delphi version. For XE7 that would be

HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\15.0\GExperts-1.3

The exported file will contain many sections in the form

[HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\15.0\GExperts-1.3]

[HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\15.0\GExperts-1.3\ASCIIChart]
"Font Size"=dword:0000000a
"Font Name"="Tahoma"
"Font Base"=dword:00000000
"Edit Display Text"="±"
"Show Hex"="0"
"Zoom Font Size"=dword:00000020
"Show Hint"="1"
"Left"=dword:000002a9
"Top"=dword:0000016b
"Width"=dword:0000022e
"Height"=dword:000001b2
"TotalCallCount"=dword:00000000

Here you will have to change the BDS version (15.0) to the version of your new Delphi.

In addition there are multiple entries that refer to the Delphi installation directory, e.g.:

[HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\15.0\GExperts-1.3\Grep\DirectoryList]
"Count"=dword:00000003
"GrepDir0"="C:\\Delphi\\DelphiXE7\\Source\\VCL"
"GrepDir1"="C:\\Delphi\\DelphiXE7\\Source\\rtl"
"GrepDir2"="C:\\Delphi\\DelphiXE7\\Source\\fmx"

or

[HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\15.0\GExperts-1.3\Misc]
"VCLPath"="C:\\Delphi\\DelphiXE7\\Source\\VCL\\"
"ConfigPath"="C:\\Users\\twm\\AppData\\Roaming\\GExperts\\RAD Studio XE 7\\"
"HelpFile"="D:\\source\\_sourceforge\\gexperts\\editorexpert\\GExperts.chm"
"AlphabetizeMenu"="1"
"EditorExpertsEnabled"="1"
"PlaceGxMainMenuInToolsMenu"="0"
"EditorEnhancementsEnabled"="0"
"EnableCustomFont"="0"
"HideWindowMenu"="0"
"MoveComponentMenu"="0"
"CachingPath"="C:\\Users\\twm\\AppData\\Local\\Gexperts\\RAD Studio XE 7\\"

You will have to change all these and if you get them wrong, GExperts might not work after you have imported them.

In addition, some of the experts store additional configuration files in the ConfigPath (which is configured in the last section shown above). You will also have to copy these files.

But not all is lost:
You probably know which experts you regularly use and are worth migrating the settings, so delete everything but these settings, edit them and the triple check them. That’s easier and less error prone than summarily editing all of them. Then only import the settings for these experts. Again: Don’t forget the files the experts might have stored in the configuration directory.

 Posted by on 2020-11-30 at 14:28

PortableAppsToStartMenu 1.0.0

 Delphi  Comments Off on PortableAppsToStartMenu 1.0.0
Nov 012020
 

Tired of all those programs which install lots of additional stuff I have been using more and more so called “Portable Apps”. “Portable” in this context means: You can put them anywhere, even on a portable storage device and start them from there. These Programs are still Windows only. And of course nobody prevents you from putting them in a folder on the system harddisk, usually c:\PortableApps. All files these programs need are inside this one folder, so in order to move or copy them, you simply move/copy that folder.

There is a dedicated launcher and updater for these types of programs at portableapps.com, which is written in Delphi btw. and the source code is available.

One thing that has irked me all the time is that these programs don’t show up in the Windows start menu, unless I add them manually, which I usually don’t. Today I had enough and wrote PortableAppsToStartMenu, a tool which given a PortableApps directory collects all the executables stored there and creates shortcuts in the Windows Start Menu for them. They will be visible in the PortableApps folder there. Apparently there was no such tool so far.

This is what the program looks like:

Some feature highlights:

  • You can drag the PortableApps directory on the entry field to set it.
  • The entry field has autocompletion for directories.
  • There are options to
    • Hide the Portable Apps Platform tools
    • Hide apps hidden in the launcher
    • Hide the “Portable” part of the executable name
  • It’s also possible to select the apps manually, but that’s rather cumbersome.

And these are the entries it has added to my start menu:

The entries are also available through the Start Menu’s usual search/filter functionality:

The program itself is of course a portable app, but not available from portableapps.com but only from OSDN. The program is written in in Delphi 10.2 and the source code is also available there.

If you want to discuss this article, go to the related post in the international DelphiPraxis forum.

 Posted by on 2020-11-01 at 18:49

How secure is your WordPress installation?

 blog  Comments Off on How secure is your WordPress installation?
Oct 242020
 

I have been using WordPress for this blog for several years and always thought my setup was reasonably secure. Turns out that there is something called the WordPress REST API which allows to get quite a lot information about the installation without any security at all. E.g. https://blog.dummzeuch.de/wp-json/wp/v2/users used to show a list of all my registered users (all three of them: me, myself and I). But that’s only by coincidence because I have disabled comments. There are similar lists for all articles, all pages and – most worrying – all media contents. So, if I had ever used the upload feature of my blog to share a file with somebody else, it would have been possible for anybody who knew about this REST API to find the file name and access that file.

I read about this security or at least privacy hole in the current issue of the German c’t magazine (I am subscribed to the dead tree edition). And today I plugged it. For this particular problem, there is a simple fix: Install the Disable WP REST API plugin. It changes the API to only work when a user is logged in. Others get the error:

{"code":"rest_login_required","message":"REST API restricted to authenticated users.","data":{"status":401}}

In case you are worried: The WordPress Android App still works even if that plugin is installed.

And since I am always curious I tried some other blogs and found quite a few for which this API was open.

I also changed the WordPress login page to require basic authentication as described here (in German). Yes, that means two logins are required now, but that’s not much of an inconvenience since I am the only user.

If you want to discuss this article, go to the related post in the international DelphiPraxis forum.

 Posted by on 2020-10-24 at 18:27

GExperts 1.3.17 experimental twm 2020-10-23 released

 Delphi, GExperts  Comments Off on GExperts 1.3.17 experimental twm 2020-10-23 released
Oct 232020
 

Guess what? The new GExperts release is here.

There are lots of bug fixes and a few new features in the new version.

The major new feature is the Filter Exceptions expert. Please be warned that there was a bug when developing for non-Windows targets. It might have been fixed, but I can’t test it and nobody else bothered to volunteer to test it. So there you go: Now you will be a tester, if you like it or not. If you encounter this problem, please file a bug report!

There is also a small improvement in PE Information tool (I won’t call it an expert any more because it’s now a stand alone executable that GExperts only calls.)

Also, the installer is now based on InnoSetup 5.6.1 which was the last version compatible with Windows XP. So, installing GExperts on Windows XP (VMs) should work again.

I hope this time the installers won’t be wrongly detected as malware by virus scanners. Sorry about that.

Please note that GExperts for Delphi 10.4 requires Update 1!

The new version is available for download on the GExperts download page.

If you want to discuss this article, you can do so in the corresponding post in the international Delphi Praxis forum.

 Posted by on 2020-10-23 at 18:07

Contributing to projects on GitHub with Subversion

 git, GitHub, TortoiseSVN  Comments Off on Contributing to projects on GitHub with Subversion
Oct 012020
 

Many open source projects have moved from the former top dog SlashdotSourceForge to GitHub and in the process usually converted from Subversion to git. This also includes quite a few Delphi libraries like project Jedi (JCL/JVCL), SynEdit or Indy.

I am not really comfortable with git, it just feels too complex for most projects and the GUI tools I have tried are clunky compared to TortoiseSVN. I see some advantages, but so far I’m not convinced. So, I have stayed with SVN and used that to access GitHub repositories through their git-svn bridge. This works fine, most of the time, unless you want to rename a file, which apparently is not possible for whatever reason.

Now, contributing to such projects is another challenge. You need to create something called “pull requests“, which basically is a way of creating patches that are centrally managed by GitHub together with a discussion area for them. It took me a while to get my head around the process but I think I got it now. So here are the steps:

  1. Get a GitHub account. There is no way around that.
  2. Fork the repository of the project to which you want to contribute.
  3. Create a branch in that forked repository. You need a separate branch for each pull request you want to create! (That was the main stumbling block for me, I just didn’t realize this. It’s probably documented somewhere but I overlooked it.)
  4. Check out that branch.
  5. Make your changes in that branch
  6. Commit those changes and push them to GitHub
  7. On GitHub, create a pull request

There are many sites that give you these steps sometimes with examples on how to do them, but always using git. Here is, how to do it without a git client, but using svn + the aforementioned git-svn bridge.

GitHub shows a url for each repository that can be accessed via git or svn. It looks like this:

https://github.com/[account]/[project].git

Remember that this url contains the the whole repository, so in order to check out only the trunk (master branch) or a branch, you need to add /trunk or /branches/[branchname] to it.

Creating a branch can be done either with svn in the usual way or with the web UI on GitHub. I prefer the latter which is done by typing a non-existing name for a branch and pressing enter.

For the following steps lets assume we created a branch called “pullrequesttest”.

Using the svn client of your choice (mine is TortoiseSVN), check out the sources of the branch we just created. The url would be:

https://github.com/[account]/[project].git/branches/pullrequesttest

Just make your changes and commit them the usual way. Subversion does not distinguish between a commit and a push to the server as git does.

The branch now contains the changes you want to submit to the project.

On GitHub, select that branch and you will see a message about your changes an a button “Compare & pull request”.

Click that button, add a comment and submit the pull request. It should show up on the original project’s page. Somebody with the rights to it can now approve and merge these changes. They can also be discussed there. Maybe some further improvements are necessary to get them accepted. For that you simply make changes to the code you have checked out and commit them to the same branch. They will automatically become part of the pull request (Remember that I said you need a separate branch for each pull request? That’s why.).

Now suppose there are other, unrelated changes you would like to submit? Start with creating a new branch, based on master, check out the code, make the changes commit them and create a new pull request for the new branch.

Just remember to never make any changes to the trunk (=master branch). That one is meant to have the same content as the original repository and the base for each branch to be used for a pull request.

I’m sure this description is more complicated that it needs to be. My main idea in writing this article is to get a starting point for creating pull requests without having to use git. If you can think of improvements, please discuss them in Delphi Praxis. Note that this is not meant to become a discussion about the merits of git vs. Subversion. We don’t need another one of these.

 Posted by on 2020-10-01 at 11:48

Bug and possible fix for GExperts Filter Exceptions expert – testers needed

 Delphi, GExperts  Comments Off on Bug and possible fix for GExperts Filter Exceptions expert – testers needed
Sep 272020
 

Mahdi Safsafi has proposed a fix for the bug in the GExperts Filter Exceptions expert, which occurs when developing for non Windows targets (first reported on Embarcadero’s quality portal ). I have implemented this fix and it doesn’t have any adverse effects on for Windows targets. But neither he nor I can test it for non Windows targets since we don’t develop for these. That means we need testers. If you want to help, please post a comment on the bug report on SourceForge.

 Posted by on 2020-09-27 at 13:27

Source code for Andreas Hausladen’s DfmCheck available

 Delphi  Comments Off on Source code for Andreas Hausladen’s DfmCheck available
Sep 092020
 

Andreas Hausladen – most probably know him because he wrote the very popular Delphi IDE Fixpackhas just announced (in German) that he published the source code of one of his other useful tools: DFMCheck. It’s in his GitHub repository.

Now I have just to figure out how to actually use it. 😉

 Posted by on 2020-09-09 at 09:21

GExperts for Delphi 10.4.1

 Delphi, GExperts  Comments Off on GExperts for Delphi 10.4.1
Sep 052020
 

I have received a few reports about bugs in GExperts in Delphi 10.4.1 that do not occur in Delphi 10.4. Here is a GExperts DLL that was compiled with Delphi 10.4.1. Maybe it will solve some of theses problems.

Simply extract the DLL and put it into the GExperts installation directory, replacing the original one.

Let me know on Delphi Praxis whether this fixes the problems.

 Posted by on 2020-09-05 at 11:36

Delphi’s TZipFile working on a stream

 Delphi  Comments Off on Delphi’s TZipFile working on a stream
Aug 202020
 

Recent versions of Delphi (for a suitable definition of “recent”) come with a TZipFile class implemented in the unit System.Zip. This class has the really neat feature that it can not only read the contents of a ZIP file directly from a stream but also extract a file from that stream to a TBytes array, thus it does not require any file system access.

E.g. imagine you have got a memory stream containing the contents of a ZIP archive (e.g. you got a zipped XML description from a GenICam compatible camera using the GCReadPort (PDF) function.). You now want to read a file from this stream and immediately process that file’s content without first writing it to the file system. This can be done like this:

var
  ms: TMemoryStream;
  ZIP TZipFile;
  Data: TBytes;
  // [...]
begin
  //
  // Some code here retrieves the ZIP archive's content and stores it in ms
  //
  Zip := TZipFile.Create;
  try
    ms.Position := 0;
    Zip.Open(ms, zmRead);
    if Zip.FileCount > 0 then begin
      Zip.Read(0, Data);
    end;
  finally
    FreeAndNil(Zip);
  end;
  //
  // now we have the file's content in Data and can process it.
  //
end;

One very important step here is to set the stream’s position to 0 before passing it to TZipFile.Open. If you forget that (guess who did) you will likely get an EZipException in TZipFile.Read with the error message ‘Invalid Zip Local Header signature’. The reason for this is that TZipFile.Open assumes that the current stream position is the first byte of the first file stored in the ZIP archive:

procedure TZipFile.Open(ZipFileStream: TStream; OpenMode: TZipMode);
begin
  // [...]
  FStream := ZipFileStream;
  FStartFileData := FStream.Position;
  // [...]
end;

If it isn’t, it will try to read the files starting from that position and will fail with the exception mentioned above.

If you want to discuss this article, you can do so in the corresponding post in the international Delphi Praxis forum.

 Posted by on 2020-08-20 at 18:08