José:

This little app I made years ago unloads just fine, so I'm not sure
why your's stays in memory.

According to Przemek, this is how it should be done:

hDll := hb_LibLoad( "pcode.dll" )
hb_LibDo( "DllInit" )
...

an upon closing the app

hb_LibFree( hDll )

For me this approach made the app gpf (don't recall if it was
during the app running, or upon closing the app).

So I ended up using

hDll := LoadLibrary( "pcode.dll" )
hbLibDo( "DllInit" )

and avoid calling FreeLibrary( hDll ) at app exit.

The other important issue is to use the DYNAMIC statement to
reference all functions (xharbour's and your's) that are called
insided your pcode dll.

The following code is based on code Przemek and Miguel
provided.  The idea is to code your app to, for example,
hold down the Shift key upon loading to create this ch with
all dynamic declarations and exit right away.  You then
add at the top of your pcode dll:

#include "dynamic.ch"

//***
Function mkFuncList()
Local aFunc, hFile, lRetVal := .f.

aFunc := getFuncList()
ASort( aFunc )
If ( hFile := FCreate( "dynamic.ch" ) ) > -1
   FWrite( hFile, "// dynamically created xharbour header file - do not 
edit!" + hb_osNewLine() )
   AEval( aFunc, {|cFunc| FWrite( hFile, "DYNAMIC " + cFunc + 
hb_osNewLine() ) } )
   FClose( hFile )
   lRetVal := .t.
Endif

Return lRetVal

Function getFuncList()
Local aFunc, nCount := __dynsCount(), nDst := 0, nI

aFunc := Array( nCount )
For nI := 1 To nCount
   If __dynsIsFun( nI )
      aFunc[ ++nDst ] := __dynsGetName( nI )
   Endif
Next
ASize( aFunc, nDst )

Return aFunc
//***

Jose F. Gimenez wrote:
> Luis,
>
>
>   
>> I have this code at the bottom of pcode dlls:
>>     
>
> Thank you very much. It seems that now it works, but the caller program 
> stays in memory at end, even freeing the dll before. That is, it's not 
> really ends. I'll continue researching on it.
>
> ITOH, isn't possible to call hb_initstatics() automatically on dll startup?
>
>
> Regards,
>
> Jose F. Gimenez 
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> xHarbour-developers mailing list
> xHarbour-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xharbour-developers
>
>   

-- 
Luis Krause Mantilla
lkrausem at shaw dot ca
luis_krause at hotmail dot com
"May the Source be with GNU"



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
xHarbour-developers mailing list
xHarbour-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to