How do I use gpg2.exe in GPG4Win to programatically generate a keypair?

–gen-key expects console input. I tried to create a program in VB6 that uses the ActiveX DLL file for Windows Script Host Object Model (which has a neat feature that it makes console communications very easy) to hook the console of gpg2.exe, so that instead of providing the inputs to the key generator wizard via a literal console, it would provide them via my program instead.

Problem is, gpg2.exe does NOT send stdout to my program, and instead displays it in its console, and another problem is gpg2.exe does NOT accept stdin commands from my program. It only accpts input from the literal console. I need a way to force gpg2.exe when running with the command “–gen-key” (or another command, who’s sole purpose is to allow easy interfacing with a GUI for key generation) to actually accept console signals from my program.

Is there any way to do this? Or is gpg2.exe intended to operate as a standalone program?