DLL vs LIB

HMG en Español

Moderator: Rathinagiri

jorge.posadas
Posts: 174
Joined: Mon May 19, 2014 7:43 pm
DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
Location: Morelia, Mich. México
Contact:

DLL vs LIB

Post by jorge.posadas »

Grupo,

Hace muchisimo tiempo que usando clipper logre hace una libreria, encadenarla a mis PRG y luego usarla, ahora con el nacimiento de HMG, he leido sobre DLL mi pregunta es:

Cual es la diferencia entre DLL y LIB?
Cuando se debe usar LIB y cuando una DLL
Hay ventas de una sobre la otra?

Y por terminar,

Ejemplo,

LnCustomerId :=GetNextNumber("customer_id")


*------------------------------------------------------------------------------*
FUNCTION GetNextNumber(PsModule)
*------------------------------------------------------------------------------*
LdDateSQL := "DATE('NOW')"
LsTimeSQL := "TIME('NOW','LOCALTIME')"
LsModule := C2SQL(PsModule)
GnNextNumber := 0
IF .NOT. ConectMe()
MsgExclamation ("No me pude conectar a la base de datos")
RETURN NIL
ELSE
GsRead := "SELECT Module, Last_Number, "
GsRead += "(Last_Number + Sequence_Count) AS [Next_Number] "
GsRead += "FROM Folios WHERE LOWER(Module) = LOWER(&LsModule)"
IF TryToLock()
aTableNextNum := sql(oDataBase,GsRead)
IF LEN(aTableNextNum) = 0
MsgExclamation("No se encontro el modulo para la numeracion")
DeleteFileLock()
RETURN NIL
EndIf
GnNextNumber := aTableNextNum[1,3]
GsQueryInsert := "UPDATE Folios SET "
GsQueryInsert += "Last_Number = (Last_Number + Sequence_Count), "
GsQueryInsert += "Modify_Date = "+LdDateSQL +", "
GsQueryInsert += "Modify_Time = "+LsTimeSQL
GsQueryInsert += "WHERE LOWER(Module) = LOWER(&LsModule)"
IF .NOT. BeforeSave(GsQueryInsert)
MsgExclamation ("Error al tratar de obtener el folio siguiente.")
ENDIF
DeleteFileLock()
ENDIF
ENDIF
RETURN ( VAL(GnNextNumber ))

Pregunta: Como convierto esa pequea function en DLL y como se debe de llamar en un PRG.

De antemano agradezco la ayuda.
Cordialmente

POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: posoft@gmx.com
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: DLL vs LIB

Post by Rathinagiri »

Difference between DLL and LIB:

DLL is dynamically linked library (ie., linked at the runtime). LIB is statically linked library inside the EXE.

DLL can be reused by many EXE files. LIB once attached to the EXE can be used by only that EXE.

Other than that, I don't see much of a difference between these two.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: DLL vs LIB

Post by serge_girard »

Thanks for clarification Rathi!

Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3723
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: DLL vs LIB

Post by mol »

Can sb. place small sample how to load dll into .exe and later unload it?
Regards, Marek
mlnr
Posts: 126
Joined: Fri Aug 28, 2015 1:52 pm
DBs Used: DBF

Re: DLL vs LIB

Post by mlnr »

Code: Select all

If !File("example.dll")
  MsgInfo ('Missing file: EXAMPLE.DLL')
  ReleaseAllWindows()
Endif
regikez:=ErrorBlock({ |objerr| ujkez(objerr,.T.) })
Begin Sequence
   jDll := hb_libLoad( hb_DirBase() + "example.dll" )
   IF !Empty( jDll )
      hb_DynCall( { "VerzioSzam", jDll, HB_DYN_CALLCONV_CDECL, HB_DYN_CTYPE_DOUBLE},@DllVersion)
      If DllVersion>1.1
         PcNev := hb_DynCall( { "PcNeve", jDll, hb_bitOr( HB_DYN_CALLCONV_STDCALL, HB_DYN_ENC_UTF16, HB_DYN_CTYPE_CHAR_PTR ),HB_DYN_CTYPE_CHAR_PTR },'*' )
      EndIf
    Else
      MsgInfo ('The program was not able to start correctly' + Chr(13) + Chr(10) + ' Please install .net framework 4' )
   EndIf
Recover Using objlocal
End Sequence
ErrorBlock(regikez) 

unload:

hb_libFree( hLib )
Best regards,
Gabor
User avatar
Anand
Posts: 595
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF

Re: DLL vs LIB

Post by Anand »

Rathinagiri wrote:Difference between DLL and LIB:

DLL is dynamically linked library (ie., linked at the runtime). LIB is statically linked library inside the EXE.

DLL can be reused by many EXE files. LIB once attached to the EXE can be used by only that EXE.
Further with what Rathi said, calling functions in a DLL is same like calling in your codes, if the dll is linked statically with lib. Whereas calling the function requires dllcall with defined parameters if it is dynamically linked.

Regards,

Anand
Regards,

Anand

Image
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: DLL vs LIB

Post by srvet_claudio »

The only advantage of the dll is when a very large library is shared by multiple applications or require frequent updating in library functions, so the dll is used in the practice only by software developers for programmers.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: DLL vs LIB

Post by Rathinagiri »

Rightly said Claudio.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
jorge.posadas
Posts: 174
Joined: Mon May 19, 2014 7:43 pm
DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
Location: Morelia, Mich. México
Contact:

Re: DLL vs LIB

Post by jorge.posadas »

Grupo,

Gracias a todos por sus comentarios, ahora me tocara investigar COMO se crea una DLL y luego el COMO se usa en mis aplicaciones
Cordialmente

POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: posoft@gmx.com
Carlos Britos
Posts: 245
Joined: Sat Aug 02, 2008 5:03 pm

Re: DLL vs LIB

Post by Carlos Britos »

jorge.posadas wrote:Grupo,

Gracias a todos por sus comentarios, ahora me tocara investigar COMO se crea una DLL y luego el COMO se usa en mis aplicaciones
Hi Jorge

Crear una dll con harbour no es una tarea sencilla, aunque si es posble. Deberas manejar mucho el codigo C. La gran pregunta es si se justifica todo ese trabajo para cargar una funcion.

Usarla es muy sencillo hay varios ejemplos en los samples.

Create a DLL with harbour is not easy, but not impossible. You have to do a lot of work with C code. The big question is if this big job paid for it, just to load one function.

Using dll is very simple, you can find many samples in the Samples folder.
Regards/Saludos, Carlos (bcd12a)
Post Reply