Hello, I am working on a dll that is being loaded by browsers. I have to check if the hostname of a requested site is in a database containing sites that has to be blocked. I am using the following code to connect to the db:
Code:
BOOL ret = FALSE;
_ConnectionPtr pConn = NULL;
_CommandPtr pCmd = NULL;
_RecordsetPtr pRs = NULL;
try
{
  pConn.CreateInstance(__uuidof(Connection));
  pCmd.CreateInstance(__uuidof(Command));
  pRs.CreateInstance (__uuidof (Recordset));	
  pConn->Open(_bstr_t(L"Provider=MSDASQL.1;Data Source="C:\xxx"), _bstr_t(L""), _bstr_t(L""), adOpenUnspecified);
  pCmd->ActiveConnection = pConn;
  pCmd->CommandType=adCmdText;
  wcscpy_s(query, 2*_MAX_PATH, L"SELECT site FROM Allow WHERE site='");
  wcscat_s(query, 2*_MAX_PATH, wszHost);
  wcscat_s(query, 2*_MAX_PATH, L"'");
  pCmd->CommandText = (_bstr_t)query;
  pRs->CursorLocation = adUseClient;
  pRs->Open((IDispatch*)pCmd, vtMissing, adOpenStatic, adLockReadOnly, adCmdText);
  if(pRs->RecordCount > 0)
    ret  = TRUE;
}
catch(_com_error error)
{
  dbgprint("\tDescription = %s\n", (char*) error.Description());
  dbgprint("\tSource = %s\n", (char*) error.Source());
  dbgprint("\tCode = %08lx\n", error.Error());
  dbgprint("\tCode meaning = %s\n", error.ErrorMessage());
  return TRUE;
}
catch(...)
{
  return TRUE;
}
The strange thing is that this code is running fine with Internet Explorer but when the dll is loaded by Firefox pConn->Open() fails with Invalid pointer error. Any suggestions will be greatly appreciated. Thank you.
Martin