PRB: "Error in Loading DLL" if Calling Multimedia API Functions

Last reviewed: November 25, 1996
Article ID: Q159408
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 32-bit only, for Windows, version 4.0

SYMPTOMS

When you call multimedia API functions from 32-bit Visual Basic for Windows using the Declare statements retrieved from the 32-bit API Text Viewer, the following error message appears:

   "Error in loading DLL"

CAUSE

The error occurs because the 32-bit API Text Viewer incorrectly uses the Declare statements for Mmsystem.dll, which is a 16-bit DLL.

MORE INFORMATION

A 32-bit program cannot directly execute functions in a 16-bit DLL. A thunking layer is required. The thunking layer allows you to load a 16-bit DLL and place the processor in 16-bit mode so you can execute the appropriate code. However, Visual Basic for Windows cannot implement a thunking layer and its use is not supported. There are two ways around this behavior:

  1. See the following article in the Microsoft Knowledge Base that describes how to call the 16-bit Mmsystem.dll functions:

    ARTICLE-ID: Q141939

       TITLE     : How to Create an OLE Server to Implement Thunking
    
    

  2. Call the functions from Winmm.dll, the Windows 95 thunking library for multimedia. (In Windows 95, the multimedia functions are still 16-bit and Winmm.dll is a 32-bit wrapper that calls Mmsystem.dll.) This method requires the proper Declare statements for Winmm.dll.


KBCategory: kbtool
KBSubcategory: PrgOther
Additional reference words: 4.00 vb4win vb432 kbstream



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 25, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.