找回密码
 加入
搜索
查看: 8200|回复: 10

[系统综合] 求助使用LocalSecurityAuthority.au3 的报错问题[已解决]

  [复制链接]
发表于 2011-3-23 23:57:42 | 显示全部楼层 |阅读模式
本帖最后由 872777825 于 2011-3-31 13:12 编辑
#RequireAdmin
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <LocalSecurityAuthority.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <Misc.au3>
$ok = RegRead("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell\MyMenu","SubCommands")
If Not @OSVersion = "WIN_7" Then Exit
If _Singleton(" Win7桌面右键中添加菜单", 1) = 0 Then Exit
Dim $szDrive, $szDir, $szFName, $szExt
Opt("TrayIconHide", 1)
GUICreate(" Win7桌面右键中添加菜单", 320, 110)
$RegName = GUICtrlCreateInput("", 10, 5, 210, 20)
$FileName = GUICtrlCreateInput("", 10, 35, 210, 20)
$test = GUICtrlCreateInput($ok, 10, 65, 210, 20)
$btn = GUICtrlCreateButton("打开文件", 250, 5, 60, 20)
$btn2 = GUICtrlCreateButton("添加菜单", 250, 35, 60, 20)
$MyMenu = "MyMenu"
GUISetState()

$msg = 0
While 1
        $msg = GUIGetMsg()
        Select
                Case $msg = $btn
                        $var = FileOpenDialog("选择文件", @ProgramFilesDir & "", "程序 (*.exe)", 1)
                        $arrPath = _PathSplit($var, $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($RegName, $var)
                        GUICtrlSetData($FileName, $szFName)
                Case $msg = $btn2
                        $read = GUICtrlRead($FileName)
                        $RegName2 = GUICtrlRead($RegName)
                        If StringRight($RegName2, 4) <> ".exe" Then
                                MsgBox(16, "错误", "指定的文件不是程序!", 3)
                                ContinueLoop
                        EndIf
                        If Not FileExists($RegName2) Then
                                MsgBox(16, "错误", "指定的文件不存在!", 3)
                                ContinueLoop
                        EndIf
                        If $RegName2 = '' Or $read = '' Then
                                ContinueLoop
                        Else
                                If Not FileExists(@WindowsDir & "\Windows.ico") Then FileInstall("Windows.ico", @WindowsDir & "\Windows.ico")
                                RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "Position", "REG_SZ", "Bottom")
                                RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "Icon", "REG_EXPAND_SZ", @WindowsDir & "\Windows.ico,0")
                                $SubCommand = RegRead("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "SubCommands")
                                $result = StringInStr($SubCommand, $read)
                                If $result = Not 0 Then
                                        MsgBox(16, "错误", "有同名菜单!", 3)
                                        ContinueLoop
                                EndIf
                                If $SubCommand = "" Then
                                        RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "SubCommands", "REG_SZ", $read)
                                Else
                                        RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "SubCommands", "REG_SZ", $SubCommand & ";" & $read)
                                EndIf
                                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell" & $read, "MUIVerb", "REG_EXPAND_SZ", $read)
                                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell" & $read, "Icon", "REG_EXPAND_SZ", $RegName2 & ",0")
                                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell" & $read & "\command", "", "REG_EXPAND_SZ", $RegName2)
                                RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell" & $read, "MUIVerb")
                                If @error = 1 Then
                                        MsgBox(16, "", "添加失败!", 3)
                                Else
                                        MsgBox(0, "", "添加成功!", 3)
                                        IniWrite(@ScriptDir & "\MyMenu.ini", "Config", $read, "")
                                EndIf
                                GUICtrlSetData($RegName, '')
                                GUICtrlSetData($FileName, '')
                        EndIf
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
        EndSelect
WEnd
代码如上,是引用站内一位朋友的
但小弟 添加了 #include <LocalSecurityAuthority.au3> 之后就不能编译了
提示下错误



不添加的话 代码可以正常使用的
但想把此段代码集成到自己使用的工具里面
因为之前写的已经加载了#include <LocalSecurityAuthority.au3>

这个问题不知道能不能解决  忘各位老师帮帮忙....先谢了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-3-24 02:22:39 | 显示全部楼层
要么注释掉<File.au3>要么注释掉<LocalSecurityAuthority.au3>库文件里那就几个常量,只注释掉一个文件的,别两个文件全注了
 楼主| 发表于 2011-3-24 17:36:35 | 显示全部楼层
