#define QMPLUGIN_API extern "C" __declspec(dllexport)
typedef int (*QMPLUGIN_HANDLER)(char *lpszParamList, char *lpszRetVal);
typedef struct {
    char *m_lpszCommandName;
    char *m_lpszCommandDescription;
    QMPLUGIN_HANDLER m_pHandlerFunction;
    UINT m_nParamNumber;
} QMPLUGIN_CMD_INFO;
typedef QMPLUGIN_CMD_INFO* (*CommandFunc)(int iCommandNum);    HINSTANCE thDll;
    thDll = LoadLibrary("xxxxxplugin.dll");     if (thDll != NULL)
    { 
        CommandFunc someFunc = (CommandFunc)GetProcAddress(thDll, "GetCommand"); 
        if (someFunc != NULL) 
        {
            QMPLUGIN_CMD_INFO* abc = someFunc(0);
            printf("the function description is %s\n", abc->m_lpszCommandDescription); 
        }else
        {
            printf("Load Function Error\n");
        }        FreeLibrary(thDll);
    }else{
        printf("Load DLL Error\n");
    } 
 

解决方案 »

  1.   


      type
        QMPLUGIN_CMD_INFO  = record
           m_lpszCommandName, m_lpszCommandDescription: Pchar;
           m_pHandlerFunction: QMPLUGIN_HANDLER;
           m_nParamNumber: UINT;
        end;
        PQMPLUGIN_CMD_INFO = ^QMPLUGIN_CMD_INFO;    QMPLUGIN_HANDLER = function(lpszParamList, lpszRetVal: pchar): integer;
        QMPLUGIN_CMD_INFO = function(iCommandNum: integer): PQMPLUGIN_CMD_INFO;  var
        thDll: HINST;
        someFunc: CommandFunc;
        abc: PQMPLUGIN_CMD_INFO;
      begin
      thDll := LoadLibrary('xxxxxplugin.dll');  if thDll <> 0 then
      begin
        someFunc := GetProcAddress(thDll, 'GetCommand');
        if @someFunc <> nil then
        begin
          abc := someFunc(0)
        end  end;
      FreeLibrary(thDll);