|
 |
aspx_beginners thread: convert this vb6 to vb.net HELP
Message #1 by "John Hamman {Hamman Interactive}" <johnhamman@C...> on Wed, 10 Apr 2002 15:45:39 -0400
|
|
HELP! hi all,
im having a pain in the rear time of trying to convert this vb6 code to
VB.NET. Can some one help me with some insite on what i need to do to make
it work?
john
Private Const ERROR_SUCCESS = 0&
Private Const REG_OPTION_NON_VOLATILE = 0 ' Key is preserved when system
is rebooted
Private Const SYNCHRONIZE = &H100000
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_CREATE_LINK = &H20
Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE
Or _
KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or _
KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal
lpReserved As Long, ByVal lpType As Long, ByVal lpData As Any, ByVal
lpcbData As Long) As Long
' Note that if you declare the lpData parameter as String, you must pass
it By Value.
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, ByVal phkResult As Long) As
Long
Public Function FlashInstalled() As Boolean
Dim nRet As Long
Dim hKey As Long
Dim nType As Long
Dim nBytes As Long
Dim Buffer As String
' Open key
nRet = RegOpenKeyEx(HKEY_CLASSES_ROOT, ".swf", 0&, KEY_ALL_ACCESS,
hKey)
If (nRet = ERROR_SUCCESS) Then
' Determine how large the buffer needs to be
nRet = RegQueryValueEx(hKey, "Content Type", 0&, nType, ByVal Buffer,
nBytes)
FlashInstalled = (nRet = ERROR_SUCCESS)
End If
End Function
Message #2 by "Minh T. Nguyen" <nguyentriminh@y...> on Wed, 10 Apr 2002 13:27:04 -0700
|
|
John,
If you just want to query a registry key, you might just want to
use the Registry namespace in .NET. Here's the C# code for that, the
VB.NET code shouldn't be any different:
public bool FlashInstalled() {
Microsoft.Win32.RegistryKey nRet
Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(".swf");
return (nRet!=null);
}
Hope this works,
Minh.
-----Original Message-----
From: John Hamman {Hamman Interactive} [mailto:johnhamman@C...]
Sent: Wednesday, April 10, 2002 12:46 PM
To: aspx_beginners
Subject: [aspx_beginners] convert this vb6 to vb.net HELP
HELP! hi all,
im having a pain in the rear time of trying to convert this vb6 code to
VB.NET. Can some one help me with some insite on what i need to do to
make
it work?
john
Private Const ERROR_SUCCESS = 0&
Private Const REG_OPTION_NON_VOLATILE = 0 ' Key is preserved when
system
is rebooted
Private Const SYNCHRONIZE = &H100000
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_CREATE_LINK = &H20
Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or
KEY_QUERY_VALUE
Or _
KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or
_
KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String,
ByVal
lpReserved As Long, ByVal lpType As Long, ByVal lpData As Any, ByVal
lpcbData As Long) As Long
' Note that if you declare the lpData parameter as String, you must
pass
it By Value.
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, ByVal phkResult As Long) As
Long
Public Function FlashInstalled() As Boolean
Dim nRet As Long
Dim hKey As Long
Dim nType As Long
Dim nBytes As Long
Dim Buffer As String
' Open key
nRet = RegOpenKeyEx(HKEY_CLASSES_ROOT, ".swf", 0&,
KEY_ALL_ACCESS,
hKey)
If (nRet = ERROR_SUCCESS) Then
' Determine how large the buffer needs to be
nRet = RegQueryValueEx(hKey, "Content Type", 0&, nType, ByVal
Buffer,
nBytes)
FlashInstalled = (nRet = ERROR_SUCCESS)
End If
End Function
|
|
 |