Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / February 2005

Tip: Looking for answers? Try searching our database.

Adding entry to comm\tcpip\hosts

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WM - 28 Feb 2005 20:33 GMT
I am trying to figure out how to save aTCPIP address entry in the
comm\tcpip\hosts registy.  I can make the host key with the name and save the
ipaddress key with a string value, but need to convert to binary value. I was
looking at the bitconverter, but didnt see what the conversion would be? Any
help would be great!

Dim nipaddress As string
Dim bipaddress As string
nipaddress = Hex(TextBox3.Text) + " " + Hex(TextBox4.Text) + " " +
Hex(TextBox5.Text) + " " + Hex(TextBox6.Text)

bipaddress=System.BitConverter.ToDouble(nipaddress)

Dim regVersion As OpenNETCF.Win32.RegistryKey
Dim keyName As String = "Comm\\Tcpip\\Hosts\\" + TextBox1.Text
regVersion = OpenNETCF.Win32.Registry.LocalMachine.CreateSubKey(keyName)
regVersion.SetValue("ipaddr", bipaddress)
regVersion.Close()
Daniel Moth - 28 Feb 2005 20:54 GMT
Not sure which value you think should be binary.. ipaddresses are stored as
strings in the registry... Assuming you got your paths right try it with a
string (you'll need to rebind your driver OR flush the registry and restart
the unit)

Note that you do not need to escape the backslashes in VB like your sample
shows...

Cheers
Daniel
--
http://www.danielmoth.com/Blog/

>I am trying to figure out how to save aTCPIP address entry in the
> comm\tcpip\hosts registy.  I can make the host key with the name and save
[quoted text clipped - 17 lines]
> regVersion.SetValue("ipaddr", bipaddress)
> regVersion.Close()
WM - 28 Feb 2005 21:55 GMT
Daniel,

Thanks, the string I am trying to save as binary is the     bipaddress
I tested again as a string in the registry, doesnt work.  I used a program
called "Pocket Hosts" to create a new hosts entry and it saves the ipadress
in a binary value key. I can convert the dec to binary, but I cant fingure
out how to save the key value as a binary key.
I can convert 192 168 2.3  to C0 A8 02 03 but the key type needs to be
binary. When I use the setvalue below is creates as a string, the response I
got from OpennetCf was "nipaddress needs to be a byte array for the data to
be written as a binary value"  Is there a way to convert the string variable
to a binary variable?

> Not sure which value you think should be binary.. ipaddresses are stored as
> strings in the registry... Assuming you got your paths right try it with a
[quoted text clipped - 30 lines]
> > regVersion.SetValue("ipaddr", bipaddress)
> > regVersion.Close()
Daniel Moth - 28 Feb 2005 22:04 GMT
Any registry code will write to the registry whatever you pass to it. To
write binary you must pass it a byte array. So if you have the bytes just
add them to a byte array and pass that to the SetValue method. If you have
more problems post your updated code indicating which line fails.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/

> Daniel,
>
[quoted text clipped - 55 lines]
>> > regVersion.SetValue("ipaddr", bipaddress)
>> > regVersion.Close()
<ctacke/> - 28 Feb 2005 22:12 GMT
Encoding.ASCII.GetBytes

-Chris

> Daniel,
>
[quoted text clipped - 55 lines]
>> > regVersion.SetValue("ipaddr", bipaddress)
>> > regVersion.Close()

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.