You can use the findFiles XF.
See
https://www.originlab.com/doc/X-Function/ref/findFiles
I tested with the following very simple code to list templates that begins with B
findfiles path:=system.path.program$ ext:="B*.otp*";
int nn = fname.GetNumTokens(CRLF);
for(int ii = 1; ii <= nn; ii++)
{
string fn$ = fname.GetToken(ii, CRLF)$;
fn$=;
}