' ****************************************************
' This is a sample VBScript code for PCIScope.
' It will read PCI configuration space for all devices
' on Bus 0 and display a message to the user if
' device was found.
' ****************************************************

Dim App, Dev, Func, VendorId, DeviceId, Message

Set App = CreateObject("PCIScope.Application")

for Dev = 0 to 31
   for Func = 0 to 7
      if App.Pci.IsDevFuncPresent(0, Dev, Func) then
         VendorId = App.Pci.ReadWord(0, Dev, Func, 0)
         DeviceId = App.Pci.ReadWord(0, Dev, Func, 2)
         Message  = "Device at 0:" & Hex(Dev) & ":" & Hex(Func) & " is present" & Chr(10)
         Message  = Message & "Vendor Id: " & Hex(VendorId) & "h" & Chr(10)
         Message  = Message & "Device Id: " & Hex(DeviceId) & "h"
         App.MessageBox(Message)
      elseif Func = 0 then
         exit for
      end if
   next
next