| View previous topic :: View next topic |
| Author |
Message |
Jazztech Newbie
Joined: 28 Oct 2004 Posts: 8
|
Posted: Oct 28th, 2004 10:00 PM Post subject: Converting Registry data from VB 6 to VB.Net |
|
|
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 |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Oct 30th, 2004 01:05 AM Post subject: |
|
|
Those are both mine
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 |
|
Jazztech Newbie
Joined: 28 Oct 2004 Posts: 8
|
Posted: Nov 2nd, 2004 01:26 PM Post subject: Converting Registry data from VB 6 to VB.Net |
|
|
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 |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Nov 2nd, 2004 07:32 PM Post subject: |
|
|
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 |
|
Jazztech Newbie
Joined: 28 Oct 2004 Posts: 8
|
Posted: Nov 2nd, 2004 10:21 PM Post subject: |
|
|
| 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 |
|
Jazztech Newbie
Joined: 28 Oct 2004 Posts: 8
|
Posted: Nov 3rd, 2004 02:10 PM Post subject: |
|
|
| 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 |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
Jazztech Newbie
Joined: 28 Oct 2004 Posts: 8
|
Posted: Nov 4th, 2004 05:10 PM Post subject: |
|
|
| Thanks. |
|
| Back to top |
|
Jazztech Newbie
Joined: 28 Oct 2004 Posts: 8
|
Posted: Nov 5th, 2004 01:49 PM Post subject: |
|
|
| Thank you. I resolved my issue. I was testing the unit while in debug mode. |
|
| Back to top |
|
|