Program CardTrickMagic2; /////////////////////////////////////////////////////////////////////////// // #sign:8 PM max: MAXBOX8: 6/11/2014 6:40:20 PM PM // Purpose: shows the diff seeing and believing with functions and procedure // #path>C:\maXbook\maxbox3\mX3999\maxbox3\examples\ // Lines of Code #locs:697 // ref http://www.delphiforfun.org/Programs/oscilloscope.htm /////////////////////////////////////////////////////////////////////////// //TODO: find out the performance of func or proc, #locs:697 Function OpenProcess2(dwDesiredAccess: DWORD; bInheritHandle:BOOL; dwProcessId:DWORD): THandle; External 'OpenProcess@kernel32.dll stdcall'; procedure TForm1_setup1; forward; Const SW = 'SW_SHOW'; BITMAP = 'examples\citymax.bmp'; var year1, month1, day1: word; dbform: TForm; //myappevent: TApplicationEvents; procedure ProcedureSolution; var mystrings: TStrings; begin mystrings:= TStringlist.Create; getVisibleWindows(mystrings) showMessage(mystrings.text) mystrings.Free; end; function FunctionSolution: TStrings; begin result:= getVisibleWindowsF(TStringlist.Create) end; procedure TKeyPairGenerator_Create; var TmpDir, fPassword: string; TmpFile: TSearchRec; fKeyLength: word; fPrivateKeyFile, fPublicKeyFile: TFileName; fSeedFile: TFileName; begin fKeyLength:= 1024; fPassword:= ''; TmpDir:= GetEnvironmentVariable('TEMP'); if FindFirst(TmpDir + '\*', faReadOnly and faHidden and faSysFile and faArchive) = 0 then // fSeedFile := TmpFile.Name; fSeedFile:= searchrecName; writeln('fseedfile is: '+fseedfile) FindClose; end; function CheckFiletype2(const extension, filetype, description, verb, serverapp: string): boolean; var reg: TRegistry; keystring, regdfile: string; begin reg := TRegistry.Create; try Result := False; reg.Rootkey := HKEY_CLASSES_ROOT; if not reg.OpenKey(extension, False) then Exit; reg.CloseKey; if not reg.OpenKey(filetype, False) then Exit; reg.closekey; keystring := Format('%s\shell\%s\command', [filetype, verb]); if not reg.OpenKey(keystring, False) then Exit; regdfile := reg.ReadString(''); reg.CloseKey; if CompareText(regdfile, serverapp) <> 0 then Exit; Result := True; finally reg.free; end; end; //const KEY_READ = $20019; {**** Or / Oder ****} procedure TForm1_TranspImage2(Sender: TObject); var OldBkMode: integer; mainwnd: THandle; mainwnd2: HWND; ak: PKOLChar; image1: TImage; //TC: TCopyDataStruct; begin with Image1.Picture.Bitmap do begin Canvas.Font.Color := clBlue; OldBkMode := SetBkMode(Canvas.Handle, Ord(TRANSPARENT)); Canvas.Font.Size := 13; Canvas.TextOut(10, 10, 'Transparent Text!!'); SetBkMode(Canvas.Handle, OldBkMode); end; //debug ak:= '0rt'; ak:= 'maxform1'; mainwnd2:= wFindWindow(ak, ak); mainwnd:= FindWindow('TMaxForm1',''); //mainwnd2:= FindWindow(NIL, 'maxform1'); wSendMessage(mainwnd2, WM_COPYDATA, mainwnd, 42); //wSetWindowText(mainwnd2, 'WM_COPYDATA'); //ak:= 'thest'+#0; booleantoString(wSetWindowText(mainwnd, 'NIL')); wSetWindowText(mainwnd, ak); end; //unit U_PiCalc1; Var inpond, totshots:integer; {Number in pond} Const radius2 = 0.25; {for radius squared} Procedure showPIstats; var r: single; begin writeln('Pond Hits: '+inttostr(inpond)); writeln(' Total shots: '+inttostr(totshots)); if totshots>0 then r:= inpond/totshots else r:=0; writeln('Ratio of Pond hits to shots '+floattostr(r)); writeln('PI estimate: '+ floattostr(4*r)); end; //Pythagorean theorem for distance,x2+y2=d2, so point is in pond if x2+y2<.25. Procedure TFrm_PIShootBtnClick(Sender: TObject); var i: integer; x,y: double; begin //if strtoint(shotsEdt.text)