Example #1
0
static BOOL WinDialFindConnectionDesc(LPCWSTR name, LPRASCONNW connection)
{
  LPRASCONNW connections = NULL;
  DWORD bufferSize = 0, n = 0, ret, i;
  BOOL found = FALSE;
  ret = RasEnumConnectionsW(NULL, &bufferSize, &n);
  if(ERROR_BUFFER_TOO_SMALL != ret)
    goto cleanup;
  connections = (RASCONNW*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufferSize);
  connections[0].dwSize = sizeof(RASCONNW);
  ret = RasEnumConnectionsW(connections, &bufferSize, &n);
  if(ERROR_SUCCESS != ret)
    goto cleanup;  
  for(i = 0; i< n; ++i)
    if(0 == wcscmp(name, connections[i].szEntryName))
    {        
      found = TRUE;
      if(connection)
        *connection = connections[i];
      break;
    }
cleanup:
  if(connections)
    HeapFree(GetProcessHeap(), 0, connections);
  return found;
}
Example #2
0
// Check to see if RAS is already connected.
bool nsAutodial::IsRASConnected()
{
    DWORD connections;
    RASCONN rasConn;
    rasConn.dwSize = sizeof(rasConn);
    DWORD structSize = sizeof(rasConn);

    DWORD result = RasEnumConnectionsW(&rasConn, &structSize, &connections);

    // ERROR_BUFFER_TOO_SMALL is OK because we only need one struct.
    if (result == ERROR_SUCCESS || result == ERROR_BUFFER_TOO_SMALL)
    {
        return (connections > 0);
    }

    LOGE(("Autodial: ::RasEnumConnections failed: Error = %d", result));
    return false;
}