Hi
I'm having troubles reading the values from a registy key,
basically I already have my code working which reads back data from a registry
key with the name "Printer" however I also have another key called "Printer+" and
when I attempt to read that the "+" get ignored and it reads back "data" which
is in the same location. Is there a simple way of reading it back which won't
mean large changes to code that is already working as I need it to?
Any help would be greatly appreciated
I'm having troubles reading the values from a registy key,
basically I already have my code working which reads back data from a registry
key with the name "Printer" however I also have another key called "Printer+" and
when I attempt to read that the "+" get ignored and it reads back "data" which
is in the same location. Is there a simple way of reading it back which won't
mean large changes to code that is already working as I need it to?
Any help would be greatly appreciated
VB.NET:
'READ A VALUE FROM THE COMPUTERS REGISTRY
'function that reads preset registry keys
Public Sub getPrinterInfo()
ReDim PrinterData(arrayLimit)
Dim regKey As RegistryKey
Dim searchKey As RegistryKey = _
Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Print\Printers", RegistryKeyPermissionCheck.ReadSubTree)
Dim ver As String = ""
Dim count As Byte = 0
Dim i As Byte = 0
Try
For Each x In searchKey.GetSubKeyNames
regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Print\Printers\" & x, RegistryKeyPermissionCheck.ReadSubTree)
ver = regKey.GetValue("Printer Driver")
If ver = "Test Printer" Or ver = "Test Printer+" Then
PrinterData(count).friendlyName = x
PrinterData(count).driverVersion = ver
PrinterData(count).friendlyPort = getPort(x)
PrinterData(count).serverDataIndex = -1
PrinterData(count).Connected = connectionCheck(x)
regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Print\Printers\" & x & "\PrinterDriverData", RegistryKeyPermissionCheck.ReadSubTree)
PrinterData(count).firmwareVersion = getVersionNumber(regKey.GetValue("ES_FWVersion"))
While i < serverData.Count
If PrinterData(count).driverVersion = serverData(i).productName Then
PrinterData(count).serverDataIndex = i
i = serverData.Count
End If
i = i + 1
End While
i = 0
If PrinterData(count).serverDataIndex = -1 Then
MsgBox(Translator.Translate("Server data error, No data available for printer", translations), MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, Translator.Translate("No data available for printer", translations) & "[" & PrinterData(count).friendlyName & "]")
ElseIf PrinterData(count).firmwareVersion < serverData(PrinterData(count).serverDataIndex).latestFirmware Then
PrinterData(count).outOfDate = True
End If
count = count + 1
End If
regKey.Close()
Next
ReDim Preserve PrinterData((count - 1))
'close reg key handle
searchKey.Close()
Catch Ex As Exception
debugGenerateOutput("getPrinterInfo" & " :: " & Ex.Message & vbCrLf & "-STACK TRACE-" & vbCrLf & Ex.StackTrace)
Finally
If debug = 1 Then
debugGenerateOutput(vbCrLf & vbCrLf & "Start getPrinterInfo debug")
debugGenerateOutput(vbTab & "Loop counter: " & count)
debugGenerateOutput("End getPrinterInfo debug")
End If
End Try
Last edited: