Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Registry & File Input / Output

Post new topic   Reply to topic
Converting Registry data from VB 6 to VB.Net
View previous topic :: View next topic  
Author Message
Jazztech
Newbie


Joined: 28 Oct 2004
Posts: 8

PostPosted: Oct 28th, 2004 10:00 PM    Post subject: Converting Registry data from VB 6 to VB.Net Reply with quote

I have an issue trying to convert the following Registry Function written in VB 6 to VB.Net. I am new at writing to the Registry and I know iI am missing something but I do not know what it may be. Any asistance would be very much appreciated.

This is the VB code I wish to convert.

[vb:1:ccdd1f375d]Public Function GetSettingString(ByRef hKey As Integer, ByRef strPath As String, ByRef strValue As String, Optional ByRef Default_Renamed As String = "") As String

Dim hCurKey As Integer
Dim lResult As Integer
Dim lValueType As Integer
Dim strBuffer As String
Dim numBuffer As Integer
Dim lDataBufferSize As Integer
Dim intZeroPos As Short
Dim lRegResult As Integer
Dim strErrorMsg As String

'Set up default value
'UPGRADE_WARNING: IsEmpty was upgraded to IsNothing and has a new behavior. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1041"'
If Not IsNothing(Default_Renamed) Then
GetSettingString = Default_Renamed
Else
GetSettingString = ""
End If

lRegResult = RegOpenKey(hKey, strPath, hCurKey)
lRegResult = RegQueryValueEx(hCurKey, strValue, 0, lValueType, 0, lDataBufferSize)

If lRegResult = ERROR_SUCCESS Then
If lValueType = REG_SZ Then
strBuffer = New String(" ", lDataBufferSize)
lResult = RegQueryValueEx(hCurKey, strValue, 0, 0, strBuffer, lDataBufferSize)
intZeroPos = InStr(strBuffer, Chr(0))
If intZeroPos > 0 Then
GetSettingString = Left(strBuffer, intZeroPos - 1)
Else
GetSettingString = strBuffer
End If
ElseIf lValueType = REG_DWORD Then
lResult = RegQueryValueEx(hCurKey, strValue, 0, 0, numBuffer, lDataBufferSize)
GetSettingString = VB6.Format(numBuffer)
End If
Else
strErrorMsg = GetErrorString(lRegResult)
End If

lRegResult = RegCloseKey(hCurKey)

End Function[/vb:1:ccdd1f375d]

Thank you very much in advance.

Jazztech
Back to top
View user's profile Send private message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Oct 29th, 2004 07:26 AM    Post subject: Reply with quote

Hi Jazztech,

Here's a module by Andir to read registry using VB .Net.
[link]

Also here one from me:
[link]

Hope this helps!

Thanks!

Edit: Sorry Andir for that one..i recently posted mine and pasted yours 2 times. My mistake. :teehee:
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!


Last edited by Avis on Oct 30th, 2004 01:17 AM; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Oct 30th, 2004 01:05 AM    Post subject: Reply with quote

Those are both mine Razz

I won't hold a grudge.
_________________
If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too.
Back to top
View user's profile Send private message
Jazztech
Newbie


Joined: 28 Oct 2004
Posts: 8

PostPosted: Nov 2nd, 2004 01:26 PM    Post subject: Converting Registry data from VB 6 to VB.Net Reply with quote

Thank you for the assistance. It was extrememly helpful. As you know I am converting Visual Basic 6 code to Visual Basic.Net. Basically I have converted this piece of code which calls a funtion and cycles through the Registry until it find the USB peripheral installed on this computer. When I build the data I am not getting an error message. When I attempt to run this code the peripheral is not displayed I get this message in my Output Window. What is it that I may be missing?


'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\mscorlib.dll', No symbols loaded.
'USBSendData': Loaded 'C:\JT_USBDCPY\bin\USBSendData.exe', Symbols loaded.
'USBSendData.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.3300.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'USBSendData.exe': Loaded 'c:\windows\assembly\gac\system\1.0.3300.0__b77a5c561934e089\system.dll', No symbols loaded.
'USBSendData.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.3300.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
'USBSendData.exe': Loaded 'c:\windows\assembly\gac\microsoft.visualbasic\7.0.3300.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll', No symbols loaded.
'USBSendData.exe': Loaded 'c:\jt_usbdcpy\bin\axinterop.sysinfolib.dll', No symbols loaded.
'USBSendData.exe': Loaded 'c:\windows\assembly\gac\accessibility\1.0.3300.0__b03f5f7f11d50a3a\accessibility.dll', No symbols loaded.
'USBSendData.exe': Loaded 'c:\jt_usbdcpy\bin\interop.sysinfolib.dll', No symbols loaded.
'USBSendData.exe': Loaded 'c:\windows\assembly\gac\microsoft.visualbasic.compatibility\7.0.3300.0__b03f5f7f11d50a3a\microsoft.visualbasic.compatibility.dll', No symbols loaded.
The program '[3204] USBSendData.exe' has exited with code 0 (0x0).

P.S. Also included in this email is the actual piece of code and the function it calls.

Thank you
Jazztech
Back to top
View user's profile Send private message
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Nov 2nd, 2004 07:32 PM    Post subject: Reply with quote

Is this a command line utility?

The error code 0 means it returned without an error. I'm not sure about the symbols not loading.
_________________
If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too.
Back to top
View user's profile Send private message
Jazztech
Newbie


Joined: 28 Oct 2004
Posts: 8

PostPosted: Nov 2nd, 2004 10:21 PM    Post subject: Reply with quote

The situation is that there is no GAC on m PC. I went to C:\Windows\Assembly folder but there was no GAC. Is there a way to create the GAC?
Back to top
View user's profile Send private message
Jazztech
Newbie


Joined: 28 Oct 2004
Posts: 8

PostPosted: Nov 3rd, 2004 02:10 PM    Post subject: Reply with quote

I am into the GAC but read that I need to reload the *.dll files. My question is how to reload these files?
Back to top
View user's profile Send private message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Nov 3rd, 2004 02:23 PM    Post subject: Reply with quote

Hi Jazztech,

I think you load them by calling them.

Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Jazztech
Newbie


Joined: 28 Oct 2004
Posts: 8

PostPosted: Nov 4th, 2004 05:10 PM    Post subject: Reply with quote

Thanks.
Back to top
View user's profile Send private message
Jazztech
Newbie


Joined: 28 Oct 2004
Posts: 8

PostPosted: Nov 5th, 2004 01:49 PM    Post subject: Reply with quote

Thank you. I resolved my issue. I was testing the unit while in debug mode.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Registry & File Input / Output All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic