What's new?
18 februari 2002
Lan Manager header files (lm*.h).
Reason for this addition is twofold:
- The LM.pas interface unit included in this package was getting out of
synch with the original from Petr and errors were creeping in. Conversion
from scratch was imo the only way to remove all these errors.
- The original LM interface units were done by Petr and his copyright. This
somewhat limits me in my freedom to do as I want with those units.
Petr's original LM interface unit is still included (JwaLM.pas) for those that
are already using it. New development should use either Petr's original units
(available from http://www.delphi-jedi.org) or the new units included in this
release (the individual JwaLmXYZ.pas units, not JwaLM.pas). Existing applications
should continue to use the JwaLM.pas unit as the new units are different in many
aspects (e.g. in the conversion of parameters, types and so forth).
Eventually JwaLM.pas from Petr will be removed...
Up to date with November 2002 Platform SDK
The units are now up to date with the November 2002 release of the Platform SDK.
This means that the included units are up to date with their equivalent header
files in the PSDK, not that all header files are converted - obviously..
The only files that are not yet up to date are:
- NtDsApi.pas
- NtSecPkg.pas
- WinCrypt.pas
Hopefully I'll be able to attend to these soon.
8 januari 2002
The most significant change in this release is the addition of dynamic linking
support for all units. By default dynamic linking is turned off, to turn on
dynamic linking remove the dot in the line:
{.$DEFINE DYNAMIC_LINK}
inside WinDefines.inc. In this release this will turn on dynamic linking for all
interface units, in a future release I might add support to contorl this on a
unit-by-unit basis. Dynamic linking is supported by using a small assembler stub
that loads the DLL on demand only when the routine is actually used. There is no
need to call any special initialization routine, all happens automatically.
Thanks goes out to the guys in borland.public.delphi.basm for their help in
implementing this.
Please note that currently there is no way to find out upfront whether or not a
required library is present on the system other than explicitly testing this
yourself using LoadLibrary(), a future release might add support for this. In
case the required library is not present on the system, an exception is raised.
The exception is either EJwaLoadLibraryError or EJwaGetProcAddressError (both
defined in JwaWinType and descended from EJwaError) if LoadLibrary() or
GetProcAddress() fails respectively. Therefor, you'll need to protect your API
calls using a try...except block like this:
var
H: HANDLE;
begin
try
H := CreateFile(...);
if H <> INVALID_HANDLE_VALUE then
begin
...
CloseHandle(H);
end;
except
on EJwaError do
begin
// Either CreateFile or CloseHandle could not be found, handle that
// situation somehow.
end;
end;
end;
Known issues
- All functions with the cdecl calling convention do not yet support dynamic
linking. This mostly involves JwaWinBer and JwaWinLdap but there exist a few
other instances.
- There are still plenty of TODO markers :-(
- The JwaAdsTLB unit has a few errors. This is a type library import and the
errors are a result of bugs in the Delphi type library importer, not mine.
Thanks to Chris Burr for pointing this out, sorry Chris but I haven't had
time to fix it yet.
Sponsorship and contributing
Converting header files is a lot of work which I do completely in my own time.
If you've found these units usefull, like the fact that they're completely free,
and like to contribute to further development and the conversion of even more
header files you can do so in many ways. Contact me at brakelm@chello.nl for
further information.
One possible way, and a nice gesture, would be to buy me something of
my wish-list.
Installation
The Win32 interface units do not need explicit installation but you do need to
make sure that Delphi can find them. There are two ways to accomplish this,
using Project Options or Environment Options. First you need to extract the zip
into a directory of your liking, we'll refer to this directory as $(WIN32API).
Now follow either of the steps outlined in the next two sections.
Using Project Options
From the IDE menu select "Project > Options" and switch to the
"Directories/Conditionals" page in the dialog that appears. Find the edit box
labelled "Search Path", type in the $(WIN32API) path and select OK. Alternatively
you can use the ellipsis button to navigate to the directory in question. You
will need to repeat this for every new project you start that uses the Win32 API
interface units.
Using Environment Options
From the IDE menu select "Tools > Environment Options" and switch to the "Library"
page in the dialog that appears. Find the edit box labelled "Library Path", it
should contain something along the lines of "$(DELPHI)\Lib;$(DELPHI)\Bin;$(DELPHI)\Imports;$(DELPHI)\Projects\Bpl".
Change this to include the $(WIN32API) directory. For example, assuming you've
unzipped the Win32Api.zip file to "c:\win32api":
"$(DELPHI)\Lib;$(DELPHI)\Bin;$(DELPHI)\Imports;$(DELPHI)\Projects\Bpl;c:\win32api".
Don't forget to seperate using a semicolon. You don't have to manually edit this
string, you can press the ellipsis button to navigate to the $(WIN32API) directory
and add it automatically. After pressing OK Delphi will be able to find the units
for every new project without the need to specify the directory again.
If you performed the steps above you can start using the units in your application
by including the appropriate ones in your uses clause. I personally prefer to
use Project Options instead of Environment Options to avoid problems. One known
problem is that when you use the Enironment Options method, you might get compiler
errors when trying to build the JEDI Code Library.
Using the units
When you use these interface units keep in mind that they duplicate a lot of
what's in the interface units that ship with Delphi, such as Windows.pas. These
units can co-exist but you need to make sure that you do not mix the usage of them
too much. For example, either use Windows.pas or the equivalents in this library
but not both, otherwise you might run into incompatibilities between them resulting
in compile errors. The easiest way is to not include both in the uses clause of
your own units. If this is impossible for some reason you're best of using explicit
unit qualification when using anything. For example, instead of using "CreateProcess"
use either "Windows.CreateProcess" or "JwaWinBase.CreateProcess". If you do not use
unit qualification you end up using the one from the unit last mentioned in the
uses clause.
The most common error you're likely to encounter is:
"Incompatible types: 'System.WideChar' and 'JwaWinType'.WideChar" where WideChar
is only an example. This is due to the fact that the RTL (e.g. System.pas or
Windows.pas) defines the type WideChar differently from WinType.pas. To solve
this simply change the declaration in JwaWinType.pas to become an alias for the
type in System.pas (or Windows.pas). For example
Before:
type
DWORD = Longword;
After:
type
DWORD = Windows.DWORD;
If you look inside JwaWinType.pas you see that I've already done this for the most
common types (using conditional compilation) like this
type
DWORD = {$IFDEF USE_DELPHI_TYPES}Windows.DWORD{$ELSE}Longword{$ENDIF};
therefore it's unlikely you'll run into this problem. However, if you do please
notify me so I can update the interface units.
Please note that these units heavily use conditional compilation. You can
globally change some settings, and thereby determine how they get compiled,
through the WinDefines.inc include file. An example of this would be to specify
an unicode build. There are a few more directives which cannot be set globally
(yet), look through the unit itself to find them. Full documentation for all
directives will be provided in a later release.
Also note that all LanManager units (LM*.pas) were combined into a single
unit LM.pas for convenience. The same applies to the Ads*.pas units which
were combined into ActiveDS.pas and all Rpc*.pas files which were combined
into Rpc.pas. Furthermore, the LanManager translation was done by Petr Vones
and is included with his permission. The WinLDAP unit was created by Luk Vermeulen.
Copyright
These units are distributed under the terms of of the MPL, or optionally the
terms of the LGPL. What this means is that they are completely free and can
be used in all development, even commercial applications. I have a few requests
though:
- Please redistribute only using the MPL/LGPL dual license eventhough you
are legally allowed to redistribute using only MPL or LGPL.
- Please read, or have your legal department read, through the text of the
MPL and/or
LGPL to make sure
you understand your rights and obligations.
- If neither the MPL and LGPL fit your needs you I can grant you a different
license.
Contact me for more information. Depending on the details, this will
cost you something though (dunno what exactly yet, perhaps a monetary
donation or a free copy of your product, we'll see).
Please be aware that the WinLDAP unit was created by Luk Vermeulen and can only
be used and distributed under the MPL license. It's included because of dependencies
on this unit. I may convert the header myself one day.
Coming soon
- Delphi 2/3 compatible version
- Probably not much else, rather busy these days
Feedback
Any and all feedback can be send to
brakelm@chello.nl. Please do not send me any generic API related questions,
for that you should use the Borland newsgroups
(see the Borland Community site for
more information). Questions directly related to the use, or problems encountered
by the use of, these units can of course be directed at the above address. Please
include the phrase "Win32Api" in the subject header.
Request an interface unit
If you're in desperate need of an interface unit for some C/C++ API you can
send me a request
through e-mail. I cannot promise that I will convert the unit(s) within any
particular time frame, or at all, but I will let you know about it. Note that
you can also hire me to do header conversions, in that case I will guarentee
delivery within a certain time frame which depends on the header(s) themselves.
Mail me at the above address for more information.