Solved

RegDeleteKey

Posted on 2003-11-11
6
876 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

732 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