[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Deleting a key in registry

Posted on 1998-08-28
4
Medium Priority
?
182 Views
Last Modified: 2010-04-04
I'm have trouble deleting a key from the registry -> setting the key goes OK - The deleting goes fine too, but the key remains...
Heres the code:

Var
DelKey:pchar;

begin
  OVI.dwOSVersionInfoSize := SizeOf(OVI);
  GetVersionEx(OVI);
  case OVI.dwPlatformID of
       VER_PLATFORM_WIN32_WINDOWS :
          CurVerKey := '\SOFTWARE\Microsoft\Windows\CurrentVersion\Run';
       VER_PLATFORM_WIN32_NT      :
          CurVerKey := '\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Run';
  else
      CurVerKey := '';
  end;

DelKey:='AppLauncher';

      with TRegistry.Create do
        try
          RootKey := HKEY_LOCAL_MACHINE;
          if OpenKey(CurVerKey, False) then
             DeleteKey(DelKey);
          CloseKey;
        finally
          Free;
         End;

Why doesn't this remove the key??

I have checked the spelling many times..

0
Comment
Question by:sancolumbusdk
[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
  • 2
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
ID: 1337961
sancolumbusdk,

don't know why it doesn't work. I don't like the delphi TRegistry object at all. Try my winAPI function:

function RegDelKey(key: HKEY; const path: string) : boolean;
var c2 : cardinal;
begin
  result:=false;
  c2:=RegDeleteKey(key,PChar(path));
  if (c2<>ERROR_SUCCESS) and (c2<>2) then
    Application.MessageBox(PChar('Error number: '+IntToStr(c2)),PChar('Deleting RegKey "'+path+'"'),0);
  result:=c2=ERROR_SUCCESS;
end;
0
 

Author Comment

by:sancolumbusdk
ID: 1337962
Seems interesting vil try it monday :-)
0
 

Author Comment

by:sancolumbusdk
ID: 1337963
I've checked the routine, and it lead me to another conclusion. My routine doesn't work because I'm trying to delete key when it is a Value I want to remove. So I used the wrong method.

Your function works too if it is used for deleting keys - not values..


0
 
LVL 20

Expert Comment

by:Madshi
ID: 1337964
That's right...   :-)
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 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