EzhNotes

October 30, 2009

Override default firefox behavior from an extension

Filed under: programming — Tags: — alexezh @ 8:27 pm

There are number of ways to replace the default behavior for the firefox. If you want to replace a method on the object, following code will do the trick

eval("object.method =" + object[method].toString().replace('{', '{ your code here ;'));

In case if code is event handler for XUL object, you have to create a handler with the same event and return false to prevent further processing

  <binding id="my-id"
           extends="chrome://browser/content/id_to_extend">
    <handlers>
      <handler event="event to override">
      <![CDATA[
        your code here;

        return false;
      ]]></handler>
    </handlers>
  </binding>  

Advertisements

March 24, 2008

find location of installed application by app name

Filed under: programming, windows — alexezh @ 1:33 am

HRESULT hr = S_OK;
CComPtr spDocklet;
CRegKey rkAppPaths;
CRegKey rkApp;
WCHAR szPath[MAX_PATH];
ULONG cchPath;
CAtlString szAppPath;
LONG lRes;

lRes = rkAppPaths.Open(HKEY_LOCAL_MACHINE, L”SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths”, KEY_READ);
if(lRes != ERROR_SUCCESS)
{
goto Cleanup;
}

lRes = rkApp.Open(rkAppPaths, pszApp);
if(lRes != ERROR_SUCCESS)
{
goto Cleanup;
}

cchPath = sizeof(szPath) / sizeof(WCHAR);
lRes = rkApp.QueryStringValue(L”Path”, szPath, &cchPath);
if(lRes != ERROR_SUCCESS)
{
goto Cleanup;
}

szAppPath.Format(L”%s%s”, szPath, pszApp);

Create a free website or blog at WordPress.com.