>But in the .prg code used for EXE file when you are calling
>functions which do not exist in it and are loaded dynamically
>then all such functions should be declared as DYNAMIC otherwise
>you will have link time error (function does not exist).
In my case of use the functions in the DLL are called by the EXE via
macro evaluation (because I don't have their names until I load the
DLL) so it is not possible/needed declare them as DYNAMIC in the
EXE, I guess. Is it going to work anyway?

It will work but I do not understand how it's possible to call
function by macro knowing it's name when macro value is created
but in other context you do not know this name. Your above
description does not make any sense or you simply forgot to say
about some important conditions.

Hi Przemek
Below is some code to exemplify what I couldn't explain to you textually. Maybe it helps.
Rgds
Leandro


**********************************************
function CarregarDLLs(cFolder)
**********************************************
local aFiles:=Directory(cFolder+"\*.dll"),aVersion
local ddd,hh
local cFunction,cID

for ddd = 1 to len(aFiles)
  hh      := LibLoad( cFolder + aFiles[ddd,1] )
  cID  := substr(afiles[ddd,1],4,2)
  cFunction := "__DLL__" + strtran(aFiles[ddd,1],".DLL","")
if !FunctionExists(cFunction) // if the dll doesn't have such function we don't need it
     LibFree(hh)
     loop
  endif
  aVersion := & (cFunction + '()')
  oDLL := DLL2D():New(hh,aVersion)
  oDLL :dFile := ListaArq[ddd,2]
  oDLL :cFiletime := ListaArq[ddd,3]
  oDLL :nFileLen := ListaArq[ddd,4]
  LibFree(hh)
next

Return


//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
CLASS DLL2D

   CLASS VAR aAllDLL INIT {}

   DATA cCode,cName,nVersion,cPrefix,cCompileTime,cFileTime INIT ""
   DATA dCompile,dFile INIT ctod("")
   DATA nFileLen INIT 0
   DATA aList,aTopics INIT {}

   METHOD New()
   ...

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New(vetor) CLASS DLL2D

Local aaa,cFunction,aVersion

::cCode := vetor[ 1]
::cName := vetor[ 3]
::nVersion := vetor[ 4]
::cPrefix := vetor[ 5]
::dCompile := vetor[ 6]
::cCompileTime := vetor[ 7]
::aList := vetor[8]

for aaa = 1 to len(::aList)
  aadd(::aTopics,{::aList[aaa,1],.f.,NIL,len(::aList[aaa])=1})
next

for aaa = 1 to len(::aTopics)
     if ::aTopics[aaa,4]
        cFunction := "__2D_" + ::cPrefix + ::aTopics[aaa,1]
        if FunctionExists(cFunction)
           ::aTopics[aaa,2] := .t.
           if ::aTopics[aaa,1] $ "KT-KR"
              ::aTopics[aaa,3] :=  & (cFunction + '("TDK")')
           else
              ::aTopics[aaa,3] :=  & (cFunction + '(,"TDX")')
           endif
        endif
     else
        ::aTopics[aaa,2] := .t.
     endif
next

aadd(::aAllDLL,Self)

Return Self



_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to