You can think of the interface between Basic and the Windows API as a legal contract. On the one side, Basic wishes to acquire certain services and resources. On the other side, the Windows API is in the business of providing those services and resources. However, since each party is providing information that could be dangerous to the other, and since the parties don’t speak the same language, both feel the need for a legal contract spelling out the terms and limits of the transaction.
The Windows API provides its side of the contract as part of the specifications of its DLLs. These are spelled out in the API documentation and are partially enforced by the actual DLL interfaces. Visual Basic submits a legal request in the form of a Declare statement. It checks the declaration against the DLL interface and rejects anything incompatible.
As any lawyer can tell you, it’s impossible to fully specify the terms of a transaction in a legal contract. You try to define everything you can think of and handle the rest on an ad hoc basis. If something goes wrong, you can sue after the fact. Unfortunately, “lawsuits” in the Windows world often end up as unhandled exceptions, general protection faults, unrecoverable application errors, and cold boots. The next sections explain how far the API contract goes and how to avoid conflicts in areas the law doesn’t cover.