¿Tiene una llamada a una DLL en VB6 y quiere usarla en FWH sin traducirla? Aquí tiene cómo hacerlo.
Do you have a DLL call with VB6 sintax a you want to use it in FWH without translate it? Here you have how to make it.
Ejemplo / Example
****************************************************
#include "Fivewin.ch"
FUNCTION Test()
Local cUrl:="http://planteles.me.gob.ve/login.php?entrada"
Local cSaveAs:="temp"
Local nResult
nResult:=URLDownloadToFile(0, cURL, cSaveAs, 0, 0)
RETURN nil
*-----------------------------------------
#include "vbdll.ch"
// FWH entiende esta sintaxis / FWH understands this sintax
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ;
(ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ;
ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
****************************************************
¿Cómo? // How?
Copiar lo siguiente en: / Copy this in
vb6dll.ch
//============================================
//vb6 dll calls translation to FWH
//Cesar Lozada, Los Teques, Venezuela (March 30, 2008)
//============================================
#ifndef _VBDLL_CH_
#define _VBDLL_CH_
#xTranslate ByVal <x> => <x>
#xTranslate ByRef <x> => @<x>
#xTranslate As Long => AS LONG
#xTranslate As Integer => AS LONG
#Translate As String => AS STRING
#Translate As Boolean => AS BOOL
#Translate As Any => AS LPSTR
#Translate As Pointer => AS LPSTR
#Translate As Void => AS VOID
#xTranslate NOREF( [@]<x> ) => <x>
#xTranslate _DLL_FUNCT_ <cFunction> PARAMS [<Par1> AS <Typ1>] [,<ParN> AS <TypN>] [AS <cRes>] [LIB <cLib>] [ALIAS <cAlias>] =>;
Local hDll:=DllHandle( <cLib> );;
Local uResult, cFarProc;;
IF Abs(hDll) > 32 ;;
cFarProc := GetProcAddress(hDLL, if( [Empty(<cAlias>) ==] .T., <(cFunction)>, <cAlias> ),;
.T.,<cRes> [,<Typ1>][,<TypN>]);;
uResult:= CallDll(cFarProc[,<Par1>][,<ParN>]);;
ELSE;;
MsgAlert("Error código "+Str(hDll,,,.T.)+" al cargar "+<(cFunction)>,"DLL CALL");;
ENDIF;;
return uResult
#xCommand Private Declare Function <cFunction> [LIB <cLib>] [ALIAS <cAlias>];
( [<Par1> AS <Typ1>] [,<ParN> AS <TypN>] ) [As <cRes>];
=>;
Static Function <cFunction>([NOREF(<Par1>)][,NOREF(<ParN>)]);;
_DLL_FUNCT_ <cFunction> PARAMS [<Par1> AS <Typ1>] [,<ParN> AS <TypN>] [AS <cRes>] [LIB <cLib>] [ALIAS <cAlias>]
#xCommand Public Declare Function <cFunction> [LIB <cLib>] [ALIAS <cAlias>];
( [<Par1> AS <Typ1>] [,<ParN> AS <TypN>] ) [As <cRes>];
=>;
Function <cFunction>([NOREF(<Par1>)][,NOREF(<ParN>)]);;
_DLL_FUNCT_ <cFunction> PARAMS [<Par1> AS <Typ1>] [,<ParN> AS <TypN>] [AS <cRes>] [LIB <cLib>] [ALIAS <cAlias>]
#xCommand Declare Function <cFunction> [LIB <cLib>] [ALIAS <cAlias>];
( [<Par1> AS <Typ1>][,<ParN> AS <TypN>] ) [As <cRes>];
=>;
Function <cFunction>([NOREF(<Par1>)][,NOREF(<ParN>)] );;
_DLL_FUNCT_ <cFunction> PARAMS [<Par1> AS <Typ1>] [,<ParN> AS <TypN>] [AS <cRes>] [LIB <cLib>] [ALIAS <cAlias>]
#endif
============================================
Agregar estas funciones a su código: / Add these functions to your code:
//============================================
Function DllHandle(cDll,lFree)
*-----------------------------------------------
* LoadLibrary (keeps handle in static array) or FreeLibrary (-ies)
* Sintax:
* DllHandle(cDll)....... (Load cDll or retrieve cDll handle) -> cDll handle
* DllHandle(cDll,.T.)... Free cDll handle
* DllHandle()............. Free all handles
*-----------------------------------------------
Local h, hDll:=0, u
Static ahDll
DEFAULT ahDll:={}
DEFAULT lFree:=(.F. .or. pCount()=0)
IF lFree
IF Empty(cDll)
aEval(ahDll,{|u| FreeLibrary(u[2])})
ahDll:={}
ELSEIF (h:=aScan(ahDll,{|u| u[1]==Upper(cDll) }))>0
FreeLibrary(ahDll[h,2])
aDel(ahDll,h); aSize(ahDll,Len(ahDll)-1)
ENDIF
ELSE
IF (h:=aScan(ahDll,{|u| u[1]==Upper(cDll) }))=0
hDll:=LoadLibrary(cDll)
aAdd(ahDll,{Upper(cDll),hDll})
h:=Len(ahDll)
ENDIF
hDll:=ahDll[h,2]
ENDIF
return hDll
*-----------------------------------------
EXIT PROCEDURE DllFreeAll()
DllHandle()
RETURN
*==========================================