Loadlibrary fails to load dll

前端 未结 7 2080
梦谈多话
梦谈多话 2021-02-10 01:18
    *******************UseDll1.cpp*********************

        #include 

typedef int (*function1_ptr) ();

function1_ptr function1=NULL;

int APIENTR         


        
7条回答
  •  囚心锁ツ
    2021-02-10 01:32

    Thank you very much, your web page helped me a lot :) I only had to use tchar.h to make it working. You can see it in the rest of the answer.

    #pragma once
    #include 
    #include "spinapi.h"
    #include 
    
    typedef int (*count_boards_ptr)(void);
    
    int x = 0;
    HINSTANCE hinstDLL;
    hinstDLL = LoadLibrary(_T("C:\\Smajdalf\\doucko_C\\DLLProblem\\DLLProblem\\spinapi.dll"));
    count_boards_ptr count_boards = NULL;
    count_boards = (count_boards_ptr) GetProcAddress(hinstDLL, "pb_count_boards");
    
    if(count_boards != NULL) {
        x = count_boards();
    }
    
    FreeLibrary(hinstDLL);
    

提交回复
热议问题