Getting the current module name
If your module file is sites/default/modules/MYMODULE/MYMODULE.module
then module name is MYMODULE.
You can get it programmatically inside MYMODULE.module file using following command:
$module_name = basename(__FILE__, '.module');
Although OP was asking regarding D7, here's the solution for Drupal 8 (D8) as well:
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
$module_handler = \Drupal::service('module_handler');
/** @var \Drupal\Core\Extension\Extension $module_object */
$module_object = $module_handler->getModule(basename(__FILE__, '.module'));
$module_name = $module_object->getName();
Of course, you can chain these calls if necessary:
\Drupal::service('module_handler')->getModule(basename(__FILE__, '.module'))->getName()