[SOLVED] AEGetParamDesc -> -1704 since Lion lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- Gilles · 2016-04-05 10:50 Hi I have a called-back-function which worked perfectly before MacOS X 10.7, which was supposed to open documents. Here is the code : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function f_OpenDocs_back (var xx_aev, xx_rpy: AppleEvent; L_app: SInt32): OSErr;    var        xx_doc: AEDescList;        xErr: OSErr;begin    xErr := AEGetParamDesc(xx_aev, keyDirectObject, typeAEList, @xx_doc);     { at this level, since 10.7, xErr return -1704 }    { which mean : Not a valid descriptor record }    { it worked perfectly well before }    { I have no means how to solve that !!! Any idea ? }     { ... }  I have tried many things, but no way… The declaration of AEDescList I used : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type    FourCharCode = UInt32;    ResType = FourCharCode;    DescType = ResType;    AEDataStorage = ^SInt32;                    { an opaque 32-bit type }    AEDesc = record                descriptorType: DescType;                dataHandle: AEDataStorage        end;    AEDescList = AEDesc; ---------------------------------------------------------------------- Jonas Maebe · 2016-04-05 10:53 If f_OpenDocs_back() is a callback function that is called by the OS, it must be declared as "cdecl;". Without that modifier, it probably only works by chance on earlier OS versions. ---------------------------------------------------------------------- Gilles · 2016-04-05 11:03 it is a function declared at the begining of the program : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var    h_upp: AEEventHandlerUPP;begin     h_upp := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@f_OpenDocs_back));     xErr := AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, h_upp, 0, false);  I don't understand the "cdecl" part of your answer ---------------------------------------------------------------------- Jonas Maebe · 2016-04-05 11:07 So it is indeed a callback that is called by the OS (since you pass its address to AEInstallEventHandler). Add "cdecl;" at the end of its declaration, so that the compiler knows it should use the standard C calling convention rather than the default one (the Delphi-compatible "register" calling convention on i386). ---------------------------------------------------------------------- Gilles · 2016-04-05 14:20 Aaaaaargggg !!! It worked !!! Jonas Maebe, I love you !!! The question is now : how could I have missed that ? It's the first time I see that. Where is it documented ? ---------------------------------------------------------------------- Jonas Maebe · 2016-04-05 14:21 http://www.freepascal.org/docs-html/prog/progsu150.html ---------------------------------------------------------------------- Gilles · 2016-04-05 14:22 Merci 1000 fois. And you are faster than a flash !!