Question regarding --> DllCall("DeleteObject", "Ptr", hBM) ; Clean-up
Please let me ask:
If i use the --> DllCall("DeleteObject", "Ptr", hBM) ; Clean-up --> add the very end of a function AFTER return , for example:
Example 1:
Code: Select all
GDI_CaptureScreen( X, Y, W, H, ByRef Checksum="" ) {
tDC := DllCall( "CreateCompatibleDC", UInt,0 )
hBM := DllCall( "CopyImage", UInt,DllCall( "CreateBitmap", Int,W, Int,H, UInt,1, UInt,24
, UInt,0 ), UInt,0, Int,0, Int,0, UInt,0x2008, UInt )
oBM := DllCall( "SelectObject", UInt,tDC, UInt,hBM ), hDC := DllCall( "GetDC", UInt,0 )
DllCall( "BitBlt"
, UInt,tDC, UInt,0, UInt,0, Int,W, Int,H, UInt,hDC, UInt,X, UInt,Y, UInt,0x00CC0020 )
DllCall( "ReleaseDC", UInt,0, UInt,hDC ), DllCall( "SelectObject", UInt,tDC, UInt,oBM )
If ( Checksum <> "" )
VarSetCapacity( BM,24,0 ), DllCall( "GetObject", UInt,hBM, UInt,24, UInt,&BM )
, DllCall( "shlwapi\HashData", UInt,NumGet(BM,20), UInt,NumGet( BM,12 )*NumGet( BM,8 )
, Int64P,Checksum, UInt,7 )
Return hBM, DllCall( "DeleteDC", UInt,tDC )
DllCall("DeleteObject", "Ptr", hBM) ; Clean-up
}
Code: Select all
GDI_SaveBitmap( hBM, File ) {
DllCall( "GetObject", Int,hBM, Int,VarSetCapacity($,84), UInt,NumPut(0,$,40,"Short")-42 )
Numput( VarSetCapacity(BFH,14,0)+40, Numput((NumGet($,44)+54),Numput(0x4D42,BFH)-2)+4 )
If ( hF := DllCall( "CreateFile", Str,File,UInt,2**30,UInt,2,Int,0,UInt,2,Int64,0 ) ) > 0
DllCall( "WriteFile", UInt,hF, UInt,&BFH, UInt,14, IntP,0,Int,0 ) ; BITMAPFILEHEADER
, DllCall( "WriteFile", UInt,hF, UInt,&$+24, UInt,40, IntP,0,Int,0 ) ; BITMAPINFOHEADER
, DllCall( "WriteFile", UInt,hF, UInt,NumGet($,20), UInt,NumGet($,44), UIntP,BW, Int,0 )
, DllCall( "CloseHandle", UInt,hF )
Return BW ? 54+BW : 0
DllCall("DeleteObject", "Ptr", hBM) ; Clean-up
}
If i use the --> DllCall("DeleteObject", "Ptr", hBM) ; Clean-up --> add the very end of a function AFTER return (as in the above 2 examples), is it OK programmatically, please?