There is a really simple solution to this given by Microsoft: https://docs.microsoft.com/en-us/cpp/c-language/expanding-wildcard-arguments?view=msvc-170
Basically, you just link with one of two libraries that will expand wildcards into the argv[] list fed to your program.
To clarify by example, say you have the code:
// ExampleFileExpansion.cpp : This outputs the cmd line arguments
//
#include <iostream>
#include <tchar.h>
using namespace std;
int wmain(int argc, _TCHAR* argv[]) {
for (int i = 0; i < argc; i++) {
wcout << i << "\t" << argv[i] << endl;
}
}
Which normally gives output like:
C:\x64\Debug>ExampleFileExpansion *.*
0 ExampleFileExpansion
1 .
Within Visual Studio, navigate to the project properties page and choose the linker input options | Additional Dependencies. Then, add the library (in this case "wsetargv.obj") and apply the change. Then, Build the project again, from the main menu.
After the change, running the same code gives something like:
C:\x64\Debug>ExampleFileExpansion *.*
0 ExampleFileExpansion
1 ExampleF.a660785c.tlog
2 ExampleFileExpansion.exe
3 ExampleFileExpansion.exe.recipe
4 ExampleFileExpansion.ilk
5 ExampleFileExpansion.log
6 ExampleFileExpansion.obj
7 ExampleFileExpansion.pdb
8 ExampleFileExpansion.vcxproj.FileListAbsolute.txt
9 vc143.idb
10 vc143.pdb
Here are some screen shots from VS 2022 to illustrate the steps:
Visual Studio Project Properties Menu
Choose Linker input options, then Edit to get the dialog
Enter the appropriate obj file name either wsetargv.obj or setargv.obj depending on whether wmain or main function is declared