First of all, the button is visible only if the user has a privilege that grants access to it.
So you don't need to check it in code.
On top of that, you can still enable/disable it in code, based on your custom logic.
However as general information there are some ways to evaluate user permissions in code:
1) You can check in code if an user has access to a menu item button using the AccessRights class but normally you don't need to.
2) You can query SystemSecurityUserRoleEntity and join it to SystemSecurityPrivilege entity to find out which privileges the current user has access to. Or, use SystemSecurityPermissionEntity to find out on menu item level what is the user's access level.
But you don't need to! The security framework handles it for you automatically.