The `GetModuleFileName` API accepts a null pointer as the first argument to mean
the current executable.
int r;
char line[BSZ];
char* s;
- MEMORY_BASIC_INFORMATION mbi;
- if (VirtualQuery (&main, &mbi, sizeof(mbi)) == 0) {
- fprintf (stderr,"failed to get handle for executable.\n");
- graphviz_exit(1);
- }
- r = GetModuleFileName ((HMODULE)mbi.AllocationBase, line, BSZ);
+ r = GetModuleFileName(NULL, line, BSZ);
if (!r || (r == BSZ)) {
fprintf (stderr,"failed to get path for executable.\n");
graphviz_exit(1);