dummzeuch

Aug 122017
 

Donations for GExperts keep coming in. It’s more a trickle than a flood but hey, I’m not in it for the money. And please remember that I prefer other kinds of contributions over money.

I have used that money in turn for donations to

I would have liked to also donate to PuTTY and FileZilla but I found no way to do it.

(Yes, there is a donate link on the FileZilla SourceForge page but it doesn’t work.)

Jul 302017
 

The method of changing the order of the TabSheets in a PageControl in Delphi is not obvious. Apparently there is no drag and drop support (at least not in Delphi 2007). You have to change the PageIndex property. So, if you want to insert a new page, add it and then change its PageIndex to the insert position.

I smell an opportunity for a new GExperts Expert. Any takers?

EDIT: As Moreno Zenaro pointed out in a comment to my Google+ post, there is actually a GUI way of changing the order: Drag the TabSheet in the structure view.

Jul 292017
 

As I stated before I prefer good bug reports on GExperts over money any time. Philip von Melle kept testing and providing feedback even after I thought the issue was already solved.

The issue was that a Macro Template

(%SELECTION)

used on this code

// öäüß

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowMessage('TEST');
end;

while TEST was selected
generated code like this

// öäüß

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowMessage(''); (TEST)
end;

The reason again was improper use of positions and offsets into the editor buffer in conjunction with some Unicode characters above the code. So the insert position was calculated by 4 bytes too high, hence the macro code was inserted 4 characters behind the start of the original selection.

Jul 292017
 

Note to self: Do not use a watch entry like this while debugging GExperts:

GxOtaReadEditorTextToString(GxOtaGetEditReaderForSourceEditor(nil))

While this might seem very convenient it will sooner or later corrupt the current edit buffer or do something even worse, because, as a comment in ToolsApi states:

WARNING!!!
A IOTAEditReader should never be active at the same time as an IOTAEditWriter.

But having it as a disabled entry in the watch window, enable it to inspect the current content of the edit buffer, before disabling it again can be very useful.

Jul 022017
 

dzFeedReader started as a proof of concept, but became actually a usable tool. So, why not make a release available to others?

There you go:
dzFeedReader 1.0.0 is available from SourceForge.

dzFeedReader is a program that can display rss feeds from websites in RSS 1.0, RSS 2.0 and Atom 1.0 format. Its UI is similar to that of Netvibes. It started as a Delphi program but I recently switched it to Lazarus just to see whether that development environment has become any better. Turned out Lazarus is quite usable nowadays.

Jul 012017
 

Since it became rather cumbersome to find the information on my Delphi IDE Explorer expert, which was scattered through multiple blog posts, I have now added a static page for it to my blog which I will keep up to date whenever I change anything in the expert. The sourceforge page now also points to this new page.

Jun 262017
 

Note to self: If adding a Windows 8.1 computer to a SAMBA domain fails with the error “The specified domain either does not exist or could not be contacted” the following changes to the Registry might help:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters]
; Enable NT-Domain compatibility mode
; Default:
; [value not present]
; "DomainCompatibilityMode"=-
"DomainCompatibilityMode"=dword:00000001

; Disable required DNS name resolution
; Default:
; [value not present]
; "DNSNameResolutionRequired"=-
"DNSNameResolutionRequired"=dword:00000000


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Netlogon\Parameters]
; Disable requirement of signed communication
; My Samba (3.0.33) works with signed communication enabled, so no need to disable it.
; Default:
; "RequireSignOrSeal"=dword:00000001
; Disable the usage of strong keys
; Default:
; "RequireStrongKey"=dword:00000001
"RequireStrongKey"=dword:00000000

source: the answer from gigiga in the social.technet.microsoft.com forum.

Jun 182017
 

GExperts so far comes with a special stand alone executable GExpertsGrep that does nothing else but load the GExperts dll and call the entry point ShowGrep. Having this additional executable isn’t really necessary because Windows already comes with a tool that does exactly that: Load a DLL and call an entry point: rundll32.exe

rundll32 path\to\your.dll,EntryPoint additional parameters go here

In order for a dll to be called in this manner it needs to export an entry point with the following definition:

procedure EntryPoint(_HWnd: HWND; _HInstance: HINST; _CmdLine: PAnsiChar; CmdShow: integer); stdcall;

Note that the calling convention must be stdcall otherwise bad things happen.

Since Windows NT (so for all modern versions of Windows) there are two additional ways to declare the entry point:

