函数参考


_WinAPI_DecryptFile

Decrypts an encrypted file or directory.

#Include <WinAPIEx.au3>
_WinAPI_DecryptFile ( $sFile )

参数

$sFile The name of the file or directory to be decrypted. If $sFile specifies a read-only file, the function
fails and the last error code is ERROR_FILE_READ_ONLY (6009). If $sFile specifies a directory that
contains a read-only file, the functions succeeds but the directory is not decrypted.

返回值

成功: 返回 1.
失败: 返回 0 并设置 @error 标志为非 0 值.

注意/说明

The _WinAPI_DecryptFile() function requires exclusive access to the file being decrypted, and will fail
if another process is using the file.

If the file is not encrypted, the function simply returns a nonzero value, which indicates success.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global $File = FileOpenDialog('Select File', @ScriptDir, 'All Files (*.*)', 1 + 2)

If Not $File Then
    Exit
EndIf

Switch _WinAPI_FileEncryptionStatus($File)
    Case $FILE_ENCRYPTABLE
        If _WinAPI_EncryptFile($File) Then
            MsgBox(64, 'Encryption File', 'The file encrypted is successfully.')
        Else
            MsgBox(16, 'Encryption File', 'Unable to encrypt file.')
        EndIf
    Case $FILE_IS_ENCRYPTED
        If MsgBox(36, 'Encryption File', 'The file is already encrypted.' & @CR & @CR & 'Decrypt?') = 6 Then
            If _WinAPI_DecryptFile($File) Then
                MsgBox(64, 'Encryption File', 'The file decrypted is successfully.')
            Else
                MsgBox(16, 'Encryption File', 'Unable to decrypt file.')
            EndIf
        EndIf
    Case Else
        MsgBox(16, 'Encryption File', 'Unable to perform operation.')
EndSwitch