Mittwoch, 4. Dezember 2013

Delphi and missing Windows API functions

When I had to write a Windows service using Delphi 2010, which is possible thanks to WinSvc.pas, which is based on winsvc.h from Windows SDK, I found several functions just missing from the pascal unit. One of the functions I missed was ChangeServiceConfig2, which I could use to set extended service properties without fiddling with registry and setting some string and DWORD values.
I decided to go deep into the old SDKs to see what version the unit represents and was very surprised that it still had more or less the stand of Win9x line, though I'm not sure of WinME because I couldn't find it's SDK or advapi32.dll. While at least the function EnumServicesStatusEx was already in NT4.0 (but not in Win98FE), many new functions came with Win2k SDK (including ChangeServiceConfig2 which I intended to use) which was released in 2000. With Delphi support for WinXP (released in 2001) which is supported since Delphi 7 (released in 2002) they still didn't implement the new and missing WinAPI bindings and this seems to be still the situation as of today.

I decided to properly implement all the missing functions and structures of winsvc.h from Win2k SDK and so far have added extensions from WinXP SDK. (Here it's just the same as Win2k + two new constants) and currently I'm in the process of adding the extensions which came with Windows Vista, but this is WIP yet.

Because the might be several other API binding missing I decided to create a small project for this, so all the binding extensions can live in one central place. You will find the WIP source and the "stable" releases of the units here: https://github.com/rarog/winapi-for-delphi.

Keine Kommentare:

Kommentar veröffentlichen