如何在运行时检查Win API函数支持?

时间:2014-06-16 10:45:56

标签: c++ windows api

如何在运行期间检查运行时是否支持函数GetSystemTimePreciseAsFileTime

1 个答案:

答案 0 :(得分:4)

使用着名的GetProcAddress来查找函数的存在,就像这样

typedef void (WINAPI *FuncT) (LPFILETIME lpSystemTimeAsFileTime);

HINSTANCE hDLL = LoadLibrary(L"Kernel32.dll");
FuncT GetSystemTimePreciseAsFileTime = (Func) GetProcAddress((HMODULE)hDLL, L"GetSystemTimePreciseAsFileTime");

if (GetSystemTimePreciseAsFileTime)
{
   // function is exposed by the DLL, now it can be called
   GetSystemTimePreciseAsFileTime(...);
}