Hello,
this GPIO use-case is shown in the example "DeviceIntegration" that you will find within your STM32 Build Environment within the subdirectory /Examples. This demo shows how to switch on/off the hardware LED when you press a button within a GUI application.
Please have a look to the chapter Device Class and Device Driver? It describes the necessary concepts.
Best regards,
Manfred.