How can I detect if the current viewed page is administrative?
This can be done with path_is_admin(current_path()).

For example, the following hook implementation can be used.

function mymodule_init() {
  if (user_access('administer modules') &amp;&amp; path_is_admin(current_path())) {
      drupal_set_message(t('Message'));
  }
}