The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

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

    Join 1,860 other subscribers

Archive for March, 2021

Chocolatey: installing Forticlient

Posted by jpluimers on 2021/03/26

I needed Forticlient on a machine one day, so this is how to install the most recent Forticlient 6 using chocolatey:

choco install --yes forticlient --source https://www.myget.org/F/public-choco/api/v2

This ensures you can automatically update from Chocolatey instead of manually from the Forticlient GUI.

The update command is slightly different as a choco update will complain it cannot find the source for forticlient; you need this in stead:

choco update forticlient --source https://www.myget.org/F/public-choco/api/v2

Based on [WayBack] public-choco – forticlient 6.0.4.0182 | MyGet.

–jeroen

Posted in Chocolatey, Power User, Windows | Leave a Comment »

Interactive tool to record a web-site, then archive it as WARC: GitHub – webrecorder/webrecorder-user-guide: webrecorder user guide and glossary

Posted by jpluimers on 2021/03/26

Learned about this in the fall of G+: [WayBack] GitHub – webrecorder/webrecorder-user-guide: webrecorder user guide and glossary

Back then, fully automated tools were easier.

So it is on my list of things to try one day for smaller projects.

From the glossary:

Quick Start

  1. Enter a URL in the box in the center of the screen labeled ‘URL to capture’.
  2. Press the ‘start’ button (look down and to the right of the box where you entered the URL).
  3. Interact with the web page that loads so Webrecorder can capture the content displayed on this page. To collect audio or video from a page be sure to press ‘play’ so the file will load into the browser.
  4. Continue to visit and browse the pages you would like to capture. Each page you view will be included in your capture session. Note: you will be capturing the contents of each page you visit but will not automatically obtain pages that are linked to on the pages you collect (hyperlinks).
  5. To end your capture session hover over the ‘Capture’ button in the upper left corner of the screen so it changes to read ‘Stop’ then click that button.
  6. Your capture will then be browsable. Note: the capture will not ‘replay’ like a linear recording but instead be an interactive copy of the pages you have collected.
  7. If you are a logged-in user, this session will be saved to your account automatically. If you are not logged in an account, you can sign up for an account or log in to your existing account to save the collection after you create it. If you do not log in you can still download your collection for a limited time (approximately 90 minutes from when you stop your recording session).

–jeroen

Posted in Internet, InternetArchive, Power User | Leave a Comment »

JSONPlaceholder – Fake online REST API for developers

Posted by jpluimers on 2021/03/25

A great way for testing REST JSON calls is using the [WayBack] JSONPlaceholder – Fake online REST API for developers:

Fake Online REST API for Testing and Prototyping
Serving ~200M requests per month
Powered by JSON Server [WayBack] + LowDB [WayBack]

It is like [WayBack] Placeholder.com: Placeholder Images Done For You [JPG, GIF & PNG] but for JSON and supports both CORS and JSON-P for cross domain requests.

You can either use that site (which has a predefined set of REST calls) or the basic [WayBack] My JSON Server – Fake online REST server for teams that allows you to respond it to a db.json file from github:

Fake Online REST server for teams

Create a JSON file on GitHub

github.com/user/repo/master/db.json
{
  "posts": [
    {
      "id": 1,
      "title": "hello"
    }
  ],
  "profile": {
    "name": "typicode"
  }
}

Get instantly a fake server

my-json-server.typicode.com/user/repo/posts/1
{
  "id": 1,
  "title": "hello"
}

Related

Documentation

There is basic documentation at the repository [WayBack] GitHub – typicode/jsonplaceholder: A simple online fake REST API server:

Read the rest of this entry »

Posted in Communications Development, Development, HTTP, Internet protocol suite, JavaScript/ECMAScript, JSON, REST, Scripting, Software Development, TCP | Leave a Comment »

Delphi: Any idea why Delphi (At least since Seattle) does this to Dproj files:  nodes change places – Tommi Prami – Google+

Posted by jpluimers on 2021/03/25