回复 2# netegg


    可是 注释了<File.au3>  代码不能正常运行

  注释<LocalSecurityAuthority.au3>   那我这个问题也不存在了

难道真的没别的办法了么 ??  不过谢谢您的回复  起码我的问题还有人回复  没那么凄凉

  试着改写代码....
发表于 2011-3-24 17:43:44 | 显示全部楼层
把顺序调下试试
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <Misc.au3>
#include <LocalSecurityAuthority.au3>
发表于 2011-3-24 18:02:37 | 显示全部楼层
回复 3# 872777825
注释掉之后可以通过精简代码来搞一下
 楼主| 发表于 2011-3-24 20:53:15 | 显示全部楼层
回复 3# 872777825


    不行  切换顺序后  错误直接指向 LocalSecurityAuthority.au3
 楼主| 发表于 2011-3-24 20:55:15 | 显示全部楼层
回复  872777825
注释掉之后可以通过精简代码来搞一下
netegg 发表于 2011-3-24 18:02


   但是有些功能一定要到那个库  没办法    头痛
继续等待各位老师回复
发表于 2011-3-24 22:34:58 | 显示全部楼层
我以前好像碰到过FILE.AU3与它冲突的问题。看你代码FILE.AU3只用到 _PathSplit,可以把FILE.AU3注释掉,把下面的代码放进程序里面试试


Func _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt)
        ; Set local strings to null (We use local strings in case one of the arguments is the same variable)
        Local $drive = ""
        Local $dir = ""
        Local $fname = ""
        Local $ext = ""
        Local $pos

        ; Create an array which will be filled and returned later
        Local $array[5]
        $array[0] = $szPath; $szPath can get destroyed, so it needs set now

        ; Get drive letter if present (Can be a UNC server)
        If StringMid($szPath, 2, 1) = ":" Then
                $drive = StringLeft($szPath, 2)
                $szPath = StringTrimLeft($szPath, 2)
        ElseIf StringLeft($szPath, 2) = "\\" Then
                $szPath = StringTrimLeft($szPath, 2) ; Trim the \\
                $pos = StringInStr($szPath, "\")
                If $pos = 0 Then $pos = StringInStr($szPath, "/")
                If $pos = 0 Then
                        $drive = "\\" & $szPath; Prepend the \\ we stripped earlier
                        $szPath = ""; Set to null because the whole path was just the UNC server name
                Else
                        $drive = "\\" & StringLeft($szPath, $pos - 1) ; Prepend the \\ we stripped earlier
                        $szPath = StringTrimLeft($szPath, $pos - 1)
                EndIf
        EndIf

        ; Set the directory and file name if present
        Local $nPosForward = StringInStr($szPath, "/", 0, -1)
        Local $nPosBackward = StringInStr($szPath, "\", 0, -1)
        If $nPosForward >= $nPosBackward Then
                $pos = $nPosForward
        Else
                $pos = $nPosBackward
        EndIf
        $dir = StringLeft($szPath, $pos)
        $fname = StringRight($szPath, StringLen($szPath) - $pos)

        ; If $szDir wasn't set, then the whole path must just be a file, so set the filename
        If StringLen($dir) = 0 Then $fname = $szPath

        $pos = StringInStr($fname, ".", 0, -1)
        If $pos Then
                $ext = StringRight($fname, StringLen($fname) - ($pos - 1))
                $fname = StringLeft($fname, $pos - 1)
        EndIf

        ; Set the strings and array to what we found
        $szDrive = $drive
        $szDir = $dir
        $szFName = $fname
        $szExt = $ext
        $array[1] = $drive
        $array[2] = $dir
        $array[3] = $fname
        $array[4] = $ext
        Return $array
EndFunc   ;==>_PathSplit
发表于 2011-3-24 23:35:20 | 显示全部楼层
你把local里面的那几行注释掉,然后把#include<file.au3>加到local那个文件前面,去掉你脚本里的file.au3
 楼主| 发表于 2011-3-31 13:12:15 | 显示全部楼层
嗯  谢谢楼上两位老师  问题基本上已经解决了
发表于 2014-5-27 08:09:55 | 显示全部楼层
看不懂,怎么搞
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-17 00:39 , Processed in 0.089447 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表