用c、delphi分别写了个dll,然后用c来调用,c+delphi时,执行到FreeLibrary出错
注:c使用wxDev-C ++ 7.3.1开发,GCc编译。delphi使用delphi2007.操作系统为windows7。1、调用程序#include <stdio.h>
#include <stdlib.h>
#include <windows.h>int main(int argc, char *argv[])
{
    HINSTANCE hInstance = LoadLibrary("hello.dll");
    if(hInstance!=NULL)
    {
        typedef int (WINAPIV* GetCountFunc)(void);
        GetCountFunc GetCount=(GetCountFunc)GetProcAddress(hInstance,"GetCount");
        int count=GetCount();
        printf("%d",count);
    }
    //FreeLibrary(hInstance); 
    return 0;
}2、用c写的dll代码
(1) dll.h#ifndef _DLL_H_
#define _DLL_H_#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */DLLIMPORT WINAPIV int GetCount(void);#endif /* _DLL_H_ */(2) dllmain.c#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "dll.h"DLLIMPORT WINAPIV int GetCount(void)
{   
    return 10020;
}BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
        break;      case DLL_PROCESS_DETACH:
        break;      case DLL_THREAD_ATTACH:
        break;      case DLL_THREAD_DETACH:
        break;
    }    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}
3、delphi开发的dll源代码Library hello;
Uses
  ShareMem,
  SysUtils,
  Classes;Function GetCount(): integer; Cdecl; Export;
Begin
  Result := 10010;
End;Exports
  GetCount;
{$R *.res}
Begin
End.