3

I am trying to deactivate the annoying sound when clicking a link in WebBrowser control, WITHOUT changing the user registry. I've found documentation that this can be done through CoInternetIsFeatureEnabled, also explained here. But i have no idea how to implement it on Delphi 2010, since i am getting "Undeclared Identifier" error after including URLMon unit into the project and not much documentation out there.

Any ideas?

Community
  • 1
  • 1
Elias
  • 31
  • 1
  • You might get some tips from this page. http://www.koders.com/delphi/fid9C9871FBCA710621B778496CC84F0FB4B5D48218.aspx?s=cryptoapi – Mikael Eriksson Jan 15 '11 at 22:01
  • Yes im trying to get some light from that code, but not much luck so far... thats from the embededWB (which i dont wanna use in my app), but i still cant make that CoInternetIsFeatureEnabled work in delphi – Elias Jan 16 '11 at 09:25

1 Answers1

5

CoInternetIsFeatureEnabled() and CoInternetSetFeatureEnabled() are not included in D2010's copy of UrlMon.pas. You will have to declare them manually, eg:

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;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 1
    For reference, I believe this works if the logic is altered: The snippet is testing if the feature is enabled, and if so, enable it. It should be testing to see if the feature is not enabled, then enable it. (For this scenario, instead of testing against S_OK, test against S_FALSE) – Darian Miller Mar 29 '11 at 16:46
  • @RemyLebeau In XE4 and XE5 UrlMon is missing many interfaces. I wonder why isn't it being updated even though its from Embarcadero? For example `IInternetBindInfoEx,IInternetProtocolEx,IUri` just to name a few. –  Sep 28 '13 at 16:45
  • You will have to ask Embarcadero about that, and file a QC ticket to mention the missing interfaces. – Remy Lebeau Sep 28 '13 at 19:57
  • @RemyLebeau I'll post a question. It seems they rely on JEDI to convert the headers for them. –  Sep 28 '13 at 22:10