Guidelines for Writing ACM Drivers
Use the following guidelines when writing an ACM driver:
·Allocate driver instance data when the driver receives a DRV_OPEN message, as explained in the description of DRV_OPEN.
·Allocate stream instance data when the driver receives an ACMDM_STREAM_OPEN message, as explained in the description of ACMDM_STREAM_OPEN.
·Do not use global variables. Defining a single DWORD of global data in a DLL allocates 4K of memory in every process that uses the ACM, because your driver is mapped into the address space of each process, and global data space is not shared. Instead of using global data, dynamically allocate local storage space for each driver instance and each stream instance, as needed.
·Do not link to crtdll.dll, the dynamic-link version of the C runtime library. This DLL cannot be loaded into all contexts. As a result, your driver will not work correctly for system sounds that are played by means of the MessageBeep function. Use Win32 API functions instead of C library functions, or link to a static C runtime library (libc.lib or libcmt.lib).
·Be careful when calling Win32 functions. If your driver is used in conjunction with playing system sounds, it might get loaded into a context in which these functions fail. This warning pertains to any Win32 function that requires an instance handle, and possibly other functions. Notice, for example, that if the samples call LoadString or LoadIcon, they do not test for error return values. If you strictly follow the model provided by the sample drivers, you will not have this problem.