Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Programm in einer dll (https://www.delphipraxis.net/26863-programm-einer-dll.html)

endeffects 31. Jul 2004 11:34

Re: Programm in einer dll
 
hi, danke für den tip :)
hab dazu ein paar nette beispiele gefunden,
mit denen ich sicher noch rumexperimentieren werden,
das problem bei dieser methode ist aber das man dafür
einen loader(.exe) braucht, als explorer plugin würde
die dll automatisch bei jedem windowsstart geladen werden.

nur weiß ich leider nicht wie ich der dll einen timer verpasse :(

endeffects 31. Jul 2004 13:27

Re: Programm in einer dll
 
hier mal ein beispiel aus den delphi demos das ich noch
nicht so ganz nachvollziehen kann.

als erstes würde mich einmal interessieren wie sich
folgender wert berechnet

Zitat:

Class_CopyHook: TGUID = '{29F97553-FBD6-11D1-AFC1-00A024D1875C}';
mit hilfe dieses wertes wird dann unter dem schlüssel
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Shell Extensions\Approved
ein eintrag angelegt, wozu genau bleibt mir ein rätsel

woher weiß windows nun für welche anwendung die dll geschrieben wurde?
woher bezieht die methode TCopyHook.CopyCallBack die Konstanten/Flags
FO_COPY, F0_DELETE usw. und wie finde ich z.b. nun über die shell
herraus ob sich ein internet explorer fenster geöffnet hat.

ich hab zu all dem wirklich stundenlang im web gewühlt, aber
informationen dazu sind kaum zu finden und ms bietet leider
keinen delphi support :)

Delphi-Quellcode:
unit CopyHk;

interface

uses
  Windows, ActiveX, ComObj, ShlObj;

type
  TCopyHook = class(TComObject, ICopyHook)
  public
    function CopyCallback(Wnd: HWND; wFunc, wFlags: UINT; pszSrcFile: PAnsiChar;
      dwSrcAttribs: DWORD; pszDestFile: PAnsiChar; dwDestAttribs: DWORD): UINT; stdcall;
  end;

const
  Class_CopyHook: TGUID = '{29F97553-FBD6-11D1-AFC1-00A024D1875C}';

implementation

uses ComServ, ShellAPI, SysUtils, Registry;

function TCopyHook.CopyCallBack(Wnd: HWND; wFunc, wFlags: UINT; pszSrcFile: PAnsiChar;
  dwSrcAttribs: DWORD; pszDestFile: PAnsiChar; dwDestAttribs: DWORD): UINT;
// This is the method which is called by the shell for folder operations
const
  ConfirmMessage = 'Are you sure you want to %s ''%s''?';
var
  Operation: string;
begin
  case wFunc of
    FO_COPY:
      Operation := 'copy';
    FO_DELETE:
      Operation := 'delete';
    FO_MOVE:
      Operation := 'move';
    FO_RENAME:
      Operation := 'rename';
    else
      Operation := 'continue this operation on'
  end;

  // confirm operation
  Result := MessageBox(Wnd, PChar(Format(ConfirmMessage, [Operation, pszSrcFile])),
    'Delphi CopyHook Shell Extension...' , MB_YESNOCANCEL);
end;

type
  TCopyHookFactory = class(TComObjectFactory)
  public
    procedure UpdateRegistry(Register: Boolean); override;
  end;

procedure TCopyHookFactory.UpdateRegistry(Register: Boolean);
var
  ClassID: string;
begin
  if Register then begin
    inherited UpdateRegistry(Register);

    ClassID := GUIDToString(Class_CopyHook);
    CreateRegKey('Directory\shellex\CopyHookHandlers\DelphiCopyHook', '', ClassID);
    if (Win32Platform = VER_PLATFORM_WIN32_NT) then
      with TRegistry.Create do
        try
          RootKey := HKEY_LOCAL_MACHINE;
          OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions', True);
          OpenKey('Approved', True);
          WriteString(ClassID, 'Delphi CopyHook Shell Extension Example');
        finally
          Free;
        end;
  end
  else begin
    DeleteRegKey('Directory\shellex\CopyHookHandlers\DelphiCopyHook');

    inherited UpdateRegistry(Register);
  end;
end;

initialization
  TCopyHookFactory.Create(ComServer, TCopyHook, Class_CopyHook, '',
    'Delphi CopyHook Shell Extension Example', ciMultiInstance, tmApartment);
end.


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:45 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz