Tr1 :: function WINAPI

How can I use the tr1 :: function with a WINAPI call? (at least in the windows). I can use Visual C ++ 9 SP1 TR1 or BOOST alone ...

typedef void (WINAPI *GetNativeSystemInfoPtr)(LPSYSTEM_INFO);
HMODULE h = LoadLibrary (_T("Kernel32.dll"));
GetNativeSystemInfoPtr fp = (GetNativeSystemInfoPtr) GetProcAddress (h,"GetNativeSystemInfo");
SYSTEM_INFO info;
fp(&info); //works!

// This doesn't compile 
function< void WINAPI (LPSYSTEM_INFO) > fb = (GetNativeSystemInfoPtr) GetProcAddress (h,"GetNativeSystemInfo");
+3
source share
1 answer

This compiles:

#include <boost/function.hpp>
#include <windows.h>


int main(void)
{
    typedef void (WINAPI *GetNativeSystemInfoPtr)(LPSYSTEM_INFO);
    HMODULE h = LoadLibrary (("Kernel32.dll"));
    GetNativeSystemInfoPtr fp = (GetNativeSystemInfoPtr) GetProcAddress (h,"GetNativeSystemInfo");
    SYSTEM_INFO info;
    fp(&info); //works!

    boost::function< void (LPSYSTEM_INFO) > fb = (GetNativeSystemInfoPtr) GetProcAddress (h,"GetNativeSystemInfo");
    SYSTEM_INFO info2;
    fb(&info2);


    return 0;
}

and the info content is the same as the info2 content, so it works.

, , boost:: function, (). , . , boost:: function , , , .

+2

Source: https://habr.com/ru/post/1732031/


All Articles