Something like this I think:
```c++
template <typename ReturnType, typename...Args>
class DynFunc final
{
public:
	typedef ReturnType(WINAPI* DynFuncType)(Args...);

	DynFunc() = delete;
	DynFunc(const DynFunc&) = delete;
	DynFunc& operator=(const DynFunc&) = delete;

	DynFunc(const CString& dll, const CStringA& func) {
		ASSERT(!dll.IsEmpty());
		ASSERT(!func.IsEmpty());
		m_hLib = LoadLibrary(dll);
		m_pDynFunc = reinterpret_cast<DynFuncType>(GetProcAddress(m_hLib, func));
	}

	~DynFunc() {
		FreeLibrary(m_hLib);
	}

	explicit operator bool() const {
		return !!m_pDynFunc;
	}

	ReturnType operator()(Args...args) {
		return m_pDynFunc(args...);
	}

private:
	HMODULE m_hLib = nullptr;
	DynFuncType m_pDynFunc = nullptr;
};

// used like this in any scope we want
DynFunc<HRESULT, HINSTANCE, PCWSTR, int, int, HICON*> loadIconWithScaleDown = {"comctl32.dll", "LoadIconWithScaleDown"};
```