I'm probably stupid but...
I can't call the LresultFromObject function (from the windows system dll 'oleacc.dll') within Lazarus. Any kind of call provokes always a SIGSEGV.
The same call with the same parameters is OK with FPC (and also with Delphi 7).
Trying to play with the "mode" or within any declaration for the parameters doesn't change the results: always KO with the LCL, and always OK with FPC.
Using my own LCL "alternative" gives also a correct result: so the problem is really concerning the LCL.
Here is a simple test code for a demonstration (parameters don't have any signification for this test).
LCL version (a form with a pushbutton and a statictext controls):
unit Unit1;
{$mode objfpc}{$H+}
//{$mode delphi}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
StaticText1: TStaticText;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
type
WPARAMM = NativeUInt;
HRESULTT = NativeUInt;
// WPARAMM = Longword;
// HRESULTT = Longword;
function LResultFromObject(riid: Pointer; wParam: WPARAMM; pAcc: Pointer): HRESULTT; stdcall; external 'oleacc.dll' name 'LresultFromObject';
procedure TForm1.Button1Click(Sender: TObject);
var aWParam: WPARAMM;
var aResult: HRESULTT;
var aArray: array [0..pred(256)] of Byte;
var ppp: Pointer;
begin
awParam:=0;
FillChar(aArray,Sizeof(aArray),0);
ppp:=@aArray;
aResult := LResultFromObject(ppp, aWParam, @aArray);
StaticText1.Caption := 'Result='+IntToStr(aResult);
end;
end.
Same code for an FPC program:
program project1;
{$mode objfpc}{$H+}
//{$mode delphi}
type
WPARAMM = NativeUInt;
HRESULTT = NativeUInt;
// WPARAMM = Longword;
// HRESULTT = Longword;
function LResultFromObject(riid: Pointer; wParam: WPARAMM; pAcc: Pointer): HRESULTT; stdcall; external 'oleacc.dll' name 'LresultFromObject';
var aWParam: WPARAMM;
var aResult: HRESULTT;
var aArray: array [0..pred(256)] of Byte;
var ppp: Pointer;
var sResult: String;
begin
awParam:=0;
FillChar(aArray,Sizeof(aArray),0);
ppp:=@aArray;
aResult := LResultFromObject(ppp, aWParam, @aArray);
str(aResult, sResult);
WriteLn('Result='+sResult);
end.
Does anybody see a good reason to explain the crash with the LCL, and especially the difference(s) when FPC only is used in this case ? Currently, I'm stuck...