[comp.windows.ms.programmer] Having an EXE and DLL of the same name

jls@hsv3.UUCP (James Seidman) (02/13/91)

I'm probably missing something really obvious here.  I have a program
which requires a DLL to go along with it.   I'd like to have them named
the same (e.g. XYZPROG.EXE and XYZPROG.DLL).  The problem is that when
I try to declare an import function from the DLL in the DEF for the EXE,
link complains about a "self-import," thinking the EXE is trying to import
from itself.

I'd really prefer not to have to import the functions explicitly.  Is
there some simple way around this problem?  Thanks in advance.

-- 
Jim Seidman (Drax), the accidental engineer.
"It doesn't have to work... they'll be paralyzed just from laughing at me."
							- Dr. Who, _Shada_
UUCP: ames!vsi1!hsv3!jls	         INTERNET: hsv3.UUCP!jls@apple.com

jporter@twaddle.dell.com (Jeff Porter) (02/13/91)

In article <7134@hsv3.UUCP>, jls@hsv3.UUCP (James Seidman) writes:
|> 
|> I'm probably missing something really obvious here.  I have a program
|> which requires a DLL to go along with it.   I'd like to have them named
|> the same (e.g. XYZPROG.EXE and XYZPROG.DLL).  The problem is that when
|> I try to declare an import function from the DLL in the DEF for the EXE,
|> link complains about a "self-import," thinking the EXE is trying to import
|> from itself.
|> 

Windows only allows either a DLL or EXE with a given name.  It's a
documented feature in the SDK manuals.

Jeff Porter

ed@odi.com (Ed Schwalenberg) (02/13/91)

In article <15097@uudell.dell.com> jporter@twaddle.dell.com (Jeff Porter) writes:
  In article <7134@hsv3.UUCP>, jls@hsv3.UUCP (James Seidman) writes:
  |> 
  |> I'm probably missing something really obvious here.  I have a program
  |> which requires a DLL to go along with it.   I'd like to have them named
  |> the same (e.g. XYZPROG.EXE and XYZPROG.DLL).

  Windows only allows either a DLL or EXE with a given name.  It's a
  documented feature in the SDK manuals.

Oh, twaddle.  (Sorry, I couldn't resist.)
Look at PBRUSH.EXE/PBRUSH.DLL in your Windows directory with EXEHDR.
The secret is that the module name of PBRUSH.EXE is actually PBRUSHX.
Develop XYZPROG.DLL and XYZPROGX.EXE, then rename the latter to XYZPROG.EXE
before execution and you're all set.

jls@hsv3.UUCP (James Seidman) (02/14/91)

In article <15097@uudell.dell.com> jporter@twaddle.dell.com (Jeff Porter) writes:
>Windows only allows either a DLL or EXE with a given name.  It's a
>documented feature in the SDK manuals.

Yes, but I've actually seen programs distributed which had a DLL and an
EXE with the same name.  Perhaps they got away with it by importing all
the functions explicitly at runtime.  Maybe I'll see if I can track one
down and run EXEHDR on it.

-- 
Jim Seidman (Drax), the accidental engineer.
"It doesn't have to work... they'll be paralyzed just from laughing at me."
							- Dr. Who, _Shada_
UUCP: ames!vsi1!hsv3!jls	         INTERNET: hsv3.UUCP!jls@apple.com

jporter@twaddle.dell.com (Jeff Porter) (02/14/91)

In article <1991Feb13.151814.25905@odi.com>, ed@odi.com (Ed Schwalenberg) writes:
|> In article <15097@uudell.dell.com> jporter@twaddle.dell.com (Jeff Porter) writes:
|>   In article <7134@hsv3.UUCP>, jls@hsv3.UUCP (James Seidman) writes:
|>   |> 
|>   |> I'm probably missing something really obvious here.  I have a program
|>   |> which requires a DLL to go along with it.   I'd like to have them named
|>   |> the same (e.g. XYZPROG.EXE and XYZPROG.DLL).
|> 
|>   Windows only allows either a DLL or EXE with a given name.  It's a
|>   documented feature in the SDK manuals.
|> 
|> Oh, twaddle.  (Sorry, I couldn't resist.)
|> Look at PBRUSH.EXE/PBRUSH.DLL in your Windows directory with EXEHDR.
|> The secret is that the module name of PBRUSH.EXE is actually PBRUSHX.
|> Develop XYZPROG.DLL and XYZPROGX.EXE, then rename the latter to XYZPROG.EXE
|> before execution and you're all set.

That'll teach me to believe what I read!!! :-)

Jeff Porter

nate@hplvec.LVLD.HP.COM (Nathan Berg) (02/14/91)

>I'm probably missing something really obvious here.  I have a program
>which requires a DLL to go along with it.   I'd like to have them named
>the same (e.g. XYZPROG.EXE and XYZPROG.DLL).  The problem is that when
>I try to declare an import function from the DLL in the DEF for the EXE,
>link complains about a "self-import," thinking the EXE is trying to import
>from itself.
>
>I'd really prefer not to have to import the functions explicitly.  Is
>there some simple way around this problem?  Thanks in advance.
>
set the 'NAME' field in your DLL .DEF file to a different value than the
'NAME' field in your program's .DEF file...
Regards,
Nathan
-------------
Nathan Berg                              Measurement Systems Operation R&D Lab
nathan_berg@hpisla.lvld.hp.com           Hewlett-Packard, CU-325
[ihnp4|hplabs]!hpislx!nate               815 14th Street Southwest
(303) 679-2424                           P.O. Box 301
FAX (303) 679-5957                       Loveland, CO  80537  USA