Jump to content


Photo

Translate VB 6 to .NET


  • Please log in to reply
2 replies to this topic

#1 crushed

crushed

    Young Padawan

  • Members
  • Pip
  • 30 posts

Posted 22 May 2005 - 05:43 PM

Hi, I recently had a question regarding how to edit REG_DWORDS in the registry, and have now found coding for it! Great, right? Well it turns out this is VB 6 coding, and I was wondering if any of you are having a lazy Sunday, would mind translating it for me? I'm basically a noob, and am looking for help. Thanks!

Declarations
Option Explicit
Dim msg As String
Private Const REG_DWORD As Long = 4
Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_ALL_ACCESS = &H3F
Private Const REG_OPTION_NON_VOLATILE = 0

Private Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey _
As String, _ByVal ulOptions As Long, ByVal samDesired As Long,_ phkResult As Long) As Long

Private Declare Function RegSetValueExLong Lib _
"advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long,_
ByVal lpValueName As String,ByVal Reserved As Long, _
ByVal dwType As Long, lpValue As Long,ByVal cbData As Long) As Long

Code
Private Sub cmdfav_Click()
SetKeyValue "Software\Microsoft\Windows\Currentversion\policies\explorer", "NoFavoritesMenu", 1, REG_DWORD
msg = MsgBox("You need to restart Windows for the changes to take place.", vbCritical, "Restart Windows")
End Sub

The code is the example given? See this line? (Below)
SetKeyValue "Software\Microsoft\Windows\Currentversion\policies\explorer", "NoFavoritesMenu", 1, REG_DWORD
I know how to get the path, the specified name of the hex, etc, but see where it says:
1, REG_DWORD?
When I add the above to my project, it won't recognize it. I am wondering if this has to do with declarations. I think everything is fine, except for the declaration for REG_DWORD needs to be translated. Thanks!

#2 soyunlocofl

soyunlocofl

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Location:FL

Posted 23 May 2005 - 11:50 PM

Hi, I recently had a question regarding how to edit REG_DWORDS in the registry, and have now found coding for it! Great, right? Well it turns out this is VB 6 coding, and I was wondering if any of you are having a lazy Sunday, would mind translating it for me? I'm basically a noob, and am looking for help. Thanks!

Declarations
Option Explicit
Dim msg As String
Private Const REG_DWORD As Long = 4
Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_ALL_ACCESS = &H3F
Private Const REG_OPTION_NON_VOLATILE = 0

Private Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey _
As String, _ByVal ulOptions As Long, ByVal samDesired As Long,_ phkResult As Long) As Long

Private Declare Function RegSetValueExLong Lib _
"advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long,_
ByVal lpValueName As String,ByVal Reserved As Long, _
ByVal dwType As Long, lpValue As Long,ByVal cbData As Long) As Long

Code
Private Sub cmdfav_Click()
SetKeyValue "Software\Microsoft\Windows\Currentversion\policies\explorer", "NoFavoritesMenu", 1, REG_DWORD
msg = MsgBox("You need to restart Windows for the changes to take place.", vbCritical, "Restart Windows")
End Sub

The code is the example given? See this line? (Below)
SetKeyValue "Software\Microsoft\Windows\Currentversion\policies\explorer", "NoFavoritesMenu", 1, REG_DWORD
I know how to get the path, the specified name of the hex, etc, but see where it says:
1, REG_DWORD?
When I add the above to my project, it won't recognize it. I am wondering if this has to do with declarations. I think everything is fine, except for the declaration for REG_DWORD needs to be translated. Thanks!


Try this
Private Const clngREG_DWORD As Long = 4


#3 crushed

crushed

    Young Padawan

  • Members
  • Pip
  • 30 posts

Posted 25 May 2005 - 08:08 PM

nope..but sincerely, thanks..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users