windows - CoInternetIsFeatureEnabled i Delphi2010

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg forsøger at deaktivere den irriterende lyd, når du klikker på et link i WebBrowser-kontrol, uden at ændre brugerregistret. Jeg har fundet dokumentation om, at dette kan gøres gennem CoInternetIsFeatureEnabled, også forklaret her.Men jeg har ingen idé om, hvordan man implementerer det på Delphi 2010, da jeg får fejl i 'Undeclared Identifier' efter at have inkluderet URLMon enhed i projektet og ikke meget dokumentation derude. [4]


Nogle ideer?

Bedste reference


CoInternetIsFeatureEnabled() og CoInternetSetFeatureEnabled() er ikke inkluderet i D2010s kopi af UrlMon.pas. Du skal deklarere dem manuelt, fx:


const
  GET\_FEATURE\_FROM\_THREAD = $00000001;
  GET\_FEATURE\_FROM\_PROCESS = $00000002;
  GET\_FEATURE\_FROM\_REGISTRY = $00000004;
  GET\_FEATURE\_FROM\_THREAD\_LOCALMACHINE = $00000008;
  GET\_FEATURE\_FROM\_THREAD\_INTRANET = $00000010;
  GET\_FEATURE\_FROM\_THREAD\_TRUSTED = $00000020;
  GET\_FEATURE\_FROM\_THREAD\_INTERNET = $00000040;
  GET\_FEATURE\_FROM\_THREAD\_RESTRICTED = $00000080;

  SET\_FEATURE\_ON\_THREAD = $00000001;
  SET\_FEATURE\_ON\_PROCESS = $00000002;
  SET\_FEATURE\_IN\_REGISTRY = $00000004;
  SET\_FEATURE\_ON\_THREAD\_LOCALMACHINE = $00000008;
  SET\_FEATURE\_ON\_THREAD\_INTRANET = $00000010;
  SET\_FEATURE\_ON\_THREAD\_TRUSTED = $00000020;
  SET\_FEATURE\_ON\_THREAD\_INTERNET = $00000040;
  SET\_FEATURE\_ON\_THREAD\_RESTRICTED = $00000080; 

type
  INTERNETFEATURELIST = (
    FEATURE\_OBJECT\_CACHING,
    FEATURE\_ZONE\_ELEVATION,
    FEATURE\_MIME\_HANDLING,
    FEATURE\_MIME\_SNIFFING,
    FEATURE\_WINDOW\_RESTRICTIONS,
    FEATURE\_WEBOC\_POPUPMANAGEMENT,
    FEATURE\_BEHAVIORS,
    FEATURE\_DISABLE\_MK\_PROTOCOL,
    FEATURE\_LOCALMACHINE\_LOCKDOWN,
    FEATURE\_SECURITYBAND,
    FEATURE\_RESTRICT\_ACTIVEXINSTALL,
    FEATURE\_VALIDATE\_NAVIGATE\_URL,
    FEATURE\_RESTRICT\_FILEDOWNLOAD,
    FEATURE\_ADDON\_MANAGEMENT,
    FEATURE\_PROTOCOL\_LOCKDOWN,
    FEATURE\_HTTP\_USERNAME\_PASSWORD\_DISABLE,
    FEATURE\_SAFE\_BINDTOOBJECT,
    FEATURE\_UNC\_SAVEDFILECHECK,
    FEATURE\_GET\_URL\_DOM\_FILEPATH\_UNENCODED,
    FEATURE\_TABBED\_BROWSING,
    FEATURE\_SSLUX,
    FEATURE\_DISABLE\_NAVIGATION\_SOUNDS,
    FEATURE\_DISABLE\_LEGACY\_COMPRESSION,
    FEATURE\_FORCE\_ADDR\_AND\_STATUS,
    FEATURE\_XMLHTTP,
    FEATURE\_DISABLE\_TELNET\_PROTOCOL,
    FEATURE\_FEEDS,
    FEATURE\_BLOCK\_INPUT\_PROMPTS,
    FEATURE\_ENTRY\_COUNT
  );

function CoInternetIsFeatureEnabled(FeatureEntry: INTERNETFEATURELIST; dwFlags: DWORD): HRESULT; stdcall; external 'urlmon.dll'
function CoInternetSetFeatureEnabled(FeatureEntry: INTERNETFEATURELIST; dwFlags: DWORD; fEnable: BOOL): HRESULT; stdcall; external 'urlmon.dll'

begin
  if CoInternetIsFeatureEnabled(FEATURE\_DISABLE\_NAVIGATION\_SOUNDS, GET\_FEATURE\_FROM\_PROCESS) = S\_FALSE then
    CoInternetSetFeatureEnabled(FEATURE\_DISABLE\_NAVIGATION\_SOUNDS, SET\_FEATURE\_ON\_PROCESS, True); 
end;