laojikelly 发表于 2011-11-10 10:08:51

[已解决]用了P版的LocalSecurityAuthority.au3和File.au3后出现常量不能声明

本帖最后由 laojikelly 于 2011-11-10 10:32 编辑

代码如下:#NoTrayIcon
#include <LocalSecurityAuthority.au3>
#include <File.au3>

If Not IsDeclared("KEY_READ") Then $KEY_READ = 0x20019
If Not IsDeclared("KEY_ALL_ACCESS") Then $KEY_ALL_ACCESS = 0xF003F
If Not IsDeclared("HKEY_LOCAL_MACHINE") Then $HKEY_LOCAL_MACHINE = 0x80000002

$sSubKey1 = "HSOFTWARE\Microsoft\Windows\CurrentVersion\Run"
Dim $aAceList = [["Administrators", $KEY_READ, $GRANT_ACCESS, $SUB_CONTAINERS_AND_OBJECTS_INHERIT],["Everyone", $KEY_READ, $GRANT_ACCESS, $SUB_CONTAINERS_AND_OBJECTS_INHERIT]]
$iResult1 = _RegSetKeySecurityDacl($HKEY_LOCAL_MACHINE, $sSubKey1, $aAceList)

While 1
        If FileExists(@SystemDir & "\GroupPolicy_backup\gpt.ini") = 0 Or FileExists(@SystemDir & "\GroupPolicy_backup\Machine\Registry.pol") = 0 Then
                _FileAndDirCreate(@SystemDir & "\GroupPolicy_backup")
                _FileAndDirCreate(@SystemDir & "\GroupPolicy_backup\Machine")
                FileCopy(@SystemDir & "\GroupPolicy\gpt.ini", @SystemDir & "\GroupPolicy_backup\gpt.ini", 0)
                FileCopy(@SystemDir & "\GroupPolicy\Machine\Registry.pol", @SystemDir & "\GroupPolicy_backup\Machine\Registry.pol", 0)
        EndIf
        If FileExists(@SystemDir & "\GroupPolicy_backup\gpt.ini") = 1 And FileExists(@SystemDir & "\GroupPolicy\Machine\Registry.pol") = 1 Then ExitLoop
WEnd


;~ _FileAndDirCreate()
;===============================================================================
; 函数名称:   _FileAndDirCreate()
; 描述:       创建文件和文件夹
; 语法:       _FileAndDirCreate($FilePach)
; 参数:       $FilePach - 创建文件的路径和文件名.
; 例子:       _FileAndDirCreate('C:\Users\Administrator\Desktop\a.txt');创建文件
;             _FileAndDirCreate('C:\Users\Administrator\Desktop\a');创建文件夹
;
; 作者:      lixiaolong - http://www.autoitx.com/
;===============================================================================

Func _FileAndDirCreate($FilePach)
        Dim $szDrive, $szDir, $szFName, $szExt
        $arrPath = _PathSplit($FilePach, $szDrive, $szDir, $szFName, $szExt)
        If Not FileExists($FilePach) Then
                If $szExt = '' Then
                        DirCreate($FilePach)
                Else
                        _FileCreate($FilePach)
                EndIf
        Else
                For $i = 1 To 1000
                        If Not FileExists($szDrive & $szDir & $szFName & '(' & $i & ')' & $szExt) Then ExitLoop
                Next
                If $szExt = '' Then
                        DirCreate($szDrive & $szDir & $szFName & '(' & $i & ')')
                Else
                        _FileCreate($szDrive & $szDir & $szFName & '(' & $i & ')' & $szExt)
                EndIf
        EndIf
EndFunc   ;==>_FileAndDirCreate运行后的错误提示是:---------------------------
AutoIt 错误
---------------------------
Line 74(File "D:\autoit3\Include\FileConstants.au3"):

Global Const $GENERIC_ALL                = 0x10000000
Global Const ^ ERROR

Error: 不能重新声明一个常量.
---------------------------
确定   
---------------------------
我发现是FileContants.au3第74行的$GENERIC_ALL和P版的LocalSecurityAuthority.au3第210行的f Not IsDeclared("GENERIC_ALL") Then Global Const $GENERIC_ALL = 0x10000000发生冲突了。是否需要把FileContants.au3第74行的$GENERIC_ALL删除?
等待解决方法。

laojikelly 发表于 2011-11-10 10:31:56

大量事实证明。把FileContants.au3下的74~77行的声明前全部加;即可解决问题。;Global Const $GENERIC_ALL                = 0x10000000
;Global Const $GENERIC_EXECUTE        = 0x20000000
;Global Const $GENERIC_WRITE                = 0x40000000
;Global Const $GENERIC_READ                = 0x80000000
页: [1]
查看完整版本: [已解决]用了P版的LocalSecurityAuthority.au3和File.au3后出现常量不能声明