请教函数“_ServListInstalled”的用法。[附上代码了] [已解决]
本帖最后由 dreamgg 于 2010-1-28 23:02 编辑想列表出系统服务到日志文件,按照“ServiceControl.au3”内含例子里的方法总是报错,请赐教!#include <Array.au3>
Func _ServListInstalled($Computer = ".")
Local $Rtn = ''
$Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2")
$sItems = $Service.ExecQuery("Select * from Win32_Service")
For $objService in $sItems
$Rtn &= $objService.Name & '|'
Next
Return StringSplit(StringTrimRight($Rtn, 1), '|')
EndFunc
_ArrayDisplay(_ServListInstalled(),"test")报错信息:
F:\My Documents\code\listserv\1.au3(25,42) : ERROR: _ArrayDisplay() called with expression on Const ByRef-param(s).
_ArrayDisplay(_ServListInstalled(),"test")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:\Tools\autoit3\Include\Array.au3(322,163) : REF: definition of _ArrayDisplay().
Func _ArrayDisplay(Const ByRef $avArray, $sTitle = "Array: ListView Display", $iItemLimit = -1, $iTranspose = 0, $sSeparator = "", $sReplace = "|", $sHeader = "")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\My Documents\code\listserv\1.au3 - 1 error(s), 0 warning(s) 看的朋友很多呢,再次请求支援! Const ByRef-param(s)
什么意思? 语法错误
#include <Array.au3>
Func _ServListInstalled($Computer = ".")
Local $Rtn = ''
$Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2")
$sItems = $Service.ExecQuery("Select * from Win32_Service")
For $objService in $sItems
$Rtn &= $objService.Name & '|'
Next
Return StringSplit(StringTrimRight($Rtn, 1), '|')
EndFunc
$test=_ServListInstalled()
_ArrayDisplay($test,"test")
应为以上
楼主帮助没看清,英文也不行
_ArrayDisplay的首项是要返回已声明的变量的
看到Const ByRef,想想就清楚了
建议看帮助和恶补英文 非常感谢楼上的管理员先生,对于脚本和英文都是初学,正在努力提高。
页:
[1]