cebasso
asked on
Delphi to Lazarus?
Hello,
I need to pass a simple Delphi project to compile in Lazarus x64
Since this project when compiled on Delphi x86 doesnt work on a x64 OS
and... as i need to compile on x64 compiler, i'm using Lazarus hehe
take a look at the source!! i tried to compile and searching before but CBT_CreateWnd i can't typecast the lP Param :(
NOTE: I tried to port it from Delphi to Lazarus using Tools >Â Delphi project to Lazarus Project but no success...
How to make this code working on Lazarus?
Can somebody help me?
Best Regards,
Carlos
I need to pass a simple Delphi project to compile in Lazarus x64
Since this project when compiled on Delphi x86 doesnt work on a x64 OS
and... as i need to compile on x64 compiler, i'm using Lazarus hehe
take a look at the source!! i tried to compile and searching before but CBT_CreateWnd i can't typecast the lP Param :(
NOTE: I tried to port it from Delphi to Lazarus using Tools >Â Delphi project to Lazarus Project but no success...
How to make this code working on Lazarus?
Can somebody help me?
Best Regards,
Carlos
(* ORIGINAL DELPHI CODE *)
library uap;
uses
Windows;
var
h_HOOK: HHOOK;
{$R *.res}
function StrPas(const Str: PChar): String;
begin
Result := Str;
end;
function LowerCase(const S: string): string;
var
Ch: Char;
L: Integer;
Source, Dest: PChar;
begin
L := Length(S);
SetLength(Result, L);
Source := Pointer(S);
Dest := Pointer(Result);
while L <> 0 do
begin
Ch := Source^;
if (Ch >= 'A') and (Ch <= 'Z') then
Inc(Ch, 32);
Dest^ := Ch;
Inc(Source);
Inc(Dest);
Dec(L);
end;
end;
function CBTProc(nCode: Integer; wP: WPARAM; lP: LPARAM): LRESULT; StdCall;
var
szBuff: String;
begin
try
if (nCode >= HC_ACTION) then
begin
case nCode of
HCBT_CREATEWND:
begin
szBuff := StrPas(PCBTCreateWnd(lp).lpcs.lpszName);
if (szBuff <> '') then
if (Pos('notepad', LowerCase(szBuff)) > 0) then
begin
//no more notepad
Result := 1;
Exit;
end;
end;
end;
end;
Result := CallNextHookEx(h_HOOK, nCode, wP, lP);
except
Result := 0;
end;
end;
function InitUAP: BOOL; StdCall;
begin
h_HOOK := SetWindowsHookEx(WH_CBT, @CBTProc, SysInit.HInstance, 0);
Result := LongBool(h_HOOK);
end;
function DeinitUAP: BOOL; StdCall;
begin
Result := LongBool(h_HOOK);
if Result then
Result := UnhookWindowsHookEx(h_HOOK);
end;
exports
InitUAP name 'InitUAP',
DeinitUAP name 'DeinitUAP';
end.
What is the compiler error you get?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.