With runprogram you should be able to pass the workspace information as well. The workspace name is the full path to the .WS file and since this path may have spaces you need to surround it in double quotes, e.g.
dbexplor.exe "-xc:\DataFlex 19.0 Examples\Order Entry\Programs\"
The code using the registry may fail because:
- You don't have rights to read it
- You aren't using a 64 bit version of the OS
- You don't have rights to write the DDB string
- ...