Does anyone care about this? (With apologies to the "the wrapper should
only be used for services" folks.)
With the idea of making a wrapperW.exe, the solution seems to go about
like this (some refinements and more testing needed). Modify
wrapper_win.c
replace:
void _CRTAPI1 main(int argc, char **argv) {
with something like this, then compile it as a Win32 application:
void _CRTAPI1 myMain(int argc, char **argv);
#ifdef _WIN32
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nShowCmd ) {
char** argv = malloc(sizeof(char *)*1);
MSG msg;
BOOL bRet;
char appName[MAX_PATH];
GetModuleFileName(hInstance, appName, sizeof(appName)-1);
argv[0] = appName;
myMain (1, argv);
// Start the message loop.
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
#else {
void _CRTAPI1 main(int argc, char **argv) {
main(argc, argv);
}
#endif
// renamed main.
void _CRTAPI1 myMain(int argc, char **argv) {
[...]
The problem is that I don't parse the arguments - just push in argv[0].
The lpCmdLine string seems to be pretty close, but I think that it's
missing argv[0] - the application name.
There are a number of examples of parsing and creating an argv and argc.
For example, this message seems to contain the code:
http://public.kitware.com/pipermail/cmake/2004-June/005170.html
This seems close:
http://wwwhome.cs.utwente.nl/~gansevle/win32/wstart/wstart.c
But the most thorough work I've found is here
http://cvs.sourceforge.net/viewcvs.py/fellow/fellow/SRC/WIN32/C/WINMAIN.C?view=markup
from the "fellow" project:
http://sourceforge.net/projects/fellow
This code is GPL'd and so incompatible with the Wrapper license. I
expect that if we asked, they'd allow the wrapper to use that piece of
code (bottom 1/3 of the file or so), but someone would have to be
intereted enough to ask.
Jim
--
Jim Redman
(505) 662 5156 x85
http://www.ergotech.com
|