home *** CD-ROM | disk | FTP | other *** search
/ Guide To Cracking 2002 / Guide_to_Cracking_2002.iso / Programming / yPP-B-SRC.ZIP / d32lib.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-08-31  |  1.9 KB  |  73 lines

  1. unit d32lib;
  2.  
  3. interface
  4.  
  5. uses windows;
  6.  
  7. const yodastamp : dword   = $61646f79;
  8.  
  9. function mb(MessageBoxtext:string;MessageBoxcaption:string;Messageboxattributes:integer=0) : integer;
  10. // calculate the screen middle
  11. function getmiddleX(winwidth:integer) :integer;
  12. function getmiddleY(winheight:integer):integer;
  13. // get the filesize
  14. function getfsize(PathtoFile : string) : DWORD;
  15. // anti exception
  16. function ishexnum(targetnumber : string) : boolean;
  17.  
  18. implementation
  19.  
  20. function mb(MessageBoxtext:string;MessageBoxcaption:string;Messageboxattributes:integer=0) : integer;
  21. begin
  22. result:=Messagebox(0,pchar(MessageBoxtext),pchar(MessageBoxcaption),Messageboxattributes);
  23. end;
  24.  
  25. function getmiddleX(winwidth:integer):integer;
  26. var topx    : integer;
  27.     middlex : real;
  28. begin
  29. topx:=getsystemmetrics(SM_CXSCREEN);
  30. middlex:=(topx-255)/2;
  31. topx:=round(middlex);
  32. result:=topx;
  33. end;
  34.  
  35. function getmiddleY(winheight:integer):integer;
  36. var topy    : integer;
  37.     middley : real;
  38. begin
  39. topy:=getsystemmetrics(sm_cyscreen);
  40. middley:=(topy-winheight)/2;
  41. topy:=round(middley);
  42. result:=topy;
  43. end;
  44.  
  45. function getfsize(PathtoFile : string) : DWORD;
  46. var fileh : THandle;
  47. begin
  48. result:=$FFFFFFFF;
  49. fileh:=createfile(pchar(pathtofile),GENERIC_read,FILE_SHARE_READ,nil,OPEN_EXISTING,0,0);
  50. result:=getfilesize(fileh,nil);
  51. closehandle(fileh);
  52. end;
  53.  
  54. function ishexnum(targetnumber : string) : boolean;
  55. var i          :   longint;
  56.     tmpstring  :   string;
  57. begin
  58. result:=false;
  59. if targetnumber='' then exit;
  60. tmpstring:=targetnumber; // upcase the string without uppercase
  61. targetnumber:='';
  62. for i:=1 to length(tmpstring) do
  63.   targetnumber:=targetnumber+upcase(tmpstring[i]);
  64. // start the test
  65. for i:=1 to length(targetnumber) do
  66.   if ((targetnumber[i] < '0') or (targetnumber[i] > '9')) and ((targetnumber[i] < 'A') or (targetnumber[i] > 'F' ))
  67.     then exit;
  68. result:=true;
  69. end;
  70.  
  71. end.
  72.  
  73.