Not sure how to clean up legacy DDE codes lazarus / 34-Windows ---------------------------------------------------------------------- PaulRowntree · 2019-10-02 13:57 I have been using some DDEML client codes for over two decades that are based on some original Delphi classes; I converted this to lazarus in 2011.  Code runs, but requires RangeChecking to be off, and it gives many warnings about unsafe conversions etc.  I now read that the use of the MakeProcInstance (and FreeProcInstance I assume) is deprecated ( https://devblogs.microsoft.com/oldnewthing/20080207-00/?p=23533  ) but I have no idea what the recommended way to do this under modern Win system.  I am running Win 7-10, Laz 1.8.4 Here is the working but obsolete code fragment, from the bottom of my DDEML unit.  The purpose is to initialize the DDE link, and to insert the code into the exit chain mechanism.  The DDE system does not function if a NIL CallBackPtr is passed to DDEInitialize as written.  If it matters, I don't actually use the Advise functionality, so the CallBackpROC is never used in my codes .. it is always based on direct transactions with the DDE system. Any suggestions or guidance would be greatly appreciated.  Thanks! 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    CallBackPtr : Pointer;    ChainExit      : POINTER;{$S-}PROCEDURE DDEML_ExitProc; far;begin  if DDEML_Instance <> 0 then    DdeUninitialize(DDEML_Instance);   { Ignore the return value }   if CallBackPtr <> nil then    FreeProcInstance(longint(CallBackPtr));   ExitProc := ChainExit;END;{$S+} BEGIN{ install the exit codes }    ChainExit := ExitProc;    ExitProc := @DDEML_ExitProc;  CallBackPtr := pointer( MakeProcInstance( longint(@CallBackProc), HInstance) );//  CallBackPtr := NIL;  DDEML_INstance := 0; { Initialize the DDE and setup the callback function. }  if CallBackPtr <> nil then    DdeInitialize(@DDEML_Instance, PFNCallback(CallBackPtr), AppClass_STANDARD,0);END. ---------------------------------------------------------------------- marcov · 2019-10-02 14:10 longint(@CallBackProc)  is wrong, since longint is 32-bit and callbackproc is 64-bit on 64-bit systems. It would be helpful to see the exact errors you get. ---------------------------------------------------------------------- PaulRowntree · 2019-10-02 14:44 Sorry ... first reply was a mess ... There are no compile errors, but here are the 4 warnings 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 ddeml_laz.pas(389,30) Warning: Procedure type "FAR" ignored  *** this is the DDEML_ExitProcddeml_laz.pas(395,22) Warning: Conversion between ordinals and pointers is not portableddeml_laz.pas(406,44) Warning: Conversion between ordinals and pointers is not portableddeml_laz.pas(406,17) Warning: Conversion between ordinals and pointers is not portableOddly, the MakeProcInstance and FreeProcInstance API functions show that the parameters are defined as longints according to the hover-help messages.  They both return longint results as well. Thanks! ---------------------------------------------------------------------- marcov · 2019-10-02 15:11 Things like FAR are 16-bits remnants. They should probably have been cleared out after Windows 95 emerged :-) It seems makeprocinstance and freeprocinstance are macros that in FPC are converted to Pascal functions, and are essentially no ops (empty functions that return whatever is passed to them. Probably related to thunking allocation in Win3.1, which is now largely considered obsolete too. (as is its successor Win9x) So probably just leave out all the procinstance stuff, and simply just run the ddeinitialize line only. For reference,  here is the complete source code for those functions: 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 MakeProcInstance(p,i : longint) : longint;    begin       MakeProcInstance:=p;    end;  function FreeProcInstance(p : longint) : longint;    begin       FreeProcInstance:=p;    end; ---------------------------------------------------------------------- PaulRowntree · 2019-10-02 15:20 That is great information marcov, thank you very much!  It is scary that I was dragging around Win3.1 code, although it is just as scary to know that I remember those days (and was so excited to be 'living in the future'). Thanks again!