Recherche Handler Shell d'exécution en utilisant Delphi
Le Shell supporte plusieurs utilitaires de recherche qui permettent aux utilisateurs de localiser les noms des objets tels que des fichiers ou des imprimantes. Vous pouvez créer un moteur de recherche personnalisé et de les rendre accessibles aux usagers par la mise en œuvre et l'enregistrement d'un gestionnaire de recherche.
Les utilisateurs ont deux façons de choisir un moteur de recherche. La première est dans le menu Démarrer. Avec plus tôt que les systèmes Microsoft Windows 2000, la sélection de la commande Rechercher du menu Démarrer affiche le menu de la disposition des moteurs de recherche. Avec Windows 2000 et versions ultérieures, le menu Démarrer de la commande Rechercher le nom de recherche.
Les utilisateurs peuvent également lancer une recherche à partir de Windows Explorer. Sur les systèmes antérieurs à Windows 2000, ils cliquent sur la commande Rechercher dans le menu Outils pour afficher essentiellement le même menu que celui associé avec le menu Démarrer. Toutefois, l'Explorateur Windows pour Windows 2000 traite les moteurs de recherche de façon très différente. Au lieu de traiter les moteurs de recherche comme un sous-menu du menu Outils, il ya maintenant un bouton de recherche sur la barre d'outils. En cliquant sur ce bouton ouvre la barre de recherche de volet
L'exemple suivant montre comment mettre en œuvre Shell Recherche Handler avec Borland Delphi. Comme toute Shell Extension, il doit être mis en œuvre dans le processus d'in-Component Object Model (COM) objet. Il doit être attribué un identificateur global unique (GUID) et enregistré à l'aide de regsvr32.exe
library SearchHandler;($ R *. RES)
uses
ComServ,
HandlerM in 'HandlerM.pas' ;
exportations
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;
commencer
fin.
{******************************************************************************************************************************* ***************************}
Name : TSearchEngine
Author : Perevoznyk Serhiy
Description : Shell Search Handler
HandlerM unité;
interface
utilise
Windows, ActiveX, ComObj, ShlObj, Dialogs;
type
TSearchEngine = class (TComObject, IShellExtInit, IContextMenu)
protégées
IShellExtInit ()
fonction IShellExtInit.Initialize = SEIInitialize;/ / Eviter d'avertissement du compilateur
fonction SEIInitialize (pidlFolder: PItemIDList; lpdobj: IDataObject;
hKeyProgID: HKEY): HResult; stdcall;
IContextMenu ()
fonction QueryContextMenu (Menu: HMENU; indexMenu, idCmdFirst, idCmdLast,
uFlags: UINT): HResult; stdcall;
fonction InvokeCommand (var lpici: TCMInvokeCommandInfo): HResult; stdcall;
fonctionGetCommandString (idCmd, uType: UINT; pwReserved: PUINT;
pszName: LPSTR; cchMax: UINT): HResult; stdcall;
fin;
const
Class_SearchEngine: TGUID = '(B8091A44-1F5E-4EFE-8F26-194ACBDE4465)';
la mise en œuvre
utilise ComServ, sysutils, ShellApi, Registry;
fonction TSearchEngine.SEIInitialize (pidlFolder: PItemIDList; lpdobj: IDataObject;
hKeyProgID: HKEY): HResult;
commencer
Résultat: = NOERROR;
fin;
fonction TSearchEngine.QueryContextMenu (Menu: HMENU; indexMenu, idCmdFirst,
idCmdLast, uFlags: UINT): HResult;
commencer
Résultat: = 0;
fin;
fonction TSearchEngine.InvokeCommand (var lpici: TCMInvokeCommandInfo): HResult;
commencer
/ / entrez votre code ici
ShowMessage ( 'Executed');
Résultat: = NOERROR;
fin;
fonction TSearchEngine.GetCommandString (idCmd, uType: UINT; pwReserved: PUINT;
pszName: LPSTR; cchMax: UINT): HRESULT;
commencer
if (idCmd = 0) alors
commencer
if (uType = GCS_HELPTEXT), puis
/ / Return string pour aider menu
StrCopy (pszName, «Trouver le document ');
Résultat: = NOERROR;
fin
autre
Résultat: = E_INVALIDARG;
fin;
type
TSearchEngineFactory = class (TComObjectFactory)
public
procédure UpdateRegistry (Registre: Boolean); override;
fin;
procédure CreateKey (const Key, VALUENAME, Valeur: string);
var
Handle: HKEY;
Status, Disposition: Integer;
commencer
Situation: = RegCreateKeyEx (HKEY_LOCAL_MACHINE, PChar (Key), 0,'',
REG_OPTION_NON_VOLATILE, KEY_READ ou KEY_WRITE, nil, Manche,
@ Écoulement);
Situation si = 0 alors
commencer
RegSetValueEx (Handle, PChar (VALUENAME), 0, REG_SZ,
PChar (Value), Length (Value) + 1);
RegCloseKey (Manche);
fin;
fin;
procédure DeleteKey (const Key: string);
commencer
RegDeleteKey (HKEY_LOCAL_MACHINE, PChar (Key));
fin;
procédure TSearchEngineFactory.UpdateRegistry (Registre: Boolean);
var
De classe: string;
FileName: array [0 .. MAX_PATH] de Char;
commencer
Inscrivez ensuite si
commencer
hérité UpdateRegistry (Register);
De classe: = GUIDToString (Class_SearchEngine);
GetModuleFileName (HINSTANCE, FileName, sizeof (FileName));
CreateKey ('Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \' +
«FindExtensions \ Static \ SearchHandler ','', de classe);
CreateKey ( "Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ '+
«FindExtensions \ Static \ SearchHandler \ 0 ','',' Utilisation de Delphi ... ');
CreateKey ('Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \' +
«FindExtensions \ Static \ SearchHandler \ 0 \ DefaultIcon ','', FileName +', 0 ');
fin
autre
commencer
DeleteKey ( "Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ '+
FindExtensions\Static\SearchHandler\0\DefaultIcon');'Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \' +
DeleteKey(
«FindExtensions \ Static \ SearchHandler \ 0 ');
DeleteKey ( "Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ '+
«FindExtensions \ Static \ SearchHandler ');
hérité UpdateRegistry (Register);
fin;
fin;
initialisation
TSearchEngineFactory.Create (ComServer, TSearchEngine, Class_SearchEngine,
'', "Exemple de moteur de recherche de Delphes», ciMultiInstance,
tmApartment);
fin.
Other People Are Searching For...
Related How To's
- Comment Ajouter Formulaire Ombre sur Windows XP
- Comment faire pour installer et désinstaller des polices de Delphi Code
- How To Turn On / Off Monitor avec Delphi
- Comment un programme de Delphi en mode console
- Comment faire pour capturer l'écran avec Delphi
- Comment connecter un Delphi demande d'accès
- Comment faire un programme avec Delphi
- Bon de commande de lignes
- Application.ProcessMessages remplacement
- Comment faire pour récupérer les valeurs AutoInc avec BDP dans Delphi 2005

Be the First to Comment on this Article