Solved

RegDeleteKey

Posted on 2003-11-11
6
872 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

830 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