How to unlock the device programmatically if PIN lock is used

we have a c++ program that manages cellular broadband on Windows, but it cannot setup a cellular network connection if the sim card is locked, is there any way to unlock the device programmatically before setup network connection?

A subset of the mobile broadband API includes the PIN Management API can do this, but the sample code is written in c#, it's better to get C++ code example or a script, thanks.

https://docs.microsoft.com/en-us/windows-hardware/drivers/mobilebroadband/unlock-a-device https://github.com/oldnewthing/old-Windows8-samples/blob/master/MobileBroadbandCom/js/MbnComWrapper/PinWrapper.cs