#include "ltwrappr.h"

virtual L_INT LScreenCapture::CaptureFromEXE(pszFileName, nResType, pResID, bCaptureByIndex, clrBackGnd=RGB(0,0,0))

Captures an image from the specified resource, stored in an EXE or DLL, into the associated class object's bitmap.


L_TCHAR * pszFileName

Character string containing the name of the exe (or dll) from which the resource should be captured.

L_INT nResType

Specifies the type of resource to capture. Possible values are:

Value Meaning
RESTYPE_BITMAP capture a bitmap resource
RESTYPE_ICON capture an icon resource
RESTYPE_CURSOR capture a cursor resource


Specifies the index of the resource to capture. You can use MAKEINDEX or MAKERESOURCEID macros to convert the resource ids to strings.

L_BOOL bCaptureByIndex

Flag that indicates whether pResID represents an index or a resource ID. Possible values are:

Value Meaning
TRUE pResID is the index position of the requested resource.
FALSE pResID is the resource ID of the requested resource.


Background color for icons.


Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Required DLLs and Libraries


Win32, x64.

See Also




L_INT LScreenCapture__CaptureFromEXEExample(HWND hWnd) 
   L_INT nRet; 
   HDC hDC; 
   RECT rcDestRect; 
   LBitmap LeadBitmap; 
   LScreenCapture screenCapture(&LeadBitmap); 
   // CaptureFromExe  
   //MFCDEM32 is shipped with LEADTOOLS, you have to copy it to the directory of the sample 
   // it has an ICON with ID=128 
   nRet = screenCapture.CaptureFromEXE(TEXT("MFCDEM32.EXE"), RESTYPE_ICON, MAKEINTRESOURCE(128), 0); 
   //   COLORREF Transparent; 
   if(nRet == SUCCESS) 
      hDC = GetDC(hWnd); 
      // Set destination rectangle to be the same as the bitmap dimensions 
      SetRect(&rcDestRect, 0, 0, LeadBitmap.GetWidth(), LeadBitmap.GetHeight()); 
      nRet = LeadBitmap.SetDstRect(&rcDestRect); 
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = LeadBitmap.Paint()->PaintDC(); 
      if(nRet != SUCCESS) 
         return nRet; 
      ReleaseDC(hWnd, hDC); 
      return nRet; 
   return SUCCESS; 
Help Version 22.0.2022.4.4
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help