Cannot read from Registry
Cannot read from Registry
Cannot read from Registry
Cannot read from Registry
Cannot read from Registry
Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry
Cannot read from Registry Cannot read from Registry
Cannot read from Registry
Go Back  Xtreme Visual Basic Talk > > > Cannot read from Registry


Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2015, 09:08 AM
hanoch_hendel hanoch_hendel is offline
Newcomer
 
Join Date: Jun 2005
Posts: 6
Default Cannot read from Registry


I am trying to read the Hard Drive ID from Registry.

The line in code, which reads the Registry key, throws the following error:

InvalidCastException was unhandled. Conversion from type Byte() to type Byte is not valid.

Can someone help?

Thanks.

Code:
Sub Extract_from_Registry_HardDrive_ID()
'open registry key "\DosDevices\C:"
RegKey = My.Computer.Registry.LocalMachine.OpenSubKey("System\MountedDevices", True)
'read registry key
Hard_drive_ID = My.Computer.Registry.GetValue("HKEY_Local_Machine\System\MountedDevices", "\DosDevices\C:", Nothing)
'close Registry key
RegKey.Close()
End Sub
Reply With Quote
  #2  
Old 04-11-2015, 04:58 PM
passel's Avatar
passelCannot read from Registry passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

Sounds like you have Hard_drive_ID declared as a Byte and it should be a Byte array.

You probably have something like
Private Hard_drive_ID as Byte 'a single byte

when it should be
Private Hard_drive_ID() as Byte 'an array of byte
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Cannot read from Registry
Cannot read from Registry
Cannot read from Registry Cannot read from Registry
Cannot read from Registry
Cannot read from Registry
Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry Cannot read from Registry
Cannot read from Registry
Cannot read from Registry
 
Cannot read from Registry
Cannot read from Registry
 
-->