Recent

Author Topic: Error compiling SysRec on Win64  (Read 7793 times)

Edson

  • Hero Member
  • *****
  • Posts: 1302
Error compiling SysRec on Win64
« on: July 19, 2016, 07:14:04 am »
Trying to compile SysRec from:

https://sourceforge.net/projects/lazarus-ccr/files/Demos%20and%20examples/SysRec%201.0.0.2/

Give me:

Quote
Recorder.pas(229,14) Error: Illegal type conversion: "LongInt" to "<procedure variable type of function(QWord;LongWord;Int64;Int64):Int64;StdCall>"

in the line:

Code: Pascal  [Select][+][-]
  1.   OldProc := TMWndProc(Windows.GetWindowLong(Handle, GWL_WNDPROC));
  2.  

I can compile correctly it in my Win32 Lazarus, so I suppose this is a Win32 code. How can I compile in my current Win64 Lazarus?
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Error compiling SysRec on Win64
« Reply #1 on: July 19, 2016, 09:46:34 am »
Use windows.SetWindowLongPtr  and getwindowlongptr instead of just -long

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Error compiling SysRec on Win64
« Reply #2 on: July 19, 2016, 05:15:15 pm »
Thanks @marcov

I have replaced GetWindowLong() and SetWindowLong(), by GetWindowLongPtr() and SetWindowLongPtr(), but when executing, Windows shows the message "Application cannot start correctly (0xc000007)"

I have tested using GetWindowLongPtrA(),SetWindowLongPtrA(); GetWindowLongPtrW() and SetWindowLongPtrW(), executing like Admid, and the result is the same.

The code when replacing is:

Code: Pascal  [Select][+][-]
  1. procedure TVideo.Hook;
  2. begin
  3.   OldProc := TMWndProc(Windows.GetWindowLongPtr(Handle, GWL_WNDPROC));
  4.   Windows.SetWindowLongPtr(Handle, GWL_WNDPROC, LongInt(@MsgProc));
  5. end;
  6.  
  7. procedure TVideo.Unhook;
  8. begin
  9.   if Assigned(OldProc) then
  10.     Windows.SetWindowLongPtr(Handle, GWL_WNDPROC, LongInt(OldProc));
  11.   OldProc := nil;
  12. end;
  13.  

It gives me some warnings on conversion between ordinal and pointers.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Error compiling SysRec on Win64
« Reply #3 on: July 19, 2016, 05:19:51 pm »
I have replaced GetWindowLong() and SetWindowLong(), by GetWindowLongPtr() and SetWindowLongPtr(), but when executing, Windows shows the message "Application cannot start correctly (0xc000007)"
Coincidence i just helped someone with such exact issue :-)

You are most probably mixing 32 bit executable code with 64 bit dll's (or vice versa).

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Error compiling SysRec on Win64
« Reply #4 on: July 19, 2016, 06:19:26 pm »
Code: Pascal  [Select][+][-]
  1. procedure TVideo.Hook;
  2. begin
  3.   OldProc := TMWndProc(Windows.GetWindowLongPtr(Handle, GWL_WNDPROC));
  4.   Windows.SetWindowLongPtr(Handle, GWL_WNDPROC, LongInt(@MsgProc));
  5. end;
  6.  


The longints in above code should be ptrint. However that would have yielded access violations, so Molly's comment is probably spot-on.

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Error compiling SysRec on Win64
« Reply #5 on: July 20, 2016, 12:25:05 am »
The longints in above code should be ptrint. However that would have yielded access violations, so Molly's comment is probably spot-on.

Yes. I have tested using PtrInt(), with no success.

You are most probably mixing 32 bit executable code with 64 bit dll's (or vice versa).

I have the feeling, it's the problem. But I don't know where could be the 32bit code. I think Lazarus generate 64bits code in my PC. I don't know if the library SysRec use some dll, or if the driver of my WebCam is 32bit.

Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Error compiling SysRec on Win64
« Reply #6 on: July 20, 2016, 12:37:11 am »
I have the feeling, it's the problem. But I don't know where could be the 32bit code. I think Lazarus generate 64bits code in my PC. I don't know if the library SysRec use some dll, or if the driver of my WebCam is 32bit.
I know for sure ;-)

SysRec project uses unit recorder which uses unit VFW which declares:
Quote
const
    VFWDLL      = 'MSVFW32.DLL';
    AVIFILDLL   = 'AVIFIL32.DLL';
    AVICAPDLL   = 'AVICAP32.DLL';
So, yeah. uhm. it really loads these libraries, while your executable is 64 bit. That ain't going to work  :'(.

Either search for the 64-bit counterpart libraries on your system (and rename those names (as showed above) of the libraries inside unit VFW) or compile your application as a 32-bit application.

« Last Edit: July 20, 2016, 12:39:40 am by molly »

 

TinyPortal © 2005-2018