//函数指针模板的定义
template
class ProcTemplate
{
typedef ReturnType(WINAPI * PFN_PROC)(Args...);
public:
ProcTemplate(LPCTSTR pszModule, LPCSTR pszProcName)
{
m_pfn = (PFN_PROC)GetProcAddress(GetModuleHandle(pszModule), pszProcName);
}
ReturnType operator ()(Args... args)
{
return m_pfn(std::forward(args)...);
}
protected:
PFN_PROC m_pfn;
};
//模板的使用
ProcTemplate _RtlNtStatusToDosError(TEXT("Ntdll.dll"), "RtlNtStatusToDosError");
ULONG uError = _RtlNtStatusToDosError(dwErrorCode);