Относительно скрипта для создания DLL "применительно к структуре и файлам дистрибутива MiniGUI"
ничего не скажу, не знаю о чем речь.
цитата: |
Как из готового exe-шника обращиться к функциям dll, если имя DLL и имя функции неизвестно на этапе компиляции exe-шника, а имя dll и имя функции становится известным в процессе выполнения exe-шника? |
|
PROCEDURE main
LOCAL result
result := ExecuteFuncFromLib( "mydll", "myfunc", 12, "string" )
FUNCTION ExecuteFuncFromLib( cDllName, cFuncName, ... )
LOCAL lib, result := NIL
lib = Hb_libLoad( cDllName )
IF ! Hb_IsNil( lib )
result := HB_libDo( cFuncName, ... )
Hb_LibFree( lib )
ENDIF
RETURN result
Но это не совсем безопасный и не самый быстрый путь,
Пржемек предлагает использовать такую схему
BTW using:
DYNAMIC OtherFuncInPCodeDll
and then:
OtherFuncInPCodeDll( nParam )
is much faster then HB_LilbDo() which search for function symbol on each
call. In Harbour you can also make:
sym := &("@OtherFuncInPCodeDll()")
and then:
sym:exec( nParam )
Еще один совет от Пржемека
If you want to create automatically list of functions declared as DYNAMIC
you can use in your PCODE DLLs then please add to your main code:
proc genFuncList()
local aFunc, hFile
aFunc := getFuncList()
asort( aFunc )
hFile := fcreate("dynamic.ch")
aeval( aFunc, {|x| fwrite( hFile, "DYNAMIC " + x + hb_osNewLine() ) } )
fclose( hFile )
return
func getFuncList()
local aFunc, nCount := __dynsCount(), nDst:=0, n
aFunc := array( nCount )
for n := 1 to nCount
if __dynsIsFun( n )
aFunc[ ++nDst ] := __dynsGetName( n )
endif
next
asize( aFunc, nDst )
return aFunc
and then simply call
genFuncList()
it will create dynamic.ch file with all available functions. Then
simply add:
#include "dynamic.ch"
to your .prg code which should be linked into dynamic DLL. And do not
create any stub functions.