HRESULT ShowShellDocViewMenu(LPDISPATCH lpDocDisp, POINT pt, UINT nCmdID)
...{
HRESULT hr = S_FALSE;
IOleCommandTarget *pct;
if ( lpDocDisp && SUCCEEDED(lpDocDisp->QueryInterface(IID_IOleCommandTarget, (void **)&pct)))
...{
try
...{
CComVariant vtIn;
vtIn.vt = VT_I4;
vtIn.lVal = MAKELONG(pt.x, pt.y);
CComVariant vtOut;
hr = pct->Exec(&CGID_ShellDocView, nCmdID, OLECMDEXECOPT_DONTPROMPTUSER, &vtIn, &vtOut);
}
catch (...) ...{
}
pct->Release();
}
return hr;
}
这个是调用IE管理加载项的代码,不知道怎么专程delphi,帮忙下,谢谢了。
------解决方案--------------------------------------------------------
var
hr:HRESULT;
pct:^IOleCommandTarget;
vtin,vtout:TVarRec;
begin
hr := S_FALSE;
if (lpDocDisp<>nil) and (lpDocDisp^.QueryInterface(IID_IOleCommandTarget,@pct)=S_OK)
then
try
vtIn.vt = VT_I4;
vtIn.lVal = pt.x+(pt.y shl 16); //MAKELONG(pt.x, pt.y);
hr := pct^.Exec(@CGID_ShellDocView, nCmdID,OLECMDEXECOPT_DONTPROMPTUSER, @vtIn, @vtOut);
finally
pct^.Release;
end;
result:= hr;
end;
希望能帮到你
------解决方案--------------------------------------------------------
vtIn.lVal = pt.x+(pt.y shl 16); //MAKELONG(pt.x, pt.y);
这行应该改为
vtIn.lVal = pt.x or DWORD(pt.y shl 16); //MAKELONG(pt.x, pt.y);