detecting when the registry is locked (e.g. limited users with WindowsXP)

chris_at_mricro.com
Date: 12/05/03


Date: Fri, 05 Dec 2003 18:23:33 -0000

Hello-

I have always had my software attempt to create file associations at
startup. Using there, a user can simply click on a '*.img' icon and it
will load the appropriate software (e.g. my free MRIcro brain viewing
software).

However, with WindowsXp, it appears that administrators can severly limit
the ability of standard users to access the registry. Instead of simply
saying that the system can not generate a new assoiciation, the
application crashes. I know that the code below is the culprit, because if
I deactivate this code the program executes normally. Since my software is
used in university student labs where all the computers are restricted, is
there a way that my software can automatically detect if the current user
is an adminstrator or not? If so, my software could be designed to only
update the registry if the user has the appropriate privileges.

Thanks in advance,

-chris

p.s. Here is the offending code, which works on Windows 95+ and is similar
to lots of code you can find with Google (a sample call would me
"registerfiletype('.img','MRIimg'{key},'MRIimg',Application.ExeName+',1');").

procedure registerfiletype(inft,inkey,desc,icon:string);
var myreg : treginifile;
     ct : integer;
     ft,key: string;
begin
      ft := inft;
      key := inkey;
      ct := pos('.',ft);
      while ct > 0 do begin
            delete(ft,ct,1);
            ct := pos('.',ft);
      end;
      if (ft = '') or (Application.ExeName = '') then exit; //not a valid
file-ext or ass. app
      ft := '.'+ft;
      myreg := treginifile.create('');
      try
         myreg.rootkey := hkey_classes_root; // where all file-types are
described
         if key = '' then key := copy(ft,2,maxint)+'_auto_file'; // if no
key-name is given, create one
         myreg.writestring(ft,'',key); // set a pointer to the
description-key
         myreg.writestring(key,'',desc); // write the description
         myreg.writestring(key+'\DefaultIcon','',icon); // write the
def-icon if given
         //showmessage(key);
         myreg.writestring(key+'\shell\open\command','',Application.ExeName+'
%1'); //association
      finally
             myreg.free;
      end;
end;



Relevant Pages

  • Re: System Tray
    ... When I click the icon ... I have tried to contact those at the website but no joy. ... To eliminate a non malware program from running at startup the first step ... Make sure you have a backup of the registry using a program like ERUNT ...
    (microsoft.public.windowsxp.general)
  • Re: System Tray
    ... When I click the icon ... in the system tray it takes me to the following website: ... To eliminate a non malware program from running at startup the first step ... Make sure you have a backup of the registry using a program like ERUNT ...
    (microsoft.public.windowsxp.general)
  • Re: XP Pro - Erratic Start Up
    ... Selective startup is intended for diagnostic purposes, not as a way to run ... If the programs were correctly uninstalled and left behind startup entries, ... "A Definition of the Run Keys in the Windows XP Registry" ... > Show Volume icon is checked. ...
    (microsoft.public.windowsxp.newusers)
  • Registry Cleanup Question
    ... Double click the icon once downloaded. ... >I have just recently upgraded to WindowsXP. ... >Windows XP registry contains a lot of garbage related to ... >Clean-up Utility that will strip out all of the garbage ...
    (microsoft.public.windowsxp.perform_maintain)
  • How can i remove the task bar?
    ... icon and the time) by modifying the registry? ... I want to run my application on startup instead of the to today screen and ...
    (microsoft.public.pocketpc)