In the Microsoft Windows environment, an application should perform
only those operations specified by the Windows application programming
interface (API). Specifically, a Windows-based application should not:
- Use processor I/O instructions.
- Issue software interrupts.
- Install interrupt handlers.
These three operations should be done only in a Windows dynamic-link
library (DLL).
The Windows API has been designed to let programmers write applications in
a hardware-independent fashion. However, some programmers may have noticed
that the three operations mentioned previously can be performed from both
Windows DLLs and applications.
Therefore, it may be tempting to avoid coding these operations in a
DLL, especially if the DLL's only purpose is to execute functions that
seem to operate correctly in an application. However, Microsoft
strongly recommends against this practice, for the following two
reasons:
- Future Compatibility. Changes may be made to Windows in future
versions such that applications that perform these operations
directly may not execute reliably.
- Portability. Applications that perform these operations directly
will be more difficult to port to different hardware platforms
(such as Windows running on a different machine architecture).
In summary, executing low-level operations from within a Windows-based
application may, in a future version of Windows, produce unexpected
results, generate unnecessary maintenance overhead, and have severe
impact on the potential lifetime of that application. To avoid these
problems, machine-specific functionality should be coded in a DLL.