Baseado no conteudo do arquivo DLL.CH voce só poderá usar as definições lá existentes para não acontecer erro de compilação.
pois provavelmente algumas variáveis passadas como parametro deverão ter seu valor retornado na própria variável, assim:
Tente fazer uso destá classe que promete integração com DLLs se a necessidade de declará-las.
Código: Selecionar todos
#include "fivewin.ch"
#define _TEST_ //Comment this line to skip test
#ifdef _TEST_
Function Test()
Local c:="hErE iS mY tEsT tExT: äâ"
MsgInfo( tDLL():New("user32","CharUpperA",LPSTR,.t.,{LPSTR}):Exec32(c), 'CharUpperA in user32')
MsgInfo( tDLL():New("user32","CharLowerA",LPSTR,.t.,{LPSTR}):Exec32(c), 'CharLowerA in user32')
return
#endif
******************************************************************************
* CLASS to access any DLL function without explicite declaring
*
* César E. Lozada (cesarlozada@hotmail.com)
* 01-Nov-2002
*
* I'm tired for writing DLL32 FUNCTION blah blah blah....
* I'll use an object for that
*
* Sintax to define object
* oDll:=tDLL():New(cDllName,cFunction,nResultType,lPascal,aParamType)
* where
* cDllName is the DLL's name
* cFunction is the function into the DLL
* nResultType is the function result type
* lPascal is .T. if PASCAL (default .T.) (I don't know what it means)
* aParamType is an array whith parameters type,
* ex.: {LONG,LONG,LONG,LPSTR,LONG,LONG} or easier
* {{LONG,3},LPSTR,{LONG,2}} //3 LONG's + 1 LPSTR + 2 LONGs
* //in this order
* ... for calling the function
*
* uRes:=oDll:Exec32([p01,p02,p03,p04,p05,p06,p07,p08,p09,p10 ]) for a DLL32, or
*
* uRes:=oDll:Exec16([p01,p02,p03,p04,p05,p06,p07,p08,p09,p10 ]) otherwise
*
* p01..p10 are the function parameteres
******************************************************************************
#xTranslate nTrim(<n>) => LTrim(Str(<n>))
******************************************************************************
CREATE CLASS tDLL
DATA cDllName
DATA aParamType
DATA cFunction
DATA nResultType
DATA lPascal INIT .T.
DATA hDll //Error code
METHOD New(cDllName,cFunction,nResultType,lPascal,aParamType) CONSTRUCTOR
METHOD Exec16(p01,p02,p03,p04,p05,p06,p07,p08,p09,p10)
METHOD Exec32(p01,p02,p03,p04,p05,p06,p07,p08,p09,p10)
METHOD Exec() LOCAL
ENDCLASS
*=============================================================================
METHOD New(cDllName,cFunction,nResultType,lPascal,aParamType)
DEFAULT nResultType:=LONG, lPascal:=.T., aParamType:={}
cFunction:=AllTrim(cFunction)
BYNAME cDllName,cFunction,nResultType,lPascal,aParamType
return
*=============================================================================
METHOD Exec16(p01,p02,p03,p04,p05,p06,p07,p08,p09,p10)
return ::Exec(.f., @p01,@p02,@p03,@p04,@p05,@p06,@p07,@p08,@p09,@p10)
*=============================================================================
METHOD Exec32(p01,p02,p03,p04,p05,p06,p07,p08,p09,p10)
return ::Exec(.t., @p01,@p02,@p03,@p04,@p05,@p06,@p07,@p08,@p09,@p10)
*=============================================================================
METHOD Exec(l32,p01,p02,p03,p04,p05,p06,p07,p08,p09,p10)
Local uResult, cFarProc, cMacro
Local n,m
::hDLL:=LoadLib32(::cDllName)
IF Abs(::hDLL)<=32
MsgAlert( "Error code: " + nTrim( ::hDLL ) + " loading " + ::cDllName )
ELSE
cMacro:=if(l32,[GetProc32],[GetProcAddress])+[(]+nTrim(::hDLL)+;
[,"]+::cFunction+["]+;
[,]+if(::lPascal,'.t.','.f.')+;
[,]+nTrim(::nResultType)
for n:=1 to Len(::aParamType)
IF ValType(::aParamType[n])="A"
for m:=1 to ::aParamType[n,2]
cMacro+=[,]+nTrim(::aParamType[n,1])
next
ELSE
cMacro+=[,]+nTrim(::aParamType[n])
ENDIF
next
cMacro+=[)]
cFarProc:=&cMacro
if l32
uResult:=CallDll32(cFarProc,p01,p02,p03,p04,p05,p06,p07,p08,p09,p10)
FreeLib32(::hDLL)
else
uResult:=CallDll(cFarProc,p01,p02,p03,p04,p05,p06,p07,p08,p09,p10)
FreeLibrary(::hDLL)
endif
ENDIF
return uResult
******************************************************************************
*
* Some useful functions
*
* aPoints:={{0,0}, {100,0}, {100,100}, {0,100}}
* cLPSTR:=aLong2LPSTR(aPoints)
* oDLL:=tDLL():New('gdi32','Polygon',LONG,.t.,{LONG,LPSTR,LONG})
* oDLL:Exec32(hDC,cLPSTR,Len(aPoints))
*
******************************************************************************
Function aLong2LPSTR(aArr)
*----
* Converts a LONGs' array into a LPSTR
*----
Local cLPSTR:=''
aEval(aArr,{|u| _t:=ValType(u),;
cLPSTR+=if(_t="N",L2Bin(u),if(_t="A",aLong2LPSTR(u),'')) })
return cLPSTR
******************************************************************************
Function LPSTR2aLong(cLPSTR,nCols)
*----
* Converts a LPSTR into a LONGs' array every row having nCols columns
*----
Local aArr:={}, p:=1
DEFAULT nCols:=0
DO WHILE p<=Len(cLPSTR)
if nCols=0
aAdd(aArr,Bin2L(SubStr(cLPSTR,p,4)))
p+=4
else
aAdd(aArr,LPSTR2aLong(SubStr(cLPSTR,p,4*nCols),0))
p+=4*nCols
endif
ENDDO
return aArr
******************************************************************************
Use DLL32 FUNCTION no lugar de DLL FUNCTION pois estas DLLs fornecedidas são 32Bits.