爱问知识人 爱问教育 医院库

VBS 变量值写入.INI文件的问题

首页

VBS 变量值写入.INI文件的问题

On Error Resume Next 
strComputer = "A1" 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\") 
Set colItems = objWMIService.ExecQuery("Select * from Win32_Share",,48) 
For Each objItem in colItems 
Wscript.Echo "Name: " & objItem.Name 
jItem.Type 
Next 

上面代码可获得A1共享目录的名字 

我要怎么做才能让它不逐个显示目录名,而是以固定格式将目录名保存到指定的INI文件里? 
比如:Share1= Share2= ..... 

最好给出完整代码。(假设为Path.ini ,段名为dir)

提交回答
好评回答
  • 2018-03-29 10:01:39
      Function GetIni( strPrimary  ,  strSubKey,  strIniFilePath ) 
        Dim myFso 
        Dim MyFile 
        Dim intCount , strState 
        Set myFso =  CreateObject("Scripting。
      FileSystemObject") Set MyFile = myFso。OpenTextFile(strIniFilePath, 1, False, False) With MyFile Do Until 。
      AtEndOfStream If intCount = 0 Then If 。ReadLine = "[" & strPrimary & "]" Then intCount = 1 End If Else strState = 。
      ReadLine If UCase(Left(strState, Len(strSubKey & "="))) = UCase(strSubKey & "=") Then GetIni = Right(strState, Len(strState) - Len(strSubKey & "=")) End If End If Loop 。
      Close End With Set MyFile = Nothing Set myFso = Nothing End Function 。

    张***

    2018-03-29 10:01:39

类似问题

换一换
  • VB 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 171-190
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):