Delphi simple project to Lazarus lazarus / 8-Other ---------------------------------------------------------------------- cebasso · 2010-01-04 00:40 Hello, I need to pass a simple Delphi project to compile in Lazarus x64 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,   SysUtils; var   h_HOOK: HHOOK; {$R *.res}   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. ---------------------------------------------------------------------- cdbc · 2010-01-04 09:55 Hi Carlos I think your problem stems from the fact, that pointer type sizes are different on x64 platform than on x32 platform. The code tries to typecast a 'longint' (4 bytes) into a pointer...: szBuff := StrPas(PCBTCreateWnd(lp).lpcs.lpszName); Have you tried 'googling' the problem?!? Maybe MSDN, as it is winapi? Regards Benny ---------------------------------------------------------------------- cebasso · 2010-01-04 12:16 Quote from: cdbc on January 04, 2010, 10:55:39 amHi Carlos I think your problem stems from the fact, that pointer type sizes are different on x64 platform than on x32 platform. The code tries to typecast a 'longint' (4 bytes) into a pointer...: szBuff := StrPas(PCBTCreateWnd(lp).lpcs.lpszName); Have you tried 'googling' the problem?!? Maybe MSDN, as it is winapi? Regards Benny Hey finally i have done! i just changed PCBTCreateWnd to PCBT_CreateWnd and used "^" to de- reffing the pointer szBuff := StrPas(PCBT_CreateWnd(lp)^.lpcs^.lpszName); seems to be working, compiled with success but... i will test it and then i reply here Thanks for reply Benny! Cheers ---------------------------------------------------------------------- marcov · 2010-01-06 13:08 It might be wise by setting {$mode delphi} above the library keyword. It could be that you are now in the default (Turbo Pascal alike) mode where "integer" = 16-bit.