求助使用LocalSecurityAuthority.au3 的报错问题[已解决]
本帖最后由 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>
这个问题不知道能不能解决忘各位老师帮帮忙....先谢了 要么注释掉<File.au3>要么注释掉<LocalSecurityAuthority.au3>库文件里那就几个常量,只注释掉一个文件的,别两个文件全注了 回复 2# netegg
可是 注释了<File.au3>代码不能正常运行
注释<LocalSecurityAuthority.au3> 那我这个问题也不存在了
难道真的没别的办法了么 ??不过谢谢您的回复起码我的问题还有人回复没那么凄凉
试着改写代码.... 把顺序调下试试
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <Misc.au3>
#include <LocalSecurityAuthority.au3> 回复 3# 872777825
注释掉之后可以通过精简代码来搞一下 回复 3# 872777825
不行切换顺序后错误直接指向 LocalSecurityAuthority.au3 回复872777825
注释掉之后可以通过精简代码来搞一下
netegg 发表于 2011-3-24 18:02 http://www.autoitx.com/images/common/back.gif
但是有些功能一定要到那个库没办法 头痛
继续等待各位老师回复 我以前好像碰到过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
$array = $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 = $drive
$array = $dir
$array = $fname
$array = $ext
Return $array
EndFunc ;==>_PathSplit 你把local里面的那几行注释掉,然后把#include<file.au3>加到local那个文件前面,去掉你脚本里的file.au3 嗯谢谢楼上两位老师问题基本上已经解决了 看不懂,怎么搞
页:
[1]