Xceed Zip for COM/ActiveX on x86/x64 Documentation
Direct DLL API / DLL API Exported Functions structure
In This Topic
    DLL API Exported Functions structure
    In This Topic

    When you need to call exported functions in a DLL, but cannot link with any library that resolves all these calls, you normally need to call the LoadLibrary function on the DLL and then obtain a pointer to each procedure you want to use with a call to the GetProcAddress function.

    But the GetProcAddress can do more than provide you with a pointer to exported functions. It can also retrieve exported global variables. The xceedzip.dll file possesses a specially exported variable, which is a structure made of a pointer to each exported function. This structure's data is set when the DLL is loaded, and is of type XceedZipFunctions. Its exported variable name is g_xzFunctions.

    To use the xceedzip.dll API interface without linking with xceedzip.lib, all you need is the following code:

    VC++ Copy Code

    /* Load the DLL */

    HINSTANCE hXceedDll = LoadLibrary ( "XCEEDZIP.DLL" ); 

    if ( hXceedDll )
    {
       /* Get a pointer to the functions structure */ 
       XceedZipFunctions* pFuncs = ( XceedZipFunctions * ) GetProcAddress( hXceedDll, "g_xzFunctions" );  

       if ( pFuncs ) 
       { 
          /* You are now ready to use the DLL API interface, but you must make your */
          /* calls to the exported functions */
          /* using pointers in this structure. For example: */ 

          pFuncs->lpfnXceedZipInitDLL(); 
          HXCEEDZIP hZip = pFuncs->lpfnXzCreateXceedZipA( "???" );  

          if ( hZip ) 
          { 
             /* Etc */ 
             pFuncs->lpfnXzDestroyXceedZip( hZip ); 
          } 
          pFuncs->lpfnXceedZipShutdownDLL(); 
       } 
       /* Free the library */ 
       FreeLibrary( hXceedDll ); 
    }