Pegar informações do HD

Aqui você poderá oferecer suas Contribuições, Dicas e Tutoriais (Texto ou Vídeo) que sejam de interesse de todos.

Moderador: Moderadores

Avatar do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

Pegar informações do HD

Mensagem por asimoes »

Referência: https://docs.microsoft.com/en-us/window ... -diskdrive

Retorna como Hash

Código: Selecionar todos


   aDiskInformation := GetDiskInformation()

FUNCTION GetDiskInformation()
LOCAL oDiskDrive, aDiskInformation 
LOCAL oWMIObjA, oWMIDiskDrive, oWMIObjA2

   oWMIObjA := Win_OleCreateObject( "wbemScripting.SwbemLocator" )
   
   oWMIServerA   := oWMIObjA:ConnectServer()
   oWMIDiskDrive := oWMIServerA:ExecQuery( "SELECT * FROM Win32_DiskDrive" )
  
   aDiskInformation := {}
   
   hRecord := Nil
   
   FOR EACH oDiskDrive IN oWMIDiskDrive
      hRecord := Nil
      hRecord := {=>}
   
      hRecord["SerialNumber"] := oDiskDrive:SerialNumber
      hRecord["Manufacturer"] := oDiskDrive:Manufacturer
      hRecord["MediaType"]    := oDiskDrive:MediaType
      hRecord["Partitions"]   := oDiskDrive:Partitions
      hRecord["Size"]         := oDiskDrive:Size
      hRecord["Caption"]      := oDiskDrive:Caption
      hRecord["Description"]  := oDiskDrive:Description
   
      aAdd( aDiskInformation, hRecord )
   NEXT
   
RETURN aDiskInformation

►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Responder