DLL vs LIB
Moderator: Rathinagiri
-
- 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
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.
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
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
- 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
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.
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.
South or North HMG is worth.
...the possibilities are endless.
- 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
Thanks for clarification Rathi!
Serge
Serge
There's nothing you can do that can't be done...
Re: DLL vs LIB
Can sb. place small sample how to load dll into .exe and later unload it?
Regards, Marek
Regards, Marek
Re: DLL vs LIB
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
Gabor
Re: DLL vs LIB
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.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.
Regards,
Anand
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: DLL vs LIB
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.
- 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
Rightly said Claudio.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
-
- 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
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
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
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
-
- Posts: 245
- Joined: Sat Aug 02, 2008 5:03 pm
Re: DLL vs LIB
Hi Jorgejorge.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
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)