[comp.os.os2.programmer] Partial DLL installation

wolf@grasp1.univ-lyon1.fr (Christophe Wolfhugel) (05/25/91)

I have an application that *might* use one of 2 DLLs or both of                 
them. If these DLLs are defined LOADONCALL and if the application               
is run on a system that does not have the unused DLL, will it work              
or will I get a crash?                                                          
In the second case, is there any easy solution doing this, except               
compiling 3 versions of the software and taking the one corresponding           
to each workstation's configuration?                                            
                                                                                
-- 
Christophe Wolfhugel (on irc: Zolf)  |  Email: wolf@grasp1.univ-lyon1.fr
INSA Lyon - Departement Informatique |  "Ecole publique, ecole fauchee. Encore"
69621 Villeurbanne Cedex             |  "une tradition francaise dont on se"
France                               |  "passerait bien."

towfiq@FTP.COM (Mark Towfiq) (05/27/91)

>>>>> On 25 May 91 09:33:10 GMT, wolf@grasp1.univ-lyon1.fr (Christophe
>>>>> Wolfhugel) said:

Christophe> I have an application that *might* use one of 2 DLLs or
Christophe> both of them. If these DLLs are defined LOADONCALL and if
Christophe> the application is run on a system that does not have the
Christophe> unused DLL, will it work or will I get a crash? 

You will not get an error unless you try to call the function, and the
DLL is not there.  Then you will get the "Could not load the
application's segment: _BLAHBLAH is in error" message.

Christophe> In the second case, is there any easy solution doing this,
Christophe> except compiling 3 versions of the software and taking the
Christophe> one corresponding to each workstation's configuration?

Yes, there is an easier solution.  You should investigate the
DosLoadModule function, which allows you to load a DLL at run-time.
Then you just read in the address of the function you want, using the
DosGetProcAddr procedure, and call it.
--
Mark Towfiq							 towfiq@FTP.COM
Work: +1 617 246 0900					  Home: +1 617 488 2818
FTP Software, Wakefield, MA	      51 Harvard Avenue, West Medford, MA 02155

  "The Earth is but One Country, and Mankind its Citizens" -- Baha'u'llah

wtracey@betasvm2.vnet.ibm.com ("Bill Tracey") (05/29/91)

Christophe Wolfhufel writes...

>I have an application that *might* use one of 2 DLLs or both of
>them. If these DLLs are defined LOADONCALL and if the application
>is run on a system that does not have the unused DLL, will it work
>or will I get a crash?
>In the second case, is there any easy solution doing this, except
>compiling 3 versions of the software and taking the one corresponding
>to each workstation's configuration?

It has nothing with whether or not the DLL segments are marked
LOADONCALL, its whether they are linked at load time or
run time.  If you import a DLL in a .DEF file, or use an import
library to access a DLL, then you are using load time dynamic
linking for that DLL.  With load time linking, all the DLLs imported
must be present for the program to load.  If they are not, then OS/2
will refuse to start the program.

You can get around the need to have all of the DLLs present by
using run time dynamic linking.  To do this you use the DosLoadModule
and DosGetProcAddr APIs to get a pointer to the function in a DLL
and then call the function through the pointer.

Bill Tracey.