I think, using <code>pgmptr</code> doesn't really solve the problem. Reading the microsoft msdn pages, i see:

<blockquote>
When a program is run from the command interpreter (Cmd.exe), _pgmptr is automatically initialized to the full path of the executable file. For example, if Hello.exe is in C:\BIN and C:\BIN is in the path, _pgmptr is set to when you execute:
Copy

C> hello

When a program is not run from the command line, _pgmptr might be initialized to the program name (the file's base name without the file name extension) or to a file name, relative path, or full path.
</blockquote>
If the fossil.exe is called by tools like the value of pgmptr may be a relative or absolute path or only the filename.