找回密码
 加入
搜索
查看: 2013|回复: 2

错误:变量类型必须为对象类型("object")

[复制链接]
发表于 2008-6-1 23:01:10 | 显示全部楼层 |阅读模式
$fso.GetTempName ()
这里提示:错误:变量类型必须为对象类型("object")

脑子不够使了,没法理解,谁给说说.
顺便帮忙改一下好吗,谢谢

_Main()

Func _Main()
    Local $s_temp = _CreateTempFileName()

    Local $h_temp = FileOpen($s_temp, 1)
    FileWrite($h_temp, "Hellow World!!!")
    FileClose($h_temp)
    $h_temp = FileOpen($s_temp, 0)
    MsgBox(0, "Temp File Used", FileRead($h_temp))
    FileClose($h_temp)
    FileDelete($s_temp)
EndFunc   ;==>_Main


Func _CreateTempFileName($i_CreateWhere = 2, $s_Path = '')
    Local $fso = ObjCreate ("Scripting.FileSystemObject")
    Local $tfolder, $tname
    Local Enum $WindowsFolder, $SystemFolder, $TemporaryFolder, $CustomFolder
    Switch $i_CreateWhere
        Case $WindowsFolder
            If FileExists(@WindowsDir & "\temp") Then
                $tfolder = @WindowsDir & "\temp"
            Else
                $tfolder = @WindowsDir
            EndIf
        Case $SystemFolder ; not widely used, don't recommend using this location
            $tfolder = @SystemDir
        Case $TemporaryFolder
            $tfolder = @TempDir
        Case $CustomFolder
            If @NumParams < 2 Then Return SetError(1, 1, "")
            $s_Path = StringReplace($s_Path, "/", "\")
            If StringRight($s_Path, 1) = "\" Then $s_Path = StringTrimRight($s_Path, 1)
            $tfolder = $s_Path
        Case Else
            Return SetError(1, 1, "")
    EndSwitch
    $tname = $tfolder & "\" & $fso.GetTempName ()
    Local $h_file = FileOpen($tname, 1)
    If $h_file = -1 Then Return SetError(1, 1, "")
    FileClose($h_file)
    Return $tname
EndFunc   ;==>_CreateTempFileName


[ 本帖最后由 木纳 于 2008-6-3 05:18 编辑 ]
发表于 2008-6-2 08:25:38 | 显示全部楼层
Scripting.FileSystemObject
有这个obj 么?
你isobj 看看...

评分

参与人数 1金钱 +2 收起 理由
木纳 + 2 感谢解答, 关键时候还得老手给指点下.

查看全部评分

发表于 2009-5-26 22:28:17 | 显示全部楼层
我的也出现这种出错!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-10 11:04 , Processed in 0.079387 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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