Solved

RegDeleteKey

Posted on 2003-11-11
6
870 Views
Last Modified: 2007-12-19
I cannot seem to get this to work...

I want to delete a string value in the folder mail called - Wide Stationery Name or even better delete the Mail folder itself..any ideas??

my code...

Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
------------------------------------------------

Private Sub cmdDelRegKey()
RegDeleteKey HKEY_CURRENT_USER, "Identities\{B49B514C-8473-414B-B7DD-27006CBCE904}\Software\Microsoft\Outlook Express\5.0\Mail"
End sub
0
Comment
Question by:williari
6 Comments
 
LVL 14

Accepted Solution

by:
aelatik earned 43 total points
ID: 9721704
Try scripting object :

Call CreateObject("wscript.shell").RegDelete("HKCU\Identities\{B49B514C-8473-414B-B7DD-27006CBCE904}\Software\Microsoft\Outlook Express\5.0\Mail\")

Happy programming,
Ayhan Elatik
0
 
LVL 2

Assisted Solution

by:andid0815
andid0815 earned 41 total points
ID: 9721778
or try using the correct api way:
-------
Option Explicit

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) 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 Const STANDARD_RIGHTS_ALL As Long = &H1F0000
Private Const KEY_CREATE_LINK As Long = &H20
Private Const KEY_CREATE_SUB_KEY As Long = &H4
Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
Private Const KEY_NOTIFY As Long = &H10
Private Const KEY_QUERY_VALUE As Long = &H1
Private Const KEY_SET_VALUE As Long = &H2
Private Const SYNCHRONIZE As Long = &H100000
Private Const KEY_ALL_ACCESS As Long = ((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 Const HKEY_CURRENT_USER As Long = &H80000001

Private Const HKEY_CURRENT_USER As Long = &H80000001

Private Sub cmdDelRegKey_Click()
    Dim hRegKey As Long
    Dim lngResult As Long
   
    Call RegOpenKeyEx(HKEY_CURRENT_USER, "Identities\{B49B514C-8473-414B-B7DD-27006CBCE904}\Software\Microsoft\Outlook Express\5.0\Mail", 0, KEY_ALL_ACCESS, hRegKey)
    If hRegKey <> 0 Then
        Call RegDeleteKey(hRegKey, "")
        Call RegCloseKey(hRegKey)
    Else
        'could not open the key
    End If
End Sub
-------

HTH,
Andreas
0
 
LVL 5

Assisted Solution

by:fantasy1001
fantasy1001 earned 41 total points
ID: 9727295
You can also add a reference to Registry Access Function. Project->Reference

Then to delete a key:

    Dim objReg As Registry
    objReg.DeleteKey  ...details here ...

~ fantasy ~
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 10537169
Moderator, my recommended disposition is:

    Split points between: aelatik and andid0815 and fantasy1001

Dan Rollins -- EE database cleanup volunteer
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question