Closed dummzeuch closed 4 years ago
The fix is easy:
Add the following to the LegacyTypes unit:
{$IF CompilerVersion = 15} // Delphi 7: PNativeInt doesn't exist type PNativeInt=^NativeInt; {$IFEND}
Another problem is the UTF-8 BOM in CPUID.pas. I had to delete it to make it compile with Delphi 7
And finally I had to remove the namespace prefixes in uMain.pas (Demo1) and change the LPCWSTR in the TMessageBox type and the InterceptMessageBox function to LPCSTR:
type TMessageBox = function(hWnd: hWnd; lpText, lpCaption: LPCSTR; uType: UINT): Integer; stdcall;
function InterceptMessageBox(hWnd: hWnd; lpText, lpCaption: LPCSTR; uType: UINT): Integer; stdcall;
After these changes everyting compiled and the demo worked in Delphi 7.
I think this change will also still compile and work with newer Delphi versions, but I haven't tested it.
EDIT: No, it only works up to Delphi 2007. It fails with the first Unicode version, Delphi 2009. So the fix is more complex:
type {$IFDEF UNICODE} TMessageBox = function(hWnd: hWnd; lpText, lpCaption: LPCWSTR; uType: UINT): Integer; stdcall; {$ELSE} TMessageBox = function(hWnd: hWnd; lpText, lpCaption: LPCSTR; uType: UINT): Integer; stdcall; {$ENDIF}
{$IFDEF UNICODE} function InterceptMessageBox(hWnd: hWnd; lpText, lpCaption: LPCWSTR; uType: UINT): Integer; stdcall; {$ELSE} function InterceptMessageBox(hWnd: hWnd; lpText, lpCaption: LPCSTR; uType: UINT): Integer; stdcall; {$ENDIF}
Sorry for that. It was working perfectly on D7 the moment when I announced the immediate availability of DDetours v2.2. Later I introduced PNativeInt and I forgot to check on D7.
Give some moment, I'll make a patch based on your recommendation to fix all those incompatibility issues.
N.B: On my machine, I only have D7, Lazarus and Rio. So I cant know for sure about other versions but if it works on D7 it should for all.
Thanks.
For Unicode issue, I think having a separate Demo for D7 is much good because on my Rio I'm having several problems opening project from old Delphi version.
Even though you claim that it is compatible with Delphi 7, it doesn't compile:
[Error] DDetours.pas(1387): Undeclared identfier 'PNativeInt'
(Or did I take the wrong source code? I took the master branch from https://github.com/MahdiSafsafi/DDetours.git )