Solved

RegDeleteKey

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

724 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