Solved

RegDeleteKey

Posted on 2003-11-11
6
867 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Moderator, my recommended disposition is:

    Split points between: aelatik and andid0815 and fantasy1001

Dan Rollins -- EE database cleanup volunteer
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now