我一直在尝试在 Shobjdl_core.h 中挂钩 GetSelectedItems 函数
virtual HRESULT STDMETHODCALLTYPE GetSelectedItems(
/* [out] */ __RPC__deref_out_opt IShellItemArray **ppsai) = 0;
由于它是一个虚函数,我无法编译代码
HRESULT(WINAPI* TrueSleep)(IShellItemArray** ppsai) = GetSelectedItems;
// Detour function that replaces the Sleep API.
//
HRESULT WINAPI TimedSleep(IShellItemArray** ppsai)
{
return 0;
}
错误是
Severity Code Description Project File Line Suppression State
Error C2065 'GetSelectedItems': undeclared identifier DllCreateFile C:\Users\x\source\repos\DllCreateFile\DllCreateFile\dllmain.cpp 132
有挂钩类实例方法的示例吗? 唯一的链接就是这个。
解决方案是:
HRESULT(WINAPI IFileOpenDialog::* TrueSleep)(IShellItemArray** ppsai) = &IFileOpenDialog::GetSelectedItems;
// Detour function that replaces the Sleep API.
//
HRESULT WINAPI TimedSleep(IShellItemArray** ppsai)
{
// Save the before and after times around calling the Sleep API.
DWORD dwBeg = GetTickCount();
//TrueSleep(dwMilliseconds);
DWORD dwEnd = GetTickCount();
return 0;
}