Yes. There is a function for that in the Godot.OS Class:
//
// Summary:
// Returns the name of the host OS. Possible values are: "Android", "iOS", "HTML5",
// "OSX", "Server", "Windows", "UWP", "X11".
[GodotMethodAttribute("get_name")]
public static string GetName();
Is there a way to do this using preprocessor directives?
(This is a bit late, I know) In Godot C# you can use preprocessor defines.
public override void _Ready()
{
#if GODOT_SERVER
// Don't try to load meshes or anything, this is a server!
LaunchServer();
#elif GODOT_32 || GODOT_MOBILE || GODOT_WEB
// Use simple objects when running on less powerful systems.
SpawnSimpleObjects();
#else
SpawnComplexObjects();
#endif
}