From a while back, but still so very relevant: [WayBackAny idea why Delphi (At least since Seattle) does this to Dproj files:  <DeployClass …> nodes change places – Tommi Prami – Google+.

Luckily most of the thread is archived by now, as G+ is dead.

This thread brought DProjNormalizer to my attention, but by now you should be better using Project Magician.

DProjNormalizer normalizes the XML structure of Delphi .dproj files, both during IDE save actions, and manually using the command-line tool DprojNormalizerCmd.exe too.

Note that the manual tool does an in-place modification of your .dproj files, so better use version control, have good backups, or use InplaceExeWrapper .

In the mean time, Project Magician has been released that too has a command-line tool ProjectMagicianCmd.exe:

The general usage is:
ProjectMagicianCmd [-v:<version> | -n | -r | -x | -f] [<filepath>]<filename> [-l:<logfile>] [-s]

The parameters have the following meaning:

  • -v = Sets VersionInfo in dproj files to a given value. Clears all version info entries in child build configurations.
    <version> up to 4 numbers separated by dots
  • -n = Normalize
  • -r = Removes unused platforms
  • -x = Removes “Excluded Packages”
  • -f = Refreshes and adds missing form type entries
  • <filename> may contain wildcards. If no extension is given .dproj is assumed

Project Magician adds more functionality, including the ability to specify settings on project, project group and global levels. An explanation of settings is at [WayBack] Keep Your Project Files Clean With Project Magician – The Art of Delphi Programming.

These are my global default settings from the Tools -> Options menu option, then following these bits of the tree:

You can get to all levels via the Project -> Project Magician menu option, then following the various tabs:



Note that if you have combinations of installed previous versions before, that you should ensure you install the most recent versions of these, as there have been incompatibility issues between them:

  • ProjectMagician (or DProjNormalizer)
  • SelectiveDebugging

Related searches

Thread

  • Jeroen Wiert Pluimers's profile photo

    +Walter Prins interesting tool! Do you know of a tool that can downgrade .dproj files so you can use them with older Delphi versions? (the opposite of what the IDE does)?

    Or someone that has written more than my XSD on .dproj files? My one is so small that’s hardly a real attempt. https://wiert.me/2013/08/31/delphi-first-try-on-an-xsd-for-groupproj-files/

  • Walter Prins's profile photo
    +Jeroen Wiert Pluimers No, but interesting idea. I suppose you’re probably aware that the JEDI JCL/JVCL takes a somewhat similar (ish) related approach, in that it generates project and package files that are compatible with every desired version of Delphi from minimalist (XML) template files. Every so often I think it might be worth looking whether one can re-use the code from there easily but haven’t gotten around to it. Always something else to do first. :/
  • Jeroen Wiert Pluimers's profile photo
    +Walter Prins no I didn’t. Where should I start reading on that minimalist template approach?
  • Walter Prins's profile photo

    +Jeroen Wiert Pluimers  Sorry I see I missed out the word installer in my comment: It’s the Jedi JCL/JVCL installers that uses xml templates etc.

    But the point stands: I guess it should be (perhaps) possible to reuse its infrastructure for ones own projects, though as I say I keep meaning to look into this but haven’t really done so.

    (BTW I’m assuming you are familiar with the JCL/JVCL and in in particular their installers that bootstrap from source code? If not then perhaps my comments may not be that useful?)

    Anyway, not sure if or where there’s particular documentation about this (kind of doubt it), but if you have the JCL/JVCL installed somewhere, then first of all have a look at the “xml” folders e.g. “<jclroot>\jcl\packages\xmls” and “<jvclroot>\jvcl\packages\xml“.

    These files appear to define projects and packages in a seemingly abstract/somewhat minimal way using XML. This seemingly is then used to automatically produce .dproj and .dpk files which are placed in e.g. “<jclroot>\jcl\packages\dXX” and “<jvclroot>\jvcl\packages\dXX” where dXX corresponds to a folder for each of the supported Delphi versions and compiled/used during installation.

    Having just looked into this briefly a bit further as a result of this conversation: Key units here (in the case of JVCL) seems to be “jvclroot>\devtools\PackagesGenerator\PackageGenerator.pas“, “<jvclroot>\install\JVCLInstall\PackageUtils.pas” and “jvclroot>\devtools\common\PackageInformation.pas” (used predictably by <jvclroot>\JVCLInstall.dproj)

    (Additionally, having looked at this a bit more closely, it also appears that the JCL does not actually replace all or even most of its .dproj and .dpk files after all, but ships version specific .dproj and .dpk files in most cases, though the JVCL does appear to mostly do so. )

    Edit: The JCL also has this interesting sounding unit “<jclroot>\source\windows\JclMsBuild.pas” which appears to be an MSBuild project file parser…

  • Jeroen Wiert Pluimers's profile photo
    +Walter Prins​ I was aware of the bootstrap and it’s been on my “eventually I’ll take a look” list like forever. One day…
  • Walter Prins's profile photo
    Same as me then basically, ha. ^^

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Mixed JScript/batch file hybrid to create Windows shortcuts

Posted by jpluimers on 2021/03/25

I bumped into this amazing JScript/batch file hybrid. It starts as a batch file, then continues as a JScript script, and creates/updates .lnk files: [WayBack] batch.scripts/shortcutJS.bat at master · npocmaka/batch.scripts · GitHub.

Wow. Just wow.

Not that I would want to be the one maintaining it (:

Via [WayBack] batch file – How do I create a shortcut via command-line in Windows? – Stack Overflow of which I like these answers most:

  • Check the shortcutJS.bat – it is a jscript/bat hybrid and should be used with .bat extension:

    call shortcutJS.bat -linkfile "%~n0.lnk" -target  "%~f0" -linkarguments "some arguments"
    

    With -help you can check the other options (you can set icon , admin permissions and etc.)

  • Nirsoft’s NirCMD can create shortcuts from a command line, too. (Along with a pile of other functions.) Free and available here:

    http://www.nirsoft.net/utils/nircmd.html

    Full instructions here: http://www.nirsoft.net/utils/nircmd2.html#using (Scroll down to the “shortcut” section.)

    Yes, using nircmd does mean you are using another 3rd-party .exe, but it can do some functions not in (most of) the above solutions (e.g., pick a icon # in a dll with multiple icons, assign a hot-key, and set the shortcut target to be minimized or maximized).

    Though it appears that the shortcutjs.bat solution above can do most of that, too, but you’ll need to dig more to find how to properly assign those settings. Nircmd is probably simpler.

–jeroen

Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »

Thread by @mathdroid: “I now have the most swagger @github profile, EVER Sorry, your browser doesn’t support embedded videos @github Method: Download and install G […]”

Posted by jpluimers on 2021/03/24

That was such a cool idea: rickrolling your own git profile. [WayBack] Thread by @mathdroid: “I now have the most swagger @github profile, EVER […]”.

Github profile (which in the mean time changed): [WayBack] mathdroid (Odi) · GitHub.

–jeroen

Read the rest of this entry »

Posted in Development, DVCS - Distributed Version Control, Fun, GitHub, Source Code Management | Leave a Comment »

When your Delphi IDE suddenly skips unsaved changes during compilation(TL;DR: watch early signs your IDE is hosed, then restart without saving)

Posted by jpluimers on 2021/03/24

A while ago, I observed that when compiling, my Delphi IDE would not take into account unsaved changes any more.

This ws in a time when I was tracking down some hard to reproduce problems of code that sometimes would and sometimes would not compile at all.

The solution was this:

[HKEY_CURRENT_USER\Software\Embarcadero\BDS\18.0\Compiling]
"BackgroundCompilation"="False"

Somehow, the Delphi IDE had turned this flag to True without me telling it did, nor me changing an option (heck if you do a “Delphi” “BackgroundCompilation” – Google Search you hardly get any meaningful results).

Luckily, I did remember what happened around the bahaviour change: the compiler had encountered a strange error, and the IDE had become unstable.

With an unstable IDE, I did have seen damage in saved source files in the past, so I always use version control with Delphi as that allows easier to spot file differences.

What I did not anticipate was that it could corrupting my persisted IDE settings, though every now and then.

Detecting early signs of the IDE becoming unstable

  • any internal compiler error (AV or not)
  • refactoring not succeeding while it should
  • insert mode suddenly becomes override or vice versa
  • editor block selection is suddenly turned on
  • any access violation or pointer error exception

Sometimes (but not always) these can be early signs too

  • debugger blue dots not matching compiled code lines
  • the debugger not being able to debug code despite blue dots being there
  • properties in the object inspector having changed without manual action

Be prepared for an unstable IDE

  • Save your work often
  • At the earliest sign of an unstable IDE: kill (do not save work!) the affected bds.32 process using Process Explorer

BackgroundCompilation

A “Delphi” “BackgroundCompilation” – Google Search did not get much relevant results. Below are the most relevant ones I could find from it:

Too bad Google does not index the WayBack machine, as I think it contains relevant material that is now hard to find.

So it looks like the feature was introduced somewhere close to Delphi 5:

[HKEY_CURRENT_USER\Software\Borland\Delphi\5.0\Compiling]
"Show Compiler Progress"="True"
"Warn on Package Rebuild"="-1"
"Compile Beep"="0"
"Cache Headers"="0"
"BackgroundCompilation"="0"

“Delphi” “Background Compilation” – Google Search shows much more information, based on what it returned I found that the first actual documentation was for Background Compilation in Delphi 2010, some 10 years after it became available:

The image in the blog post of former product manager Andreano Lanusse shows why I did not see the behaviour: when background compiling is active, the progress dialog is transparent (and non-modal). I did not have the compiler progress enabled, so never saw that dialog change behaviour.

–jeroen

 

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | Leave a Comment »

Build your own Infrared reader head for electriciti smart meters for around USD 6: haus-automatisierung.com [4K] – YouTube

Posted by jpluimers on 2021/03/24

In German, but very interesting IR-Lesekopf für SmartMeter selber bauen | haus-automatisierung.com [4K] – YouTube:

I could not find the promised follow-up video at haus-automatisierung.com – YouTube, but the manual steps and the site below have enough information for me.

Too bad the site is way to big to fully archive in the WayBack machine. I only saved the top pages:

Related: [WayBack] MQTT-Grundlagen-Kurs – haus-automatisierung.com

–jeroen

Read the rest of this entry »

Posted in Development, Hardware Development, Hardware Interfacing, IoT Internet of Things, Raspberry Pi, Software Development | Leave a Comment »

Still unsolved since 2015 NetBeans: Bug 251538 – Your Installer is Creating Invalid Data for the NoModify DWORD Key which crashes enumeration of the Uninstall Key in at least PowerShell

Posted by jpluimers on 2021/03/23

Lovely. Having a bug reported to you in 2015, and acknowledged, that makes software crash and not fixing it.

 

For NetBeans (still one of the major IDEs) and related stuff like GlassFish, this is too true (a workaround is in the Solution steps) below: [WayBack] Bug 251538 – Your Installer is Creating Invalid Data for the NoModify DWORD Key which crashes enumeration of the Uninstall Key in at least PowerShell, and copied to [WayBack] [NETBEANS-2523] Netbeans 64-bit creates invalid nomodify value in windows registry for years – ASF JIRA.

This one appears for instance when running choco install --yes jre8 (but is certainly not limited to it) as it inspects uninstall registry values which have been corrupted and resulted into [WayBack] “Specified cast is not valid” on jre8 upgrade · Issue #18 · proudcanadianeh/ChocoPackages · GitHub.

Anyway: back to the NoModify issue:

phansson 2015-06-23 13:35:00 UTC
Yep, I can see this problem as well. I believe the problem (bug) has indeed always existed.

What happens is that someone (in this case NetBeans Installer) has put an 8-byte value into a Registry field that should only contain a 4-byte value. DWORDs are 4-byte.

If you use Registry Editor you can clearly see the problem if you look at something NBI has installed. You must look under either
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall (64-bit installers) or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall (32-bit installers). For some reason I don't see the problem for those NBI applications installed with a 32-bit installer, meaning the stuff in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall. This can probably be explained when you read the next bit.

NBI actually sets a number of Registry key values but all of them are strings, with the exception of NoModify value. As far as I know this value already defaults to true (=1) if not present so the fact that Windows cannot interpret what NBI has put into the Registry does not have much effect .... until all other kinds of tools will start to explain as you've encountered.

So, what's the problem?  As far as I can see this is really just a very simple bug. In the NBI project (NetBeans Platform source) you have a file called jni_WindowsRegistry.c which defines various JNI methods that can then be used from within Java. One of these is called 'set32BitValue0(....)'.

It looks like this:

JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_set32BitValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName, jint jValue) {
    unsigned short*  key       = getWideChars(jEnv, jKey);
    unsigned short*  name      = getWideChars(jEnv, jName);
    DWORD  dword     = (DWORD) jValue;
    LPBYTE byteValue = (LPBYTE) &dword;
    
    if (!setValue(getMode(jMode),getHKEY(jSection), key, name, REG_DWORD, byteValue, sizeof(name), 0)) {
        throwException(jEnv, "Cannot set value");
    }
    
    FREE(key);
    FREE(name);
}

One of the parameters passed to the setValue() function is the size (bytes) of the value. Unfortunately whoever made this has made a blunder by using 'sizeof(name)' for that parameter. It should have been the size of the value, not the size of the name, meaning sizeof(dword) or just a hard-coded value of 4.  Just imagine what sizeof(name) will give you if name happens to be 'NoModify'. Yep, that's right: It will be 8.

As I said, I believe this blunder has been in the code from the very beginning. It just hasn't had much effect until now.
Comment 3phansson 2015-06-24 22:12:06 UTC
See https://bitbucket.org/phansson/nbi-native-jnilib-windows
for a fix to this problem. 

Honestly the sole reason why that project exists was that I had to have this problem fixed as our corporate customers were complaining about our software "messing up their Registry" and we could not wait for NetBeans team to fix the problem.
Comment 4oldium 2017-03-03 21:28:13 UTC
Any update on this? I lost 1 hour finding why the Get-ItemProperty of Chocolatey failed and found this. Then I remembered that I had the same issue one year ago...

This issue is now 2 years old, the fix is a one-liner. Is there any plan to fix this or (I am just curious) is Netbeans project dead?
Comment 5scott.fagg 2018-04-27 03:13:04 UTC
We encounter this too. Machines with Netbeans installed on our network often encounter issues when IT roll out software installs. Fix has been to remove and recreate the offending key.

If this has been known since 2015, is there any intention of fixing it ?

I encountered it in 2019, when switching my JRE installations to become chocolatey based.

Solution steps

  1. Run the script mentioned in [WayBack] powershell – How to resolve “ERROR: Specified cast is not valid.” error during installation? – Super User:

    Run the below:

    Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | % { write-host "Key Name:" $_.PSChildName }
    

    This should return some results, then, will return the Specified cast error. The error will occur on the key harboring the invalid subkey.

  2. Then inspect the keys after that in regedit, and watch for any value of type REG_DWORD with a value (invalid DWORD (32-bit) value) (usually named NoModify
  3. Note those keys, and find them in appwiz.cpl
  4. Uninstall the accompanying software

On my systems

Delete the below pieces of crap.

Then run choco install --yes jre8 again.

  • Glassfish

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\nbi-glassfish-mod-3.1.43.0.0

  • NetBeans IDE

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\nbi-nb-base-7.0.0.0.0

Luckily, the NetBeans uninstaller can uninstall GlassFish at the same time:

Do not re-install, as they re-insert the corrupt data.

–jeroen

Posted in Development, Java, Java Platform, Software Development | Leave a Comment »

Delphi object instance lifetime demo; do not use AfterConstruction as a poor-mans way to work around non-virtual constructor or undetermined Create hierarchy calls

Posted by jpluimers on 2021/03/23

I think using AfterConstruction is a poor man’s solution that you should only use in exceptional cases, as it is:

  • called only after the last constructor in the chain is called.
  • called outside of the constructor chain (i.e. exceptions in it will not automatically call the destructor chain, nor BeforeDestruction)
  • meant to add any initialization code that requires a fully created object instance.

There were quite a few customer sites I visited that were using AfterConstruction. Usage roughly falls into two cases:

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | 1 Comment »