Loading All Imports for a Delay-Loaded DLL
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Loading All Imports for a Delay-Loaded DLL

The __HrLoadAllImportsForDll function, which is defined in delayhlp.cpp, tells the linker to load all imports from a DLL that was specified with the /delayload linker option.

Loading all imports allows you to put error handling in one place in your code and not have to use exception handling around the actual calls to the imports. It also avoids a situation where your application fails partially through a process as a result of the helper code failing to load an import.

Calling __HrLoadAllImportsForDll does not change the behavior of hooks and error handling; see Error Handling and Notification for more information.

The following example shows how to call __HrLoadAllImportsForDll:

if (FAILED(__HrLoadAllImportsForDll("delay1.dll"))) {
   printf ( "failed on snap load, exiting\n" );
   exit(2);
}
Show:
© 2016 Microsoft