Autor Beitrag
JacK_Silent
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Do 22.11.07 18:16 
Heyaa =D

Hab hier ein Programm geschrieben, welches eine Tastenkombination erkennt und umwandelt.
Das ganze ist komplett ohne VCL.

HDD Speicher: 15kb (ist top!)
RAM Speicher: ca 1700kb --> zu viel

Wie kann ich den RAM Speicherbedarf dieses Programms senken:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
program BackForwardHook;

uses
  Windows,
  Messages;

const
  szClassname = 'BackForwardHook';

function WndProc(wnd: HWND; uMsg: UINT; wp: WPARAM; lp: LPARAM): lresult; stdcall;
begin
  Result := 0;

  case uMsg of
    WM_CREATE:
      begin
        RegisterHotKey(wnd,4052007,MOD_ALT xor MOD_CONTROL,39);
        RegisterHotKey(wnd,4052008,MOD_ALT xor MOD_CONTROL,37);
      end;
    WM_DESTROY:
      begin
        UnRegisterHotKey(wnd,4052007);
        UnRegisterHotKey(wnd,4052008);
        PostQuitMessage(0);
      end;
    WM_HOTKEY:
      case wp of
        4052007:
              begin
              mouse_event($008000$00020);       // Xbutton2 down
              mouse_event($010000$00020);       // Xbutton2 UP
              end;

       4052008:
              begin
              mouse_event($008000$00010);       // Xbutton1 down
              mouse_event($010000$00010);       // Xbutton1 down
              end;

      end;
    else
      Result := DefWindowProc(wnd, uMsg, wp, lp);
  end;
end;

var
  {Struktur der Fensterklasse}
  wc   : TWndClassEx = (
    cbSize          : SizeOf(TWndClassEx);
    lpfnWndProc     : @WndProc;
    lpszClassName   : szClassname;
  );
  msg  : TMsg;
  aWnd : HWND;

begin
  if(RegisterClassEx(wc) = 0then exit;
  aWnd := CreateWindowEx(0, szClassname, nil00 ,000000,  nil);
  while GetMessage(msg,0,0,0do
    begin
      TranslateMessage(msg);
      DispatchMessage(msg);
    end;
  ExitCode := msg.wParam;
end.


Danke für eure Hilfe!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 23.11.07 00:49 
Schau mal mit einem erweiterten Taskmanager (z.B. Process Explorer) nach, wo der Speicher verbraten wird.

Tipp: Es hilft meist schon, die benötigten Funktionen und Konstanten der Units Windows.pas und Messages.pas zu kopieren und komplett ohne diese Units zu arbeiten. Damit vermeidest Du u.U. das Laden einiger DLLs, die Delphi fälschlicherweise als Import-Required einträgt.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.