How to add custom css file by code? Well I know that I have to use drupal_add_css like described here.

But that doesn't work and I don't understand why.

I tried to use this hooks: function hook_init, hook_views_pre_render, hook_preprocess_html and hook_preprocess_page.

I tried in that hooks this code:

$css=drupal_add_css(drupal_get_path('module', 'mymodule') . '/style.css');
$variables['styles'] = drupal_get_css($css);


or:

drupal_add_css(drupal_get_path('module', 'mymodule') . '/style.css');
$variables['styles'] = drupal_get_css();


or also just the first line.

also:

drupal_add_css("/".drupal_get_path('module', 'mymodule') . '/style.css');


or that:

drupal_add_css(drupal_get_path('module', 'mymodule') . '/style.css',
               array('group' =&gt; CSS_DEFAULT, 'every_page' =&gt; TRUE));


Here is my style.css:

#logo {
    display:none;
}


That should hide the logo on success. What is wrong with my tries?
in hook_init, removing the first slash should solve the problem. If not, check for permissions.

drupal_add_css("/".drupal_get_path('module', 'mymodule') . '/style.css');


Should be 

drupal_add_css(drupal_get_path('module', 'mymodule') . '/style.css');