flat assembler
Message board for the users of flat assembler.
Index
> Windows > Play video with winmm (get window handle) |
Author |
|
revolution 11 Feb 2021, 06:32
You need to convert the the handle (a dword binary number) into an ASCII decimal string.
In Windows you can use wsprintf to construct the string. |
|||
11 Feb 2021, 06:32 |
|
fasm14 22 Feb 2021, 06:50
Thanks a lot! In case someone has problems with understanding wsprintf (like I did ), here's a small example of a video player:
Code: format PE GUI 4.0 include 'win32a.inc' section '.text' code readable executable start: invoke GetModuleHandle,0 mov [wc.hInstance],eax invoke LoadIcon, 0, IDI_APPLICATION mov [wc.hIcon], eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke CreateSolidBrush, 0x000000 mov [wc.hbrBackground], eax invoke RegisterClass,wc test eax,eax jz error invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,640,480,NULL,NULL,[wc.hInstance],NULL mov [hwnd],eax test eax,eax jz error invoke wsprintf,str_buffer,str_format,[hwnd] invoke mciSendString, str_buffer, 0 invoke mciSendString, str_put, 0 invoke mciSendString, str_play, 0 msg_loop: invoke GetMessage,msg,NULL,0,0 cmp eax,1 jb end_loop jne msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop error: invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc uses ebx esi edi ecx, hwnd,wmsg,wparam,lparam cmp [wmsg], WM_DESTROY je .wmdestroy .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .finish .wmdestroy: invoke PostQuitMessage,0 xor eax,eax jmp .finish .finish: ret endp section '.data' data readable writeable str_format db "open intro.wmv alias video parent %d style child",0 str_buffer db 256 dup (0) str_play db "play video notify",0 str_put db 'put video window at 0 0 0 0',0 hwnd dd ? _class TCHAR 'FASMWIN32',0 _title TCHAR 'Video',0 _error TCHAR 'Error',0 msg MSG wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BACKGROUND,NULL,_class import winmm,\ mciSendString, 'mciSendStringA' section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ gdi32,'GDI32.DLL',\ advapi32,'ADVAPI32.DLL',\ comctl32,'COMCTL32.DLL',\ winmm,'WINMM.DLL',\ comdlg32,'COMDLG32.DLL',\ shell32,'SHELL32.DLL',\ wsock32,'WSOCK32.DLL' include 'api/kernel32.inc' include 'api/user32.inc' include 'api/gdi32.inc' include 'api/advapi32.inc' include 'api/comctl32.inc' include 'api/comdlg32.inc' include 'api/shell32.inc' include 'api/wsock32.inc' |
|||
22 Feb 2021, 06:50 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.