Existe alguna forma de deshabilitar el
acceso a archivos dbf desde excel?
Gracias
FUNCTION UnProtec( cDbf ) ; return( DbProtec( cDbf, 1 ) )
FUNCTION Protec( cDbf ) ; return( DbProtec( cDbf, 0 ) )
FUNCTION DbProtec( cDbf, nAction )
local nHandle := 0
local cBuffer := space( 32 )
nHandle := FOpen( cDbf, FO_READWRITE + FO_SHARED )
DEFAULT nAction := 1
if nHandle != -1
if FRead( nHandle, @cBuffer, 32 ) == 32
if nAction == 0 // Proteger
if SubStr( cBuffer, 1, 1 ) <> Chr( 26 )
cBuffer := Chr( 26 ) + SubStr( cBuffer, 1, 31 )
endif
else // Desproteger
if SubStr( cBuffer, 1, 1 ) == Chr( 26 )
cBuffer := SubStr( cBuffer, 2, 31 ) + Chr( 0 )
endif
endif
FSeek( nHandle, 0 )
FWrite( nHandle, cBuffer, 32 )
endif
FClose( nHandle )
endif
return( FError() )
FUNCTION lProtec( cDbf )
local nHandle := 0
local cBuffer := space( 32 )
local lRet := .f.
if ( nHandle := FOpen( cDbf, FO_READWRITE + FO_SHARED ) ) != -1
if FRead( nHandle, @cBuffer, 32 ) == 32
lRet := if( SubStr( cBuffer, 1, 1 ) == Chr( 26 ), .t., .f. )
endif
FClose( nHandle )
else
MsgInfo( "No puedo abrir la DBF: " + cDbf )
endif
return( lRet )
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 101 guests