diff -Naur tinycc-current/tcc.c tinycc/tcc.c
--- tinycc-current/tcc.c	Tue Apr 29 13:12:42 2008
+++ tinycc/tcc.c	Tue Apr 29 13:28:38 2008
@@ -221,7 +221,8 @@
 } Section;
 
 typedef struct DLLReference {
-    int level;
+    int level;
+	void * hInst;	// HINSTANCE
     char name[1];
 } DLLReference;
 
@@ -10226,7 +10227,15 @@
 
     for(i = 1; i < s1->nb_sections; i++)
         free_section(s1->sections[i]);
-    tcc_free(s1->sections);
+    tcc_free(s1->sections);
+	
+	/* free any loaded DLLs */
+	for ( i = 0; i < s1->nb_loaded_dlls; i++)
+	{
+		DLLReference * ref = s1->loaded_dlls[i];
+		if ( ref->hInst )
+			FreeLibrary(ref->hInst);
+	}
     
     /* free loaded dlls array */
     dynarray_reset(&s1->loaded_dlls, &s1->nb_loaded_dlls);
diff -Naur tinycc-current/tccpe.c tinycc/tccpe.c
--- tinycc-current/tccpe.c	Tue Apr 29 13:12:42 2008
+++ tinycc/tccpe.c	Tue Apr 29 13:27:39 2008
@@ -472,16 +472,21 @@
 {
     char buffer[100];
     int sym_index, dll_index;
-    void *hModule, *addr, **m;
+    void *addr, **m;
+	DLLReference * dllref;
 
     sym_index = pe_find_import(s1, symbol);
     if (0 == sym_index)
         return NULL;
-    dll_index = ((Elf32_Sym *)s1->dynsymtab_section->data + sym_index)->st_value;
-    hModule = LoadLibrary(s1->loaded_dlls[dll_index-1]->name);
-    addr = GetProcAddress(hModule, symbol);
+    dll_index = ((Elf32_Sym *)s1->dynsymtab_section->data + sym_index)->st_value;
+	dllref = s1->loaded_dlls[dll_index-1];
+	if ( !dllref->hInst )
+	{
+		dllref->hInst = LoadLibrary(dllref->name);
+	}
+    addr = GetProcAddress(dllref->hInst, symbol);
     if (NULL == addr)
-        addr = GetProcAddress(hModule, get_alt_symbol(buffer, symbol));
+        addr = GetProcAddress(dllref->hInst, get_alt_symbol(buffer, symbol));
 
     if (addr && STT_OBJECT == type) {
         /* need to return a pointer to the address for data objects */
@@ -1415,7 +1420,8 @@
         case 2:
             dllref = tcc_malloc(sizeof(DLLReference) + strlen(dllname));
             strcpy(dllref->name, dllname);
-            dllref->level = 0;
+            dllref->level = 0;
+			dllref->hInst = 0;
             dynarray_add((void ***) &s1->loaded_dlls, &s1->nb_loaded_dlls, dllref);
             ++state;
 
