home *** CD-ROM | disk | FTP | other *** search
/ PC Administrator / spravce.iso / StartRight / source / UnitMyKeys.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2002-10-26  |  2.5 KB  |  90 lines

  1. unit UnitMyKeys;
  2. {
  3.     Purpose:
  4.         define all registry keys used by ME
  5.  
  6.     Notes:
  7.         There are some util functions that really don't belong here
  8.         or anywhere else        
  9. }
  10.  
  11. interface
  12. uses SysUtils, StrUtils;
  13.  
  14.  
  15.  
  16.  
  17. const SR_SUB_RUN = 'Run';
  18. const SR_SUB_RUNSORT = 'RunSort';
  19. const SR_SUB_STARTUPSORT = 'StartupSort';
  20. const SR_SUB_RUNNEWITEMS = 'RunNewItems';
  21. const SR_SUB_STARTUPNEW = 'StartupNew';
  22.  
  23. const SR_STARTRIGHT_VALUE = 'STARTRIGHT';
  24. const SR_EXCLUDE_DATA = 'EXCLUDE';
  25. const SR_SORTINDEX_VALUE  = 'SortIndex';
  26.  
  27. const SR_HOME_KEY = '\SOFTWARE\JackassArswareOrg\StartRight';
  28. const SR_RUN_KEY = SR_HOME_KEY + '\' + SR_SUB_RUN;
  29. const SR_RUNEXCLUDE_KEY =  SR_HOME_KEY +'\RunExclude';
  30. const SR_RUNSORT_KEY = SR_HOME_KEY + '\' + SR_SUB_RUNSORT;
  31. const SR_RUNNEWITEMS_KEY = SR_HOME_KEY + '\' + SR_SUB_RUNNEWITEMS;
  32.  
  33. const SR_STARTUPSORT_KEY = SR_HOME_KEY + '\' + SR_SUB_STARTUPSORT;
  34. const SR_STARTUPEXCLUDE_KEY = SR_HOME_KEY +'\StartupExclude';
  35. const SR_STARTUPDISABLE_KEY = SR_HOME_KEY +'\StartupDisable';
  36. const SR_STARTUPNEW_KEY = SR_HOME_KEY + '\' + SR_SUB_STARTUPNEW;
  37.  
  38. const SR_RUNDISABLED_KEY = SR_HOME_KEY + '\RunDisabled';
  39.  
  40. const WINDOWS_APPSPATH_KEY = '\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths';
  41. const WINDOWS_RUN_KEY = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Run';
  42.  
  43. function GetEXEPathFromRunValue(value : string) : string;
  44. function FindExecutableFromRunValue(value : string) : string;
  45.  
  46. implementation
  47.  
  48. uses Registry, Windows;
  49.  
  50. {util function}
  51. function GetEXEPathFromRunValue(value : string) : string;
  52. var i : integer;
  53. begin
  54.     i := pos('.exe', lowercase(value));
  55.     result := '';
  56.  
  57.     if (i > 0) then begin
  58.         result := LeftStr(value, i + 3);
  59.  
  60.         if leftstr(result,1) ='"' then
  61.             result := RightStr(result, length(result) - 1);
  62.     end;
  63. end;
  64.  
  65.  
  66.  
  67. function FindExecutableFromRunValue(value : string) : string;
  68. var r : TRegistry;
  69. begin
  70.     // extract EXE fullname from 'value'
  71.     // if it doesn't exists, look it up in the registry under "AppsPath"
  72.     // if it still doesn't exist, return an empty string
  73.  
  74.     result := GetEXEPathFromRunValue(value);
  75.     if (result <> '') and
  76.         (not FileExists(result)) then begin
  77.         r := TRegistry.Create();
  78.         r.RootKey := HKEY_LOCAL_MACHINE;
  79.         r.OpenKeyReadOnly(WINDOWS_APPSPATH_KEY + '\' + result);
  80.         result := r.ReadString('');
  81.         if (not FileExists(result)) then begin
  82.             result := '';
  83.         end;
  84.  
  85.         r.free;
  86.     end;
  87. end;
  88.  
  89. end.
  90.