We go back to the WndProc method. Here the WMsgGPUResult case has been triggered by the incoming GPU message result. That tells us that GPU has placed a string in the Memory Mapped File and that it is waiting for us to retrieve it. All we do is simply open up a view to the file with MapViewOfFile which returns a pointer to the start of the string. We split the string in two parts with ExtractParamString(...) in utils.pas. JobID and ResultStr contain the result of one computation. The only thing left to do is to close our view of the file with UnmapViewOfFile [6].
procedure TForm1.WndProc(Var TheMsg: TMessage); var thePtr : PChar; IncomingString, JobId,ResultStr : String; begin {handling a user defined windows message that is a result} if TheMsg.Msg = WMsgGPUResult then begin ThePtr:=MapViewOfFile(GPUCommSpace,FILE_MAP_WRITE,0,0,0); IncomingString := ThePtr; UnmapViewOfFile(ThePtr); JobID := ExtractParam(IncomingString,':'); ResultStr := IncomingString; end; Inherited WndProc(TheMsg); end;