procedure EntryPointA(_HWnd: HWND; _HInstance: HINST; _CmdLine: PAnsiChar; CmdShow: integer); stdcall;
procedure EntryPointW(_HWnd: HWND; _HInstance: HINST; _CmdLine: PWideChar; CmdShow: integer); stdcall;

Note that EntryPoint and EntryPointA are still assumed to have a PAnsiChar parameter, while EntryPointW is assumed to have a PWideChar parameter. A Dll only needs to export one of these entry points.

If RunDll32 is called with “EntryPoint”, it will look for “EntryPointW” first, “EntryPointA” second and “EntryPoint” last. Note that you don’t have to specify the “A” or “W” suffix, it is automatically added by RunDll32.

For a change, we even have an advantage when writing the DLL in Delphi rather than in MS Visual C++: Delphi does not do any name mangling, so the entry point will be called exactly what you write in the source code.

So, assuming the GExperts DLL exports the following procedure:

procedure ShowGrepEx(_HWnd: HWND; _HInstance: HINST; _CmdLine: PAnsiChar; CmdShow: integer); stdcall;

RunDll32 could be called like this:

rundll32 path\to\GExperts.dll,ShowGrepEx Some\Directory\here

The DLL would take the _CmdLine parameter, use it as the base directory for a directory search and show you the dialog as above. Pretty cool, eh?

We could even go a step further and write the following to the registry to add an entry to the context menu of each folder in Windows Explorer.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\GExpertsGrep]
"Icon"="path\\to\\GExperts.dll"
"MUIVerb"="GExperts Grep"

[HKEY_CLASSES_ROOT\Folder\shell\GExpertsGrep\Command]
@="\"c:\\windows\\system32\\rundll32.exe\" path\\to\\GExperts.dll,ShowGrepEx %1"

(Note: Don’t just copy that to a .reg file! You need to replace both instances of “path\\to\\GExperts.dll” with the actual absolute path to your GExperts DLL. And don’t forget that the current release does not even export the entry point ShowGrepEx at all.)

And this is what you’d get:

Unfortunately there is a drawback: RunDll32 must be given the correct path and file name of the DLL to load. That’s fine if you only have one GExperts version installed. The current GExpertsGrep stand alone executable searches for the first GExperts DLL in descending order, so it will always load the one for the latest Delphi version it can find. So I am not sure whether I want to drop the stand alone executable in favor of RunDLL32 right now.

Jun 142017
 

Various people have reported an error message regarding rtl240.bpl not being found when calling the stand alone version of GExperts Grep. I could never reproduce it but my recent insight on SaveLoadLibrary now also solved that one:

The stand alone version of GExperts Grep tries to load any GExperts dll, regardless which version. The idea being that I don’t have to maintain multiple versions of the executable just to load the dll which does all the work anyway. So it tries to load the dlls in descending order, starting with the latest Delphi 10.1 (Berlin) one (I added 10.2 yesterday). But since GExperts is an IDE expert and therefore needs to use the rtl and various other packages, it of course requires them even if it is being used stand alone. And if you for whatever reason have GExperts installed for a Delphi version which you don’t have installed (or for which the packages are not in the search path), it fails to load and the error dialog described in the linked article was displayed.

It no longer does, thanks to David Heffernan’s hint.

There is no new release yet, not sure when I will have one ready.

Jun 132017
 

Note to self: Do not call SafeLoadLibrary simply as a replacement for LoadLibrary. It has a second parameter witch is used to call SetErrorMode. That parameter is optional and defaults to SEM_NOOPENFILEERRORBOX which is NOT always what you want. E.g. if the DLL you are loading depends on other DLLs which cannot be loaded, you will get a system error dialog like this one:

(My question on StackOverflow)

This might not be what you want if you are loading a DLL dynamically and want to show your own error message if it fails.

So you might want to pass a second parameter, e.g.

  Res := SafeLoadLibrary('dllname.dll', SEM_FAILCRITICALERRORS);

There might, however be a reason to call SafeLoadLibrary instead of LoadLibrary. It safes and restores the FPU Control Word. Some DLLs change it in DllMain which might cause your program to misbehave if it isn’t restored.

I remember spending days tracking down such a problem in the late 1990ies so I made it a habit calling SafeLoadLibrary rather than LoadLibrary.

On the other hand that could also happen in any other call into the DLL. So maybe it is time to revise that habit.

%d bloggers like this: