M
mystudy
Unregistered / Unconfirmed
GUEST, unregistred user!
比葫芦画瓢写了这个东西,但是注册后还是不能屏蔽IE弹出的对话框,
大家看看为什么会这样
unit bdnetiemsg;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, ActiveX, Classes, ComObj,IeConst,Registry,Urlmon;
type
TIEBrowserHelperFactory = class(TComObjectFactory)
private
procedure AddKeys;
procedure RemoveKeys;
public
procedure UpdateRegistry(Register: Boolean)
override;
end;
type
Tbdnetiemsg = class(TComObject,IDOCHOSTSHOWUI, IDownloadManager)
protected
function ShowMessage(hwnd: THandle
lpstrText: POLESTR
lpstrCaption: POLESTR;
dwType: longint
lpstrHelpFile: POLESTR
dwHelpContext: longint;
var plResult: LRESULT): HRESULT
stdcall;
function ShowHelp(hwnd: THandle
pszHelpFile: POLESTR
uCommand: integer;
dwData: longint
ptMouse: TPoint;
var pDispatchObjectHit: IDispatch): HRESULT
stdcall;
function Download(
pmk: IMoniker
// Identifies the object to be downloaded
pbc: IBindCtx
// Stores information used by the moniker to bind
dwBindVerb: DWORD
// The action to be performed during the bind
grfBINDF: DWORD
// Determines the use of URL encoding during the bind
pBindInfo: PBindInfo
// Used to implement IBindStatusCallback::GetBindInfo
pszHeaders: PWidechar
// Additional headers to use with IHttpNegotiate
pszRedir: PWidechar
// The URL that the moniker is redirected to
uiCP: UINT // The code page of the object's display name
): HRESULT
stdcall
end;
const
Class_bdnetiemsg: TGUID = '{FE56E4DE-095C-4B9D-AD6C-0D10C71BE3CD}';
implementation
uses ComServ, Unit1;
{ Tbdnetiemsg }
function Tbdnetiemsg.Download(pmk: IMoniker
pbc: IBindCtx
dwBindVerb,
grfBINDF: DWORD
pBindInfo: PBindInfo
pszHeaders, pszRedir: PWidechar;
uiCP: UINT): HRESULT;
begin
if form1=nil then form1:=Tform1.Create(nil);
form1.Show;
Result := S_OK;
end;
function Tbdnetiemsg.ShowHelp(hwnd: THandle
pszHelpFile: POLESTR;
uCommand, dwData: Integer
ptMouse: TPoint;
var pDispatchObjectHit: IDispatch): HRESULT;
begin
result:=s_ok;
end;
function Tbdnetiemsg.ShowMessage(hwnd: THandle
lpstrText,
lpstrCaption: POLESTR
dwType: Integer
lpstrHelpFile: POLESTR;
dwHelpContext: Integer
var plResult: LRESULT): HRESULT;
begin
if form1=nil then form1:=Tform1.Create(nil);
form1.Show;
result:=S_ok
end;
{ TIEBrowserHelperFactory }
procedure TIEBrowserHelperFactory.AddKeys;
var
S: string;
begin
S := GUIDToString(Class_bdnetiemsg);
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('Software/Microsoft/Windows/CurrentVersion/explorer/Browser Helper Objects/' + S, TRUE)
then CloseKey;
finally
free;
end;
end;
procedure TIEBrowserHelperFactory.RemoveKeys;
var
S: string;
begin
S := GUIDToString(Class_bdnetiemsg);
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
DeleteKey('Software/Microsoft/Windows/CurrentVersion/explorer/Browser Helper Objects/' + S);
finally
free;
end;
end;
procedure TIEBrowserHelperFactory.UpdateRegistry(Register: Boolean);
begin
inherited UpdateRegistry(Register);
if Register then AddKeys else RemoveKeys;
end;
initialization
TComObjectFactory.Create(ComServer, Tbdnetiemsg, Class_bdnetiemsg,
'bdnetiemsg', '', ciMultiInstance, tmApartment);
end.
大家看看为什么会这样
unit bdnetiemsg;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, ActiveX, Classes, ComObj,IeConst,Registry,Urlmon;
type
TIEBrowserHelperFactory = class(TComObjectFactory)
private
procedure AddKeys;
procedure RemoveKeys;
public
procedure UpdateRegistry(Register: Boolean)
override;
end;
type
Tbdnetiemsg = class(TComObject,IDOCHOSTSHOWUI, IDownloadManager)
protected
function ShowMessage(hwnd: THandle
lpstrText: POLESTR
lpstrCaption: POLESTR;
dwType: longint
lpstrHelpFile: POLESTR
dwHelpContext: longint;
var plResult: LRESULT): HRESULT
stdcall;
function ShowHelp(hwnd: THandle
pszHelpFile: POLESTR
uCommand: integer;
dwData: longint
ptMouse: TPoint;
var pDispatchObjectHit: IDispatch): HRESULT
stdcall;
function Download(
pmk: IMoniker
// Identifies the object to be downloaded
pbc: IBindCtx
// Stores information used by the moniker to bind
dwBindVerb: DWORD
// The action to be performed during the bind
grfBINDF: DWORD
// Determines the use of URL encoding during the bind
pBindInfo: PBindInfo
// Used to implement IBindStatusCallback::GetBindInfo
pszHeaders: PWidechar
// Additional headers to use with IHttpNegotiate
pszRedir: PWidechar
// The URL that the moniker is redirected to
uiCP: UINT // The code page of the object's display name
): HRESULT
stdcall
end;
const
Class_bdnetiemsg: TGUID = '{FE56E4DE-095C-4B9D-AD6C-0D10C71BE3CD}';
implementation
uses ComServ, Unit1;
{ Tbdnetiemsg }
function Tbdnetiemsg.Download(pmk: IMoniker
pbc: IBindCtx
dwBindVerb,
grfBINDF: DWORD
pBindInfo: PBindInfo
pszHeaders, pszRedir: PWidechar;
uiCP: UINT): HRESULT;
begin
if form1=nil then form1:=Tform1.Create(nil);
form1.Show;
Result := S_OK;
end;
function Tbdnetiemsg.ShowHelp(hwnd: THandle
pszHelpFile: POLESTR;
uCommand, dwData: Integer
ptMouse: TPoint;
var pDispatchObjectHit: IDispatch): HRESULT;
begin
result:=s_ok;
end;
function Tbdnetiemsg.ShowMessage(hwnd: THandle
lpstrText,
lpstrCaption: POLESTR
dwType: Integer
lpstrHelpFile: POLESTR;
dwHelpContext: Integer
var plResult: LRESULT): HRESULT;
begin
if form1=nil then form1:=Tform1.Create(nil);
form1.Show;
result:=S_ok
end;
{ TIEBrowserHelperFactory }
procedure TIEBrowserHelperFactory.AddKeys;
var
S: string;
begin
S := GUIDToString(Class_bdnetiemsg);
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('Software/Microsoft/Windows/CurrentVersion/explorer/Browser Helper Objects/' + S, TRUE)
then CloseKey;
finally
free;
end;
end;
procedure TIEBrowserHelperFactory.RemoveKeys;
var
S: string;
begin
S := GUIDToString(Class_bdnetiemsg);
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
DeleteKey('Software/Microsoft/Windows/CurrentVersion/explorer/Browser Helper Objects/' + S);
finally
free;
end;
end;
procedure TIEBrowserHelperFactory.UpdateRegistry(Register: Boolean);
begin
inherited UpdateRegistry(Register);
if Register then AddKeys else RemoveKeys;
end;
initialization
TComObjectFactory.Create(ComServer, Tbdnetiemsg, Class_bdnetiemsg,
'bdnetiemsg', '', ciMultiInstance, tmApartment);
end.