#include #include int main(int argc, char *argv[]) { LONG ref_count; HANDLE hLib; if(argc != 2) { printf("Syntax: loaddll.exe library.dll\n"); return -1; } hLib = GetModuleHandle(argv[1]); printf("existing module %s handle is %p\n", argv[1], hLib); printf("Loading %s...", argv[1]); hLib = LoadLibrary(argv[1]); if (hLib) { printf("\nLibrary loaded successfully. hLib = %p\n", hLib); ref_count = 0; while (FreeLibrary(hLib)) ref_count++; printf("ref count = %d\n", ref_count); } else printf("\nLoadLibrary() failed. Error %u\n", GetLastError()); return 0; }