Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question.386 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE INCLUDE windows.inc INCLUDE kernel32.inc INCLUDE user32.inc INCLUDE gdi32.inc INCLUDELIB kernel32.lib INCLUDELIB user32.lib INCLUDELIB gdi32.lib GetLocalTime PROTO :DWORD GetDateFormatA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD GetDateFormat equ GetDateFormatA GetTimeFormatA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD GetTimeFormat equ GetTimeFormatA GetStdHandle PROTO :DWORD WriteFile PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD ExitProcess PROTO :DWORD CapScreen proto :DWORD SYSTEMTIME STRUCT wYear WORD ? wMonth WORD ? wDayOfWeek WORD ? wDay WORD ? wHour WORD ? wMinute WORD ? wSecond WORD ? wMilliseconds WORD ? SYSTEMTIME ENDS MAX_FILENAME_LEN EQU 64 .DATA? stCurTime SYSTEMTIME <> szFileName db MAX_FILENAME_LEN dup (?) .DATA szmybmp db ".bmp",NULL szDFormat db "ddd dd MMM yyyy",0 szTFormat db "hh'H'mm'min'ss''tt",0 szDateTitle db "Date", 0 szTimeTitle db "Time", 0 szDisplay db "DISPLAY",0 .CODE WinEntry: invoke GetLocalTime, addr stCurTime invoke GetDateFormat, LOCALE_USER_DEFAULT, NULL, addr stCurTime, addr szDFormat, addr szFileName, MAX_FILENAME_LEN sub esp,256 mov eax,esp invoke GetTimeFormat, LOCALE_USER_DEFAULT, NULL, addr stCurTime, addr szTFormat, eax, 256 invoke lstrcat ,addr szFileName ,esp invoke lstrcat ,addr szFileName ,addr szmybmp add esp,256 invoke CapScreen, addr szFileName invoke ExitProcess, eax CapScreen Proc lpFileName:DWORD LOCAL hdc:HDC LOCAL memdc:HDC LOCAL hFile:HANDLE LOCAL dwBytes:DWORD LOCAL bitmapfileheader:BITMAPFILEHEADER LOCAL bitmapinfoheader:BITMAPINFOHEADER LOCAL colors[256]:RGBQUAD LOCAL bmpinfo:BITMAPINFO LOCAL hBitmap:HBITMAP LOCAL pBits:DWORD LOCAL dwWidth:DWORD LOCAL dwHeight:DWORD LOCAL dwNumColors:DWORD LOCAL dwBPP:DWORD LOCAL ColorSize:DWORD invoke CreateDC, addr szDisplay, NULL, NULL, NULL mov hdc,eax .IF (eax==NULL) jmp ExitFunc .ENDIF invoke GetDeviceCaps, hdc, HORZRES mov dwWidth,eax invoke GetDeviceCaps, hdc, VERTRES mov dwHeight,eax invoke GetDeviceCaps, hdc, BITSPIXEL mov dwBPP,eax .IF (eax<=8) invoke GetDeviceCaps, hdc, NUMCOLORS mov dwNumColors,eax mov dwNumColors,256 ;this one looks bad .ELSE mov dwNumColors,0 .ENDIF invoke CreateCompatibleDC, hdc mov memdc,eax .IF (eax==NULL) invoke DeleteDC, hdc jmp ExitFunc .ENDIF mov bmpinfo.bmiHeader.biSize,sizeof BITMAPINFOHEADER mov eax,dwWidth mov bmpinfo.bmiHeader.biWidth,eax mov eax,dwHeight mov bmpinfo.bmiHeader.biHeight,eax mov bmpinfo.bmiHeader.biPlanes,1 mov ax,word ptr [dwBPP] mov bmpinfo.bmiHeader.biBitCount,ax mov bmpinfo.bmiHeader.biCompression,BI_RGB mov bmpinfo.bmiHeader.biSizeImage,0 mov bmpinfo.bmiHeader.biXPelsPerMeter,0 mov bmpinfo.bmiHeader.biYPelsPerMeter,0 mov eax,dwNumColors mov bmpinfo.bmiHeader.biClrUsed,eax mov bmpinfo.bmiHeader.biClrImportant,eax invoke CreateDIBSection,hdc,addr bmpinfo, DIB_PAL_COLORS,addr pBits, NULL, 0 mov hBitmap,eax .IF (eax==NULL) invoke DeleteDC, hdc invoke DeleteDC, memdc jmp ExitFunc .ENDIF invoke SelectObject, memdc, hBitmap .IF (eax==NULL) || (eax==GDI_ERROR) invoke DeleteDC, hdc invoke DeleteDC, memdc jmp ExitFunc .ENDIF invoke BitBlt, memdc, 0,0, dwWidth, dwHeight, hdc, 0,0, SRCCOPY .IF (!eax) invoke DeleteDC, hdc invoke DeleteDC, memdc jmp ExitFunc .ENDIF mov eax,dwNumColors .IF (eax!=0) invoke GetDIBColorTable, memdc, 0, dwNumColors, addr colors mov dwNumColors,eax .ENDIF mov bitmapfileheader.bfType,4D42h mov eax,dwNumColors xor edx,edx mov ecx,sizeof RGBQUAD mul ecx mov ColorSize,eax mov eax,dwWidth xor edx,edx mov ecx,dwHeight mul ecx xor edx,edx mov ecx,dwBPP mul ecx shr eax,3 add eax,ColorSize add eax,sizeof BITMAPFILEHEADER add eax,sizeof BITMAPINFOHEADER mov bitmapfileheader.bfSize,eax mov bitmapfileheader.bfReserved1,0 mov bitmapfileheader.bfReserved2,0 mov eax,ColorSize add eax,sizeof BITMAPFILEHEADER add eax,sizeof BITMAPINFOHEADER mov bitmapfileheader.bfOffBits,eax mov bitmapinfoheader.biSize,sizeof BITMAPINFOHEADER mov eax,dwWidth mov bitmapinfoheader.biWidth,eax mov eax,dwHeight mov bitmapinfoheader.biHeight,eax mov bitmapinfoheader.biPlanes,1 mov ax,word ptr [dwBPP] mov bitmapinfoheader.biBitCount,ax mov bitmapinfoheader.biCompression,BI_RGB mov bitmapinfoheader.biSizeImage,0 mov bitmapinfoheader.biXPelsPerMeter,0 mov bitmapinfoheader.biYPelsPerMeter,0 mov eax,dwNumColors mov bitmapinfoheader.biClrUsed,eax mov bitmapinfoheader.biClrImportant,0 invoke CreateFile, lpFileName,GENERIC_WRITE,0,\ NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL mov hFile,eax .IF (eax==INVALID_HANDLE_VALUE) invoke DeleteObject, hBitmap invoke DeleteDC, memdc invoke DeleteDC, hdc jmp ExitFunc .ENDIF invoke WriteFile, hFile, addr bitmapfileheader, sizeof BITMAPFILEHEADER,\ addr dwBytes, NULL invoke WriteFile, hFile, addr bitmapinfoheader, sizeof BITMAPINFOHEADER,\ addr dwBytes, NULL mov eax,dwNumColors .IF (eax!=0) invoke WriteFile, hFile, addr colors, ColorSize, addr dwBytes,NULL .ENDIF mov eax,dwWidth xor edx,edx mov ecx,dwHeight mul ecx xor edx,edx mov ecx,dwBPP mul ecx shr eax,3 mov ColorSize,eax invoke WriteFile, hFile, pBits, ColorSize, addr dwBytes,NULL invoke CloseHandle, hFile invoke DeleteObject ,hBitmap invoke DeleteDC, memdc invoke DeleteDC, hdc ExitFunc: ret CapScreen endp END WinEntry