|
-
Aug 29th, 2003, 10:15 AM
#1
Thread Starter
Fanatic Member
Why won't this work...?! (easy...)
Messing around with the register. Everything's working fine, but I just can find out how to read a value... Can anyone fix this code (so that strBuf holds the value...)?
VB Code:
Dim lngResult As Long, strBuf As String
strBuf = Space$(255)
RegOpenKey HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProgram", lngResult
RegQueryValueEx lngResult, "UninstallString", ByVal 0&, REG_SZ, ByVal strBuf, Len(strBuf)
RegCloseKey lngResult
Author for Visual Basic Web Magazine
-
Aug 29th, 2003, 10:27 AM
#2
Addicted Member
May i comment ....
May be this helps...
strBuf = Space$(255) ?
'Try This
strBuf = String(255, 0& )
I may have interpret your post wrongly
Correct me if I made a mistake...
Hope This Helps.. .....Enjoy Coding.....//
zak2zak
-
Aug 29th, 2003, 10:46 AM
#3
Thread Starter
Fanatic Member
Re: May i comment ....
Originally posted by zak2zak
May be this helps...
strBuf = Space$(255) ?
'Try This
strBuf = String(255, 0& )
Thanks, but it doesn't make a difference...
Author for Visual Basic Web Magazine
-
Aug 29th, 2003, 11:09 AM
#4
Addicted Member
May i comment again?
May be this helps....
This is a working code......
VB Code:
Public 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
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006
Public Const KEY_READ = &H20019
Public Const REG_SZ = 1
'--------------------------------------------------------------------
Dim lngResult As Long
Dim strBuf As String
Dim subkey As String
Dim datatype As Long
Dim slen As Long
Dim retval As Long
' Set the name of the new key and the default security settings
subkey = "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProgram"
' Create or open the registry key
retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, subkey, 0, KEY_READ, lngResult)
If retval <> 0 Then
MsgBox "ERROR: Unable to open registry key!"
Exit Sub
End If
strBuf = Space(255)
slen = 255
retval = RegQueryValueEx(lngResult, "UninstallString", 0, datatype, ByVal strBuf, slen)
If datatype = REG_SZ Then
strBuf = Left(strBuf, slen - 1)
MsgBox "UninstallString: " & strBuf
Else
MsgBox "Data not in string format. Unable to interpret data."
End If
retval = RegCloseKey(lngResult)
I may have interpret your post wrongly
Correct me if I made a mistake...
Hope This Helps.. .....Enjoy Coding.....//
zak2zak
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|