TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Kelly Schrock
date: 1995-01-12 00:43:04
subject: Module file name

Hello,

I need to retrieve the currently executing program's fully qualified
filename from within an application. Normally, this would be a piece of
cake, but here are the catches:

The argv[0] parameter passed to main() doesn't work with all compilers, and
this code needs to work with all compilers. I.e., IBM's compiler, I
believe, only passes what was typed at the command line.

So, I'm using DosQueryModuleName().

The call to DosQueryModuleName() is in a DLL. This is where I'm stuck.
I have 2 choices here: one, to use the extern ULONG _os2hmod variable
as the "ModHandle" parameter to that call which works great when the
call to DosQueryModuleName() comes from inside an .EXE file. From
inside the DLL, it returns a 0-length string. I can get the module
handle of the DLL and pass it to DosQueryModuleName(), but that returns
the fully qualified pathname of the DLL, not the EXE file.

Has anyone ever done this? If so, how!?

Thanks,
Kelly

___
 X KWQ/2 1.2g NR X If at first you don't succeed, put it out for beta test.

--- Maximus/2 2.02
* Origin: OS/2 Shareware BBS, Fairfax, VA: 703-385-4325 (1:109/347)
SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430
SEEN-BY: 711/807 808 809 934 942 949 712/353 515 713/888 800/1 7877/2809
@PATH: 109/347 2 7 3615/50 229/2 12/2442 711/409 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.