[Meta-diff-devel] CompareShellEx CompareShellEx.dpr,1.5,1.6
Brought to you by:
undees
From: Sebastian S. <ey...@us...> - 2005-08-26 20:24:14
|
Update of /cvsroot/meta-diff/CompareShellEx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8934/CompareShellEx Modified Files: CompareShellEx.dpr Log Message: - Fixed a bug in unregistering the shell extension. - Added the possibility to register for the current user only. Index: CompareShellEx.dpr =================================================================== RCS file: /cvsroot/meta-diff/CompareShellEx/CompareShellEx.dpr,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CompareShellEx.dpr 17 Aug 2005 21:57:14 -0000 1.5 --- CompareShellEx.dpr 26 Aug 2005 20:24:06 -0000 1.6 *************** *** 342,350 **** end; procedure Install(hWnd:HWND;hInstance:HINST;lpszCmdLine:LPSTR;nCmdShow:Integer); stdcall; var ! RetVal,i:Integer; dw:DWORD; ! s,DllLoc,GUIDs:string; Reg:TRegistry; begin --- 342,353 ---- end; + // Disable hint H2077 about the unused "AddCount" if "UnInstallMsgBox" is not + // defined. Unfortunately, Delphi has no way to disable only specific hints. + {$HINTS OFF} procedure Install(hWnd:HWND;hInstance:HINST;lpszCmdLine:LPSTR;nCmdShow:Integer); stdcall; var ! RetVal,AddCount,i:Integer; dw:DWORD; ! p,s,DllLoc,GUIDs:string; Reg:TRegistry; begin *************** *** 359,366 **** if (RetVal<>0) and (DllLoc<>'') then begin if not FileExists(ExtractFilePath(DllLoc)+ApplicationExe) then begin ! MessageBox(0, ! PChar('Please place '+LibraryName+'.dll into the same directory where '+ ApplicationExe+' is!' ! ),'Error',0 ); Exit; --- 362,373 ---- if (RetVal<>0) and (DllLoc<>'') then begin if not FileExists(ExtractFilePath(DllLoc)+ApplicationExe) then begin ! MessageBox( ! hWnd, ! PChar( ! 'Please place '+LibraryName+'.dll into the same directory where '+ ApplicationExe+' is!' ! ), ! 'Error', ! MB_OK or MB_ICONERROR ); Exit; *************** *** 368,379 **** GUIDs:=GUIDToString(CLSID_ContextMenuShellExtension); Reg:=TRegistry.Create; try ! Reg.RootKey:=HKEY_CLASSES_ROOT; for i:=Low(RegKeys) to High(RegKeys) do begin if i=Low(RegKeys) then ! s:=Format(RegKeys[i],[GUIDs]) else ! s:=RegKeys[i]; if not Reg.OpenKey(s,True) then --- 375,400 ---- GUIDs:=GUIDToString(CLSID_ContextMenuShellExtension); + Reg:=TRegistry.Create; try ! AddCount:=0; ! ! // HKEY_CLASSES_ROOT merges ! // HKEY_CURRENT_USER\SOFTWARE\Classes ! // and ! // HKEY_LOCAL_MACHINE\SOFTWARE\Classes ! if lpszCmdLine='user' then begin ! Reg.RootKey:=HKEY_CURRENT_USER; ! p:='SOFTWARE\Classes\'; ! end else begin ! Reg.RootKey:=HKEY_CLASSES_ROOT; ! p:=''; ! end; ! for i:=Low(RegKeys) to High(RegKeys) do begin if i=Low(RegKeys) then ! s:=p+Format(RegKeys[i],[GUIDs]) else ! s:=p+RegKeys[i]; if not Reg.OpenKey(s,True) then *************** *** 391,394 **** --- 412,417 ---- Reg.WriteString('',GUIDs); Reg.CloseKey; + + Inc(AddCount); end; *************** *** 400,416 **** Reg.WriteString(GUIDs,LibraryName); Reg.CloseKey; finally Reg.Free; end; SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_IDLIST,nil,nil); {$IFDEF UnInstallMsgBox} ! MessageBox(0,'Installation successful.',Libraryname+' '+VersionStr,0); {$ENDIF} end else ! MessageBox(0,'Can''t locate '+LibraryName+'.dll','Error',0); except ! on E:Exception do MessageBox(0,PChar(E.Message),'Exception',0); end; end; // Disable hint H2077 about the unused "RemoveCount" if "UnInstallMsgBox" is not --- 423,457 ---- Reg.WriteString(GUIDs,LibraryName); Reg.CloseKey; + + Inc(AddCount); finally Reg.Free; end; + SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_IDLIST,nil,nil); + {$IFDEF UnInstallMsgBox} ! MessageBox( ! hWnd, ! PChar( ! IntToStr(AddCount)+ ! ' entries have been added to the registry.' ! ), ! Libraryname+' '+VersionStr, ! MB_OK or MB_ICONINFORMATION ! ); {$ENDIF} end else ! MessageBox( ! hWnd, ! 'Can''t locate '+LibraryName+'.dll', ! 'Error', ! MB_OK or MB_ICONERROR ! ); except ! on E:Exception do MessageBox(hWnd,PChar(E.Message),'Exception',MB_OK or MB_ICONERROR); end; end; + {$HINTS ON} // Disable hint H2077 about the unused "RemoveCount" if "UnInstallMsgBox" is not *************** *** 421,464 **** RemoveCount,i:Integer; Reg:TRegistry; ! s:string; GUIDs:string; begin try GUIDs:=GUIDToString(CLSID_ContextMenuShellExtension); Reg:=TRegistry.Create; try RemoveCount:=0; ! Reg.RootKey:=HKEY_CLASSES_ROOT; for i:=Low(RegKeys) to High(RegKeys) do begin if i=Low(RegKeys) then ! s:=Format(RegKeys[i],[GUIDs]) else ! s:=RegKeys[i]; if Reg.DeleteKey(s) then Inc(RemoveCount); - - // For Windows NT and above, remove oneself from the list of - // approved shell extensions. - Reg.RootKey:=HKEY_LOCAL_MACHINE; - if not Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved',True) then - RaiseLastOSError; - if Reg.DeleteValue(GUIDs) then - Inc(RemoveCount); - Reg.CloseKey; end; finally Reg.Free; end; SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_IDLIST,nil,nil); {$IFDEF UnInstallMsgBox} ! MessageBox(0,PChar( ! IntToStr(RemoveCount)+' entries have been removed from the registry. '+ ! 'Please remove any files manually.'), ! Libraryname+' '+VersionStr,0 ); {$ENDIF} except ! on E:Exception do MessageBox(0,PChar(E.Message),'Exception',0); end; end; --- 462,525 ---- RemoveCount,i:Integer; Reg:TRegistry; ! p,s:string; GUIDs:string; begin try GUIDs:=GUIDToString(CLSID_ContextMenuShellExtension); + Reg:=TRegistry.Create; try RemoveCount:=0; ! ! // HKEY_CLASSES_ROOT merges ! // HKEY_CURRENT_USER\SOFTWARE\Classes ! // and ! // HKEY_LOCAL_MACHINE\SOFTWARE\Classes ! if lpszCmdLine='user' then begin ! Reg.RootKey:=HKEY_CURRENT_USER; ! p:='SOFTWARE\Classes\'; ! end else begin ! Reg.RootKey:=HKEY_CLASSES_ROOT; ! p:=''; ! end; ! for i:=Low(RegKeys) to High(RegKeys) do begin if i=Low(RegKeys) then ! s:=p+Format(RegKeys[i],[GUIDs]) else ! s:=p+RegKeys[i]; if Reg.DeleteKey(s) then Inc(RemoveCount); end; + + // For Windows NT and above, remove oneself from the list of + // approved shell extensions. + Reg.RootKey:=HKEY_LOCAL_MACHINE; + if not Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved',True) then + RaiseLastOSError; + if Reg.DeleteValue(GUIDs) then + Inc(RemoveCount); + Reg.CloseKey; finally Reg.Free; end; + SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_IDLIST,nil,nil); + {$IFDEF UnInstallMsgBox} ! MessageBox( ! hWnd, ! PChar( ! IntToStr(RemoveCount)+ ! ' entries have been removed from the registry. '+ ! 'Please remove any files manually.' ! ), ! Libraryname+' '+VersionStr, ! MB_OK or MB_ICONINFORMATION ); {$ENDIF} except ! on E:Exception do MessageBox(hWnd,PChar(E.Message),'Exception',MB_OK or MB_ICONERROR); end; end; |