Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Help, Win32_DefragAnalysis in VB6 code

Help, Win32_DefragAnalysis in VB6 code

Scheduled Pinned Locked Moved Visual Basic
helpcareer
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nghia09t3
    wrote on last edited by
    #1

    i want to use class Win32_DefragAnalysis(WMI) to scan status of other volume, but it is not active, exactly, the For-each is not work, please help me,

    Private Sub defrag_analysis()
    On Error Resume Next
    Dim item
    Dim nameSQL
    Dim wmiOBJECT
    Dim itemCOLLECTION
    Set wmiOBJECT = GetObject("Winmgmts:\\.\root\cimv2")
    nameSQL = "select * from Win32_DefragAnalysis" ' Where VolumeSize > 0 "
    Set itemCOLLECTION = wmiOBJECT.ExecQuery(nameSQL)
    For Each item In itemCOLLECTION
    'not print properties of item
    MsgBox "VolumeSize : " & item.VolumeSize
    MsgBox "Name : " & item.VolumeName
    MsgBox "FreeSpace :" & item.FreeSpace
    MsgBox "AverageFileSize : " & item.AverageFileSize
    Next

    MsgBox "jump here"
    

    End Sub

    L 1 Reply Last reply
    0
    • N nghia09t3

      i want to use class Win32_DefragAnalysis(WMI) to scan status of other volume, but it is not active, exactly, the For-each is not work, please help me,

      Private Sub defrag_analysis()
      On Error Resume Next
      Dim item
      Dim nameSQL
      Dim wmiOBJECT
      Dim itemCOLLECTION
      Set wmiOBJECT = GetObject("Winmgmts:\\.\root\cimv2")
      nameSQL = "select * from Win32_DefragAnalysis" ' Where VolumeSize > 0 "
      Set itemCOLLECTION = wmiOBJECT.ExecQuery(nameSQL)
      For Each item In itemCOLLECTION
      'not print properties of item
      MsgBox "VolumeSize : " & item.VolumeSize
      MsgBox "Name : " & item.VolumeName
      MsgBox "FreeSpace :" & item.FreeSpace
      MsgBox "AverageFileSize : " & item.AverageFileSize
      Next

      MsgBox "jump here"
      

      End Sub

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Since when does VB6 have a "for-each"? Did I mention it's a dead language? Why are you still using it? The VB.NET IDE is available for free, as is the runtime. I strongly suggest you switch your platform.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups