Modifying group policies programmatically is hairy and dangerous. (See this example for adding a startup script to group policy.) I'm not sure specifically where the setting is for "Always use custom logon background" in the registry, but I'm certain that there's more than one value you'll have to modify for the result you're expecting.
You're really better off using Windows' Group Policy Management Editor.