Public pDir := "C:\Test\"
****************************************************************************
function OpenDbf(cFile, cIndex, lExclusive, cAlias, lEncrypt)
****************************************************************************
*
* Abrir arquivos em rede e mante-los criptografados
* Parametro: cFile, cIndex, lExclusive, cAlias, lEncrypt
* Retorno: Lógico - sucesso ao abrir
*
****************************************************************************
local Result := .T., cChave := 'P'+'A'+'S'+'S'+'W'+'O'+'R'+'D'+'.'+'A'+'D'+'S'+'1'+'2'+'3'
default lExclusive := .F.
default lEncrypt := .T.
default cIndex := ''
if ValType(cAlias) != "C"
cFile := AllTrim(Upper(cFile))
if Right(cFile,4) == ".DBF" .or. Right(cFile,4) == ".ADS"
cAlias := Substr( cFile, 1, Len(cFile) -4 )
else
cAlias := cFile
end
end
select 0
if lEncrypt
Try
dbUseArea(.T., "ADS" , pDir + cFile, cAlias, .not. lExclusive)
catch
Return .F.
end
else
Try
dbUseArea(.T.,"DBFCDX",pDir + cFile, cAlias, .not. lExclusive)
catch
Return .F.
end
end
if .not. empty(cIndex) .and. file(pDir + cIndex)
set index to (pDir + cIndex)
dbsetorder(1)
end
if lEncrypt
AdsEnableEncryption(cChave)
end
Result := .T.
return Result
/*------------------------------------------------------------------------*/
Function Test()
If !OpenDbf("C:\Test\MyDBF.DBF", ,.T. , , .T.)
MsgInfo("Erro ao abrir a tabela")
Return .F.
end
If ADSEncryptTable() != 0
AdsShowError("Erro ao criptografar a tabela")
else
MsgInfo("Tabela criptografada")
end
Return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 100 guests