Sunteți pe pagina 1din 22

td_win32asm_221.

asm
;==============================================================================
;
Test Department's WINDOWS 32 BIT x86 ASSEMBLY EXAMPLE's
221
;==============================================================================
;==============================================================================
; ==> Part 221 : Multimedia Player
;-----------------------------------------------------------------------------; Welcome,
; first of all you must imagine that we do not decode datas here, that is not
; our job, our job is to program a multimedia player.
; All this slave decoding job is done by windows or any other better OS.
; The WinXP codec's must be installed to view videos.
;
; This program may not work proper under WinXP.
;
; Supported : CDAUDIO, aif, au, avi, mid, mov, mpg, rmi, wav and more...
;==============================================================================
; Assembler directives
;-----------------------------------------------------------------------------.386
; specifies the processor our program want run on
.Model Flat ,StdCall
; Flat for Win9x (32 Bit), Calling Convention
option casemap:none
; case sensitive !!!
;==============================================================================
; Include all files where API functins resist you want use, set correct path
;-----------------------------------------------------------------------------include D:\Masm32\include\windows.inc
includelib kernel32.lib
includelib user32.lib
includelib comctl32.lib
includelib winmm.lib
includelib vfw32.lib
;==============================================================================
; Declaration of used API functions,take a look into WIN32.HLP and *.inc files
;-----------------------------------------------------------------------------GetModuleHandleA
PROTO :DWORD
InitCommonControls
PROTO
LoadLibraryA
PROTO :DWORD
GetProcAddress
PROTO :DWORD,:DWORD
LoadIconA
PROTO :DWORD,:DWORD
LoadCursorA
PROTO :DWORD,:DWORD
RegisterClassExA
PROTO :DWORD
CreateWindowExA
PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,
:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ShowWindow
PROTO :DWORD,:DWORD
UpdateWindow
PROTO :DWORD
GetMessageA
PROTO :DWORD,:DWORD,:DWORD,:DWORD
TranslateMessage
PROTO :DWORD
DispatchMessageA
PROTO :DWORD
PostQuitMessage
PROTO :DWORD
DefWindowProcA
PROTO :DWORD,:DWORD,:DWORD,:DWORD
Page 1

FreeLibrary
ExitProcess
MessageBoxA
DestroyWindow
CreateToolbarEx

PROTO
PROTO
PROTO
PROTO
PROTO

MoveWindow
GetWindowTextA
SetWindowTextA
SetTimer
KillTimer
SendMessageA
lstrcpyA
lstrcmpiA
GetOpenFileNamePreviewA
AVIFileInit
AVIFileOpenA
AVIFileInfoA
AVIFileRelease
AVIFileExit
mciSendCommandA

PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO

td_win32asm_221.asm
:DWORD
:DWORD
:DWORD,:DWORD,:DWORD,:DWORD
:DWORD
:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,
:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
:DWORD,:DWORD,:DWORD
:DWORD,:DWORD
:DWORD,:DWORD,:DWORD,:DWORD
:DWORD,:DWORD
:DWORD,:DWORD,:DWORD,:DWORD
:DWORD,:DWORD
:DWORD,:DWORD
:DWORD
:DWORD,:DWORD,:DWORD,:DWORD
:DWORD,:DWORD,:DWORD
:DWORD
:DWORD,:DWORD,:DWORD,:DWORD

;==============================================================================
; .const
= the constants area starts here, constants are defined and fixed
;-----------------------------------------------------------------------------.const
; - Parameter MAIN WINDOW CallBack Procedure ( API=RegisterClassExA ) WP1_CallBack
equ [ebp+4]
;return address
WP1_hWnd
equ [ebp+8]
;handle of window who receives message
WP1_uMsg
equ [ebp+12]
;the message number
WP1_wParam
equ [ebp+16]
;extra info about the message
WP1_lParam
equ [ebp+20]
;extra info about the message
;==============================================================================
; .Data = the data area starts here, datas are defined but not fixed
;-----------------------------------------------------------------------------.Data
IconName
db "TDIcon",0
;icon name in rc file
MenuName
db "TDMenu",0
;menu name in rc file
ClassName
db "TDWinClass",0
;name of windows class
WindowName
db "Test Department's Multimedia Player",0;window name
MB2_Text
db "Supported Formats : CDAUDIO, aif, au, avi, mid, mov, mpg, rmi, wav and more.",0;
MB1_DllError
db "can not load DLL: msvfw32.dll",0;message box text
MB1_FunctionError
db "can not find Function: MCIWndCreate",0;
MB1_AVIFileError
db "AVI file corrupted or Format not supported",0;
Library_Name
db "msvfw32.dll",0
;filename of the library
f_MCIWndCreate
db "MCIWndCreate",0
;function name inside library
toolbar00_str_C0
db "Play Media File",0
;toolbar button text
toolbar00_str_C1
db "Play Audio CD",0
;toolbar button text
toolbar00_str_C10
db "Supported Formats",0;
toolbar button text
LoadFileFilte
db "Media Files (*.*)",0,"*.*",0,0;
LoadFileTitle
db "Select a File",0
;
AVIextender
db "avi",0
;AVI file extender
Page 2

CDAextender
CDAdevice
MOVdevice

td_win32asm_221.asm
;CDA file extender
;name of device
;name of device

db "cda",0
db "cdaudio",0
db "MPEGVideo",0

align 4
; - TBBUTTON structure ( API=CreateToolbarEx ) - ARRAY !!!
iBitmap_00
dd 0h
;zero-based index of button image
idCommand_00
dd 0h
;ID or, if fsStyle=TBSTYLE_SEP, zero
fsState_00
db 4h
;state flags,4h=TBSTATE_ENABLED
fsStyle_00
db 1h
;button style,1h=TBSTYLE_SEP
bReserved_00
db 2h dup (0)
;reserved byte,error in WIN32.HLP ?
dwData_00
dd 0h
;application-defined value
iString_00
dd 0h
;zero-based index of button string
iBitmap_01
idCommand_01
fsState_01
fsStyle_01
bReserved_01
dwData_01
iString_01

dd
dd
db
db
db
dd
dd

1h
0C0h
4h
0h
2h dup (0)
0h
0h

;zero-based index of button image


;ID of button, WM_COMMAND uMsg/wParam
;state flags,4h=TBSTATE_ENABLED
;button style,0h=TBSTYLE_BUTTON
;reserved byte,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string

iBitmap_02
idCommand_02
fsState_02
fsStyle_02
bReserved_02
dwData_02
iString_02

dd
dd
db
db
db
dd
dd

2h
0C1h
4h
0h
2h dup (0)
0h
0h

;zero-based index of button image


;ID of button, WM_COMMAND uMsg/wParam
;state flags,4h=TBSTATE_ENABLED
;button style,0h=TBSTYLE_BUTTON
;reserved byte,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string

iBitmap_03
idCommand_03
fsState_03
fsStyle_03
bReserved_03
dwData_03
iString_03

dd
dd
db
db
db
dd
dd

3h
0h
4h
1h
2h dup (0)
0h
0h

;zero-based index of button image


;ID or, if fsStyle=TBSTYLE_SEP, zero
;state flags,4h=TBSTATE_ENABLED
;button style,1h=TBSTYLE_SEP
;reserved byte,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string

iBitmap_04
idCommand_04
fsState_04
fsStyle_04
bReserved_04
dwData_04
iString_04

dd
dd
db
db
db
dd
dd

4h
0C10h
4h
0h
2h dup (0)
0h
0h

;zero-based index of button image


;ID of button, WM_COMMAND uMsg/wParam
;state flags,4h=TBSTATE_ENABLED
;button style,0h=TBSTYLE_BUTTON
;reserved byte,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string

iBitmap_05
idCommand_05
fsState_05
fsStyle_05
bReserved_05
dwData_05
iString_05

dd
dd
db
db
db
dd
dd

5h
0h
4h
1h
2h dup (0)
0h
0h

;zero-based index of button image


;ID or, if fsStyle=TBSTYLE_SEP, zero
;state flags,4h=TBSTATE_ENABLED
;button style,1h=TBSTYLE_SEP
;reserved byte,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string
Page 3

td_win32asm_221.asm
;==============================================================================
; .Data?
= the data? area starts here, not defined and not fixed
;-----------------------------------------------------------------------------.data?
toolbar00_hWnd
dd ?
;handle of the toolbar
hLibrary
dd ?
;loaded library handle
p_MCIWndCreate
dd ?
;pointer function inside DLL
mcihWnd
dd ?
;handle of mci window
mci_filehandle
dd ?
;filehandle media file
fip
dd ?
;AVI file interface pointer
ErrorFlag
dd ?
temp_00
dd ?
TrackNumber
dd ?
LoadFileBuffer
db 104h dup(?) ;buffer for load filename
TestFileName
db 104h dup(?) ;buffer, filename
MediaFileName
db 104h dup(?) ;buffer, filename
align 4
; - WndClassEx Structure ( API=RegisterClassExA ) cbSize
dd ?
;size in bytes of this structure
style
dd ?
;window style
lpfnWndProc
dd ?
;address of user proc function
cbclsExtra
dd ?
;extra bytes to allocate set to 0
cbWndExtra
dd ?
;extra bytes class directive, rc file
hInstance
dd ?
;program handle(API=GetModuleHandleA)
hIcon
dd ?
;handle of icon (API=LoadIconA)
hcursor
dd ?
;handle of cursor (API=LoadCursor)
hbrBackground
dd ?
;background color, 0=transparent
lpszMenuName
dd ?
;name of menu class in resource file
lpszClassName
dd ?
;name of windows this window class
hIconSm
dd ?
;iconhandle 0=search in resource file
align 4
; - Msg Structure ( API=GetMessageA ) - member POINT = POINT structure
hWnd
dd ?
;handle of window who receives message
message
dd ?
;the message number
wParam
dd ?
;extra info about the message
lParam
dd ?
;extra info about the message
time
dd ?
;time the message was posted
xpt
dd ?
;cursor x-position, POINT struc
ypt
dd ?
;cursor x-position, POINT struc
align 4
; - OPENFILENAME Structure
lStructSize
dd
hWndOwner
dd
hInstance1
dd
lpstrFilter
dd
lpstrCustomFilter
dd
nMaxCustFilter
dd
nFilterIndex
dd
lpstrFile
dd

( API=GetOpenFileNamePreviewA ) ?
;the length in bytes of structure
?
;handle of the window that owns dialog box
?
;handle, our program handle
?
;pointer to string + filter
?
;pointer to user defined filter
?
;size bytes/characters of above
?
;filter index of lpstrFilter
?
;pointer initialize filename, 0=no
Page 4

nMaxFile
lpstrFileTitle
nMaxFileTitle
lpstrInitialDir
lpstrTitle
Flags
nFileOffset
nFileExtension
lpstrDefExt
lCustData
lpfnHook
lpTemplateName

dd
dd
dd
dd
dd
dd
dw
dw
dd
dd
dd
dd

?
?
?
?
?
?
?
?
?
?
?
?

td_win32asm_221.asm
;size bytes/characters of above
;pointer title of the selected file
;size of the lpstrFileTitle buffer
;pointer init file dir,0=default
;pointer title of the box
;the dialog box creation flags
;offset filename in string lpstrFile
;offset extension in string lpstrFile
;pointer to default extension of file
;?
;used if flag is OFN_ENABLETEMPLATE
;used if flag is OFN_ENABLETEMPLATE

align 4
; - AVIFILEINFO Structure ( API=AVIFileInfoA ) dwMaxBytesPerSec
dd ?
;maximum data rate of the AVI file
dwFlags
dd ?
;applicable flags
dwCaps
dd ?
;capability flags
dwStreams
dd ?
;number of streams in the file
dwSuggestedBufferSize
dd ?
;buffer size in bytes for reading file
dwWidth
dd ?
;width in pixels of the AVI file
dwHeight
dd ?
;height in pixels of the AVI file
dwScale
dd ?
;time scale applicable for entire file
dwRate
dd ?
;dwRate / dwScale = samples per second
dwLength
dd ?
;length of the AVI file
dwEditCount
dd ?
;# streams added/deleted from AVI file
szFileType
db 40h dup(?)
;string containing file type infos
align 4
; - MCI_GENERIC_PARMS Structure ( API=mciSendCommand ) generic_dwCallback
dd ?
align 4
; - MCI_OPEN_PARMS Structure ( API=mciSendCommand ) open_dwCallback
dd ?
open_wDeviceID
dd ?
open_lpstrDeviceType
dd ?
open_lpstrElementName
dd ?
open_lpstrAlias
dd ?
open_dwStyle
dd ?
open_hWndParent
dd ?
align 4
; - MCI_SET_PARMS Structure ( API=mciSendCommand ) set_dwCallback
dd ?
set_dwTimeFormat
dd ?
set_dwAudio
dd ?
align 4
; - MCI_STATUS_PARMS Structure ( API=mciSendCommand ) status_dwCallback
dd ?
status_dwReturn
dd ?
status_dwItem
dd ?
Page 5

td_win32asm_221.asm
status_dwTrack

dd ?

align 4
; - MCI_DGV_RECT_PARMS Structure ( API=mciSendCommand ) dgv_generic_dwCallback dd ?
dgv_left
dd ?
dgv_top
dd ?
dgv_right
dd ?
dgv_bottom
dd ?
;==============================================================================
; .CODE = our code area starts here
Main = label of our program code
;-----------------------------------------------------------------------------.Code
Main:
;==============================================================================
; Always get your program ID first (API=GetModuleHandleA)
;-----------------------------------------------------------------------------push
0h
;lpModuleHandle, 0=get program handle
call
GetModuleHandleA
;- API Function mov
hInstance,eax
;return value in eax=handle of program
;==============================================================================
; API "CreateToolbarEx" is part of common controls, force init ...
;-----------------------------------------------------------------------------call
InitCommonControls
;- API Function ;==============================================================================
; API LoadLibraryA maps the specified exe or dll module into the address space
; of the calling process.
;-----------------------------------------------------------------------------push
OFFSET Library_Name
;lpLibFileName, pointer filename module
call
LoadLibraryA
;- API Function cmp
eax,0h
;check if return value 0h=ERROR !
jne
Library_OK
;if no ERROR goto LABEL
mov
ebx,OFFSET MB1_DllError
;lpText,pointer to text message box
call
My_MessageBoxA
;- SUBROUTINE jmp
ExitPrg
Library_OK:
mov
hLibrary,eax
;store handle of library in variable
;==============================================================================
; API "GetProcAddress" gets the address of the specified function !
;-----------------------------------------------------------------------------push
OFFSET f_MCIWndCreate
;pProcName, name of function
push
hLibrary
;hModule, handle to DLL module
call
GetProcAddress
;- API Function cmp
eax,0h
;check if return value 0h=ERROR !
jne
Function_OK
;if no ERROR goto LABEL
mov
ebx,OFFSET MB1_FunctionError
;lpText,pointer to text message box
call
My_MessageBoxA
;- SUBROUTINE jmp
FreeLib
Page 6

td_win32asm_221.asm
Function_OK:
mov
p_MCIWndCreate,eax
;store given pointer to the function
;==============================================================================
; The API function "RegisterClassExA" registers a window class.
; This API needs a "WNDCLASSEX" structure so we fill it with correct values.
;-----------------------------------------------------------------------------mov
cbSize,30h
;size in bytes of WNDCLASSEX structure
mov
style,3h
;window style
mov
lpfnWndProc,OFFSET WP1
;address of user lpfnWndProc function
mov
cbclsExtra,0h
;extra bytes to allocate set to 0
mov
cbWndExtra,0h
;class directive in rc file
mov
hbrBackground,10h
;background,1=background(parameter+1)
mov
lpszMenuName,0h;OFFSET MenuName ;menu name in resource file,0=no menu
mov
lpszClassName,OFFSET ClassName ;name of windows class
mov
hIconSm,0h
;iconhandle 0=search in rc file
;-----------------------------------------------------------------------------; API "LoadIconA" loads an icon defined in the resource file and stores the
; handle in the "WNDCLASSEX" structure
;-----------------------------------------------------------------------------push
OFFSET IconName
;icon-string or icon resource id
push
hInstance
;our program handle
call
LoadIconA
;- API Function mov
hIcon,eax
;handle of newly loaded icon
;-----------------------------------------------------------------------------; API "LoadCursorA" loads a default system cursor, in this case we must set
; hInstance to 0 and lpCursorName to a default system cursor value, here 32512
; Then we store the cursor handle in the "WNDCLASSEX" structure
;-----------------------------------------------------------------------------push
32512
;lpCursorName,default value in dezimal
push
0h
;hInstance, 0=default system cursor
call
LoadCursorA
;- API Function mov
hcursor,eax
;handle of the cursor
;-----------------------------------------------------------------------------; Now, after filled the "WNDCLASSEX" structure we call API "RegisterClassEx"
;-----------------------------------------------------------------------------push
OFFSET cbSize
;pointer to WNDCLASSEX structure
call
RegisterClassExA
;- API Function ;==============================================================================
; API "CreateWindowExA" creates an overlapped, pop-up, or child window with an
; extended style. The return value in EAX is the handle of the new window.
; This API sends a WM_CREATE message to the window procedure (WP1).
;-----------------------------------------------------------------------------push
0h
;lpParam, extra pointer data 0=no data
push
hInstance
;hInstance, handle of our program
push
0h
;hMenu, handle window menu 0=class menu
push
0h
;hWndParent, handle parent window 0=no
push
0000006Ah
;intnHeight, window height pixel
push
0000013Eh
;intnWidth, window width pixel
push
00000008h
;inty, vertical position window
push
00000030h
;intx, horizontal position window
push
04CA0000h
;dwStyle, look into WIN32.HLP
Page 7

push
push
push
call
mov

OFFSET WindowName
OFFSET ClassName
0300h
CreateWindowExA
hWnd,eax

td_win32asm_221.asm
;lpWindowName, pointer to window name
;lpClassName, pointer to class name
;dwExStyle, extra window style 0=no
;- API Function ;hwnd,return value=handle of window

;==============================================================================
; API "ShowWindow" function sets the specified window's show state.
;-----------------------------------------------------------------------------push
1h
;nCmdShow, show state 1=SW_SHOWNORMAL
push
hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function ;==============================================================================
; API "UpdateWindow" updates the area of the specified window by sending a
; WM_PAINT message to the window if the window's update region is not empty.
;-----------------------------------------------------------------------------push
hWnd
;hwnd, handle of window
call
UpdateWindow
;- API Function ;==============================================================================
; API "GetMessageA" retrieves a message + places it in the specified structure.
;-----------------------------------------------------------------------------LoopGetMessage:
push
0h
;wMsgFilterMax, highest message value
push
0h
;wMsgFilterMin, lowest message value
push
0h
;hWnd, handle of window who gets msg.
push
OFFSET hWnd
;lpMsg, pointer to MSG structure
call
GetMessageA
;- API Function cmp
eax,0h
;check if return value=0 (exit)
je
FreeLib
;if return value is 0 goto LABEL
;==============================================================================
; API "TranslateMessage" translates key code into ASCII character messages
;-----------------------------------------------------------------------------push
OFFSET hWnd
;lpMSG, pointer to msg structure
call
TranslateMessage
;- API Function - keyboard code
;==============================================================================
; API "DispatchMessageA" function dispatches a message to a window procedure.
;-----------------------------------------------------------------------------push
OFFSET hWnd
;lpMSG, pointer to msg structure
call
DispatchMessageA
;- API Function jmp
LoopGetMessage
;check for message again, goto LABEL
;-----------------------------------------------------------------------------; API FreeLibrary unmaps the modul from address space of the calling process
;-----------------------------------------------------------------------------FreeLib:
push
hLibrary
;hLibModule, handle loaded lib. module
call
FreeLibrary
;- API Function ;==============================================================================
Page 8

td_win32asm_221.asm
; Next we terminate our program (API=ExitProcess)
;-----------------------------------------------------------------------------ExitPrg:
push
hInstance
;push our programm handle to exit
call
ExitProcess
;- API Function ;##############################################################################
; The Window Procedure (API=RegisterClassExA) for this registered window.
;-----------------------------------------------------------------------------WP1:
push
ebp
;create stack frame
mov
ebp,esp
;
pushad
;push all register to the stack
mov
eax,WP1_uMsg
;move the message number to eax
;==============================================================================
; WM_CREATE (value=01h) message received ?
;-----------------------------------------------------------------------------WP1_uMsg_01h:
cmp
eax,1h
;check if WM_CREATE message recieved
jne
WP1_uMsg_02h
;if not goto LABEL
call
My_MCIWndCreate
;- SUBROUTINE call
My_MoveWindow_MCI
;- SUBROUTINE ;-----------------------------------------------------------------------------; API "CreateToolbarExA" creates a child window ( TOOLBAR ).
; Set "uStructSize" to 14h, not 12h because bReserved bytes, bug in WIN32.HLP ?
; Take a look to TBBUTTON structure in the .DATA area above.
; Parameter "ws" defines the child windows style; it also enables tooltiptext.
; In "wID" we PUSH the ID of the child window ( a value of your your choice ).
; Take a look into WIN32.HLP ( CreateToolbarEx ) and Windows.inc.
; The return value in EAX is the handle of the created toolbar.
;-----------------------------------------------------------------------------push
14h
;uStructSize,size TBBUTTON structure
push
14h
;dyBitmap,height pixels of the images
push
14h
;dxBitmap,width pixels of the images
push
14h
;dyButton,height pixels of the buttons
push
14h
;dxButton,width pixels of the buttons
push
06h
;iNumButtons,Number buttons in toolbar
push
OFFSET iBitmap_00
;lpButtons,pointer TBBUTTON structure
push
80h
;wBMID,ID for the bitmap resource
push
hInstance
;hBMInst,instance bitmap resource
push
1h
;nBitmaps,number of button image file
push
500h
;wID,control identifier for toolbar
push
50400900h
;ws,windows styles in WIN32.HLP
push
WP1_hWnd
;hwnd,handle owner window 0=no owner
call
CreateToolbarEx
;- API Function mov
toolbar00_hWnd,eax
;handle of toolbar child window
;==============================================================================
; API "ShowWindow" function sets the specified window's show state.
;-----------------------------------------------------------------------------push
5h
;nCmdShow, show state 5h=SW_SHOW
push
toolbar00_hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function Page 9

td_win32asm_221.asm
jmp

WP1_return

;==============================================================================
; WM_DESTROY (value=02h) message received ?
;-----------------------------------------------------------------------------WP1_uMsg_02h:
cmp
eax,2h
;check if value=2h (WM_DESTROY)
jne
WP1_uMsg_05h
;if not 2h go to LABEL
call
My_CleanSystem
;- SubRoutine ;-----------------------------------------------------------------------------; API "PostQuitMessage" indicates to Windows a request to terminate
;-----------------------------------------------------------------------------push
0h
;nExitCode, exit code=wParam
call
PostQuitMessage
;- API Function popad
;pop all register back from stack
xor
eax,eax
;set eax to 0 to exit our program
mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
10h
;return and clear stack
;==============================================================================
; WM_Size (value=05h) message, used to resize the window area
;-----------------------------------------------------------------------------WP1_uMsg_05h:
cmp
eax,05h
;check if WM_SIZE message recieved
jne
WP1_uMsg_4Eh
;if not goto label
;-----------------------------------------------------------------------------; API "SendMessageA" sends a message, TB_AUTOSIZE to fit toolbar and bitmaps
;-----------------------------------------------------------------------------push
0h
;lParam, second message parameter
push
0h
;wParam, first message parameter (ID)
push
421h
;uMsg, send TB_AUTOSIZE message
push
toolbar00_hWnd
;hwnd, handle of destination window
call
SendMessageA
;- API Function jmp
WP1_return
;==============================================================================
; WM_NOTIFY (value=4Eh) message, here used to show the toolbar tip !
; With a WM_NOTIFY message Windows gives you pointer to a NMHDR structure.
;-----------------------------------------------------------------------------WP1_uMsg_4Eh:
cmp
eax,4Eh
;check if WM_NOTIFY message recieved
jne
WP1_uMsg_111h
;if not goto label
;-----------------------------------------------------------------------------; The NMHDR structure contains information about a notification message.
; The TOOLTIPTEXT structure identifies a tool for which text is to be displayed
; and receives the text for the tool.
; We must fill it with the CORRECT values ...
; The POINTER to this structure is specified as lParam member of WM_NOTIFY.
; This POINTER is given to us with the WM_NOTIFY message by Windows.
;-----------------------------------------------------------------------------; - NMHDR structure ; hwndFrom = [WP1_lParam+0]
;handle to control sending message
Page 10

td_win32asm_221.asm
; idFrom
= [WP1_lParam+4]
;identifier of control sending message
; code
= [WP1_lParam+8]
;notification code
; - TOOLTIPTEXT structure ; hdr
= placeholder for NMHDR ;required for all WM_NOTIFY messages
; lpszText = [WP1_lParam+12]
;Pointer string or resource ID
; szText[80]= [WP1_lParam+16]
;buffer for text, alternate to lpszText
; hinst
= [WP1_lParam+20]
;handle instance, 0 if lpszText=pointer
; uFlags
= [WP1_lParam+24]
;Flag indicates how to interpret idFrom
;-----------------------------------------------------------------------------mov
ebx,WP1_lParam
;pointer to struc, given by windows !
mov
eax,[ebx+8]
;move code ( NMHDR structure ) into EAX
cmp
eax,0FFFFFDF8h
;check if code TTN_NEEDTEXT received
jne
WP1_return
;if not goto label
mov
eax,[ebx+4]
;move idFrom ( NMHDR structure ) to EAX
cmp
eax,0C0h
;is it toolbar button ID=0C0h
jne
next_01
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_C0;move our text pointer to lpszText
next_01:
cmp
eax,0C1h
;is it toolbar button ID=0C1h
jne
next_02
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_C1;move our text pointer to lpszText
next_02:
cmp
eax,0C10h
;is it toolbar button ID=0C10h
jne
next_03
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_C10;move our text pointer to lpszText
next_03:
jmp
WP1_return
;==============================================================================
; WM_COMMAND (value=111h) message recieved ?
;-----------------------------------------------------------------------------WP1_uMsg_111h:
cmp
eax,111h
;check if WM_COMMAND message recieved
jne
WP1_uMsg_112h
;if not goto label
mov
eax,WP1_wParam
;extra info about the message in ax
cmp
ax,0C0h
;check if toolbar button ID=C0h clicked
jne
WP1_lParam_0_0C1h
;if not 0C0h goto LABEL
;-----------------------------------------------------------------------------; API "GetOpenFileNamePreviewA" selects a file by using the Open dialog box.
; The dialog box also allows the user to preview the currently specified file.
; Look for parameter names into WIN32.HLP + parameter values into windows.inc.
;-----------------------------------------------------------------------------mov
lStructSize,4Ch
;length in bytes of structure
mov
eax,WP1_hWnd
mov
hWndOwner,eax
;id window that owns dialog box
mov
eax,hInstance
mov
hInstance1,eax
;handle, our program id
mov
lpstrFilter,OFFSET LoadFileFilte;pointer to string + filter, 0= no
mov
lpstrCustomFilter,0h
;pointer to user defined filter
mov
nMaxCustFilter,0h
;size bytes/characters of above
mov
nFilterIndex,0h
;filter index of lpstrFilter
mov
lpstrFile,OFFSET LoadFileBuffer ;pointer to filename buffer
mov
nMaxFile,104h
;max size bytes/characters of above
Page 11

td_win32asm_221.asm
mov
lpstrFileTitle,0h
;pointer title of the selected file
mov
nMaxFileTitle,0h
;size of the lpstrFileTitle buffer
mov
lpstrInitialDir,0h
;pointer init file dir,0=default
mov
lpstrTitle,OFFSET LoadFileTitle;pointer title of the box
mov
Flags,00281804h
;the dialog box creation flags
mov
nFileOffset,0h
;offset filename in string lpstrFile
mov
nFileExtension,0h
;offset extension in string lpstrFile
mov
lCustData,0h
;?
mov
lpfnHook,0h
;? used if flag is OFN_ENABLETEMPLATE
mov
lpTemplateName,0h
;? used if flag is OFN_ENABLETEMPLATE
mov
lpstrDefExt,0h
;pointer default extension file, 0=no
push
OFFSET lStructSize
;lpofn, pointer OPENFILENAME structure
call
GetOpenFileNamePreviewA
;- API Function cmp
eax,0h
;check if an error occurs
je
WP1_return
;exit on error
mov
mci_filehandle,eax
;handle of new file
;-----------------------------------------------------------------------------; API "lstrcpyA" copy's a string from source to destination.
;-----------------------------------------------------------------------------mov
ax,nFileOffset
;given from OPENFILENAME structure
cwde
;convert word in AX into doubleword EAX
mov
ebx,lpstrFile
;given from OPENFILENAME structure
add
ebx,eax
;calculate OFFSET filename
push
ebx
;lpString2, pointer source string
push
OFFSET TestFileName
;lpString1, pointer destination string
call
lstrcpyA
;- API Function ;-----------------------------------------------------------------------------; API "lstrcmpiA" compares two strings, check for Audio CD.
;-----------------------------------------------------------------------------mov
ax,nFileExtension
;given from OPENFILENAME structure
cwde
;convert word in AX into doubleword EAX
mov
ebx,lpstrFile
;given from OPENFILENAME structure
add
ebx,eax
;calculate OFFSET filename extender
mov
temp_00,ebx
;store pointer for future use
push
ebx
;lpString2, pointer second string
push
OFFSET CDAextender
;lpString1, pointer first string
call
lstrcmpiA
;- API Function cmp
eax,0h
;check if strings are equal
jne
_CHECK_AVI
;if equal go to LABEL
;-----------------------------------------------------------------------------; calculate choosen Audio CD Track
;-----------------------------------------------------------------------------mov
eax,0h
mov
TrackNumber,0h
mov
ebx,temp_00
dec
ebx
dec
ebx
mov
al,[ebx]
cmp
al,2Fh
jbe
_AUDIO_CD_TRACK1
cmp
al,3Ah
jae
_AUDIO_CD_TRACK1
sub
al,30h
Page 12

td_win32asm_221.asm
add
mov
dec
mov
cmp
jbe
cmp
jae
sub
mov
mul
cwde
add
jmp

TrackNumber,eax
eax,0h
ebx
al,[ebx]
al,2Fh
_AUDIO_CD_TRACK1
al,3Ah
_AUDIO_CD_TRACK1
al,30h
bl,0Ah
bl
TrackNumber,eax
_AUDIO_CD

_CHECK_AVI:
;-----------------------------------------------------------------------------; API "lstrcmpiA" compares two strings, check if file is an AVI file.
;-----------------------------------------------------------------------------mov
ax,nFileExtension
;given from OPENFILENAME structure
cwde
;convert word in AX into doubleword EAX
mov
ebx,lpstrFile
;given from OPENFILENAME structure
add
ebx,eax
;calculate OFFSET filename extender
push
ebx
;lpString2, pointer second string
push
OFFSET AVIextender
;lpString1, pointer first string
call
lstrcmpiA
;- API Function cmp
eax,0h
;check if strings are equal
je
_AVI
;if equal go to LABEL
_MPG:
call
My_MCI_Stop
;- SUBROUTINE call
My_KillTimer
;- SUBROUTINE call
My_SendMessageA
;- SUBROUTINE call
My_StringRoutine
;- SUBROUTINE ;-----------------------------------------------------------------------------; API "mciSendCommandA" here opens the device with a specified filename
;-----------------------------------------------------------------------------mov
eax,OFFSET MOVdevice
;fill MCI_OPEN_PARMS structure
mov
open_lpstrDeviceType,eax
;device type = MPEGVideo
mov
eax,OFFSET MediaFileName
;
mov
open_lpstrElementName,eax
;name of file to open
push
OFFSET open_dwCallback
;dwParam, address MCI_OPEN_PARMS struc.
push
2300h
;fdwCommand,
;MCI_OPEN_TYPE
= 2000h
;MCI_OPEN_ELEMENT
= 200h
;MCI_OPEN_SHAREABLE = 100h
push
0803h
;uMsg, command message, MCI_OPEN
push
0h
;IDDevice, not used with MCI_OPEN
call
mciSendCommandA
;- API Function cmp
eax,0h
jne
_AUDIO_FILE
;-----------------------------------------------------------------------------; API "mciSendCommandA" obtains the clipping rectangle for the video device
Page 13

td_win32asm_221.asm
;-----------------------------------------------------------------------------push
OFFSET dgv_generic_dwCallback
;dwParam, MCI_DGV_RECT_PARMS structure
push
40000h
;fdwCommand,
;MCI_DGV_WHERE_DESTINATION = 40000h
push
0843h
;uMsg, command message, MCI_WHERE
push
open_wDeviceID
;IDDevice, given from MCI_OPEN
call
mciSendCommandA
;- API Function mov
ErrorFlag,eax
;store return value in variable
;-----------------------------------------------------------------------------; API "mciSendCommandA" here releases access to a device or file.
;-----------------------------------------------------------------------------push
OFFSET generic_dwCallback
;dwParam, MCI_GENERIC_PARMS structure
push
0h
;fdwCommand, 0h=no command
push
0804h
;uMsg, command message, MCI_CLOSE
push
open_wDeviceID
;IDDevice, given from MCI_OPEN
call
mciSendCommandA
;- API Function cmp
ErrorFlag,0h
;check ErrorFlag 0h = no error
jne
_AUDIO_FILE
;
call
My_MCIWndCreate
;- SUBROUTINE ;-----------------------------------------------------------------------------; API "MoveWindow" changes the position and dimensions of the MCI window.
;-----------------------------------------------------------------------------push
01h
;bRepaint, repaint flag
add
dgv_bottom,20h
;calculate height of the mci window
push
dgv_bottom
;nHeight, height
add
dgv_right,6h
;calculate width of the mci window
push
dgv_right
;nWidth, width
push
24h
;Y, vertical position
push
4h
;X, horizontal position
push
mcihWnd
;hWnd, handle of window
call
MoveWindow
;- API Function ;-----------------------------------------------------------------------------; API "MoveWindow" changes the position and dimensions of the MAIN window.
;-----------------------------------------------------------------------------push
01h
;bRepaint, repaint flag
add
dgv_bottom,4Ah
;calculate height of the main window
push
dgv_bottom
;nHeight, height
add
dgv_right,12h
;calculate width of the main window
push
dgv_right
;nWidth, width
push
08h
;Y, vertical position
push
30h
;X, horizontal position
push
WP1_hWnd
;hWnd, handle of window
call
MoveWindow
;- API Function ;-----------------------------------------------------------------------------; API "UpdateWindow" updates the area of the specified window by sending a
; WM_PAINT message to the window if the window's update region is not empty.
;-----------------------------------------------------------------------------push
WP1_hWnd
;hwnd, handle of window
call
UpdateWindow
;- API Function call
My_MCI_Play
;- SUBROUTINE call
My_SetTimer
;- SUBROUTINE jmp
WP1_return
Page 14

td_win32asm_221.asm
_AUDIO_FILE:
call
My_MCI_Stop
;- SUBROUTINE call
My_KillTimer
;- SUBROUTINE call
My_SendMessageA
;- SUBROUTINE call
My_StringRoutine
;- SUBROUTINE call
My_MCIWndCreate
;- SUBROUTINE call
My_MoveWindow_MCI
;- SUBROUTINE call
My_MoveWindow_MAIN
;- SUBROUTINE ;-----------------------------------------------------------------------------; API "UpdateWindow" updates the area of the specified window by sending a
; WM_PAINT message to the window if the window's update region is not empty.
;-----------------------------------------------------------------------------push
WP1_hWnd
;hwnd, handle of window
call
UpdateWindow
;- API Function call
My_MCI_Play
;- SUBROUTINE call
My_SetTimer
;- SUBROUTINE jmp
WP1_return
_AVI:
;-----------------------------------------------------------------------------; API "AVIFileInit" initializes the AVIFile library.
;-----------------------------------------------------------------------------call
AVIFileInit
;- API Function ;-----------------------------------------------------------------------------; API "AVIFileOpenA" opens an AVI file and returns the address of a
; file interface used to access it.
;-----------------------------------------------------------------------------push
0h
;pclsidHandler, address class ID, 0=sys
push
0h
;mode, access mode to use, OF_READ = 0h
push
OFFSET TestFileName
;szFile, string - the name of the file
push
OFFSET fip
;ppfile, address file interface pointer
call
AVIFileOpenA
;- API Function cmp
eax,0h
;check if an ERROR occured
je
_AVI_OK
;no error, go to LABEL
;==============================================================================
; API "MessageBoxA" creates a message box, ERROR, AVI file format not supported
;-----------------------------------------------------------------------------push
0h
;uType, style, 0=MB_OK Button
push
OFFSET WindowName
;lpCaption,pointer to title text
push
OFFSET MB1_AVIFileError
;lpText,pointer to text message box
push
WP1_hWnd
;handle of owner window 0=no owner
call
MessageBoxA
;- API Function ;-----------------------------------------------------------------------------; API "AVIFileExit" exits the AVIFile library and decrements the
; reference count for the library.
;-----------------------------------------------------------------------------call
AVIFileExit
;- API Function jmp
WP1_return
;on error nothing to do, exit
_AVI_OK:
;-----------------------------------------------------------------------------; API "AVIFileInfoA" obtains infos about an AVI file in the AVIFILEINFO struct.
;-----------------------------------------------------------------------------Page 15

td_win32asm_221.asm
push
6Ch
;lSize, size in bytes of the structure
push
OFFSET dwMaxBytesPerSec
;pfi, address of AVIFILEINFO structure
push
fip
;pfile, handle of an open AVI file
call
AVIFileInfoA
;- API Function ;-----------------------------------------------------------------------------; API "AVIFileRelease" decrements the reference count of an AVI file interface
; handle and closes the file if the count reaches zero.
;-----------------------------------------------------------------------------push
fip
;pfile, handle of an open AVI file
call
AVIFileRelease
;- API Function ;-----------------------------------------------------------------------------; API "AVIFileExit" exits the AVIFile library and decrements the
; reference count for the library.
;-----------------------------------------------------------------------------call
AVIFileExit
;- API Function cmp
dwHeight,1h
;check if AVI file have a video stream
jbe
_AUDIO_FILE
;if not goto LABEL
call
My_MCI_Stop
;- SUBROUTINE call
My_KillTimer
;- SUBROUTINE call
My_SendMessageA
;- SUBROUTINE call
My_StringRoutine
;- SUBROUTINE call
My_MCIWndCreate
;- SUBROUTINE ;-----------------------------------------------------------------------------; API "MoveWindow" changes the position and dimensions of the MCI window.
;-----------------------------------------------------------------------------push
01h
;bRepaint, repaint flag
add
dwHeight,20h
;calculate height of the mci window
push
dwHeight
;nHeight, height
add
dwWidth,6h
;calculate width of the mci window
push
dwWidth
;nWidth, width
push
24h
;Y, vertical position
push
4h
;X, horizontal position
push
mcihWnd
;hWnd, handle of window
call
MoveWindow
;- API Function ;-----------------------------------------------------------------------------; API "MoveWindow" changes the position and dimensions of the MAIN window.
;-----------------------------------------------------------------------------push
01h
;bRepaint, repaint flag
add
dwHeight,4Ah
;calculate height of the main window
push
dwHeight
;nHeight, height
add
dwWidth,12h
;calculate width of the main window
push
dwWidth
;nWidth, width
push
08h
;Y, vertical position
push
30h
;X, horizontal position
push
WP1_hWnd
;hWnd, handle of window
call
MoveWindow
;- API Function ;-----------------------------------------------------------------------------; API "UpdateWindow" updates the area of the specified window by sending a
; WM_PAINT message to the window if the window's update region is not empty.
;-----------------------------------------------------------------------------push
WP1_hWnd
;hwnd, handle of window
call
UpdateWindow
;- API Function call
My_MCI_Play
;- SUBROUTINE Page 16

td_win32asm_221.asm
call
jmp

My_SetTimer
WP1_return

;- SUBROUTINE -

WP1_lParam_0_0C1h:
cmp
ax,0C1h
;check if button ID=0C1h clicked
jne
WP1_lParam_0_C10h
;if not 0C1h goto LABEL
_AUDIO_CD_TRACK1:
mov
TrackNumber,1h
;
;-----------------------------------------------------------------------------; API "mciSendCommandA" here opens the device.
;-----------------------------------------------------------------------------mov
open_lpstrDeviceType,516
;fill MCI_OPEN_PARMS structure
;MCI_DEVTYPE_CD_AUDIO = 516
push
OFFSET open_dwCallback
;dwParam, address MCI_OPEN_PARMS struc.
push
3100h
;fdwCommand,
;MCI_OPEN_TYPE
= 2000h
;MCI_OPEN_TYPE_ID
= 1000h
;MCI_OPEN_SHAREABLE = 100h
push
0803h
;uMsg, command message, MCI_OPEN
push
0h
;IDDevice, not used with MCI_OPEN
call
mciSendCommandA
;- API Function ;-----------------------------------------------------------------------------; API "mciSendCommandA" here retrieves information if a media is present.
;-----------------------------------------------------------------------------mov
status_dwItem,05h
;structure, MCI_STATUS_MEDIA_PRESENT
push
OFFSET status_dwCallback
;dwParam, MCI_STATUS_PARMS structure
push
0100h
;fdwCommand, MCI_STATUS_ITEM = 0100h
push
0814h
;uMsg, command message, MCI_STATUS
push
open_wDeviceID
;IDDevice, given from MCI_OPEN
call
mciSendCommandA
;- API Function ;-----------------------------------------------------------------------------; API "mciSendCommandA" here closes the device.
;-----------------------------------------------------------------------------push
OFFSET generic_dwCallback
;dwParam, MCI_GENERIC_PARMS structure
push
0h
;fdwCommand, 0h=no command
push
0804h
;uMsg, command message, MCI_CLOSE
push
open_wDeviceID
;IDDevice, given from MCI_OPEN
call
mciSendCommandA
;- API Function cmp
je
jmp

status_dwReturn,1h
_AUDIO_CD
WP1_return

;value from MCI_STATUS_PARMS structure


;media is present so play it

_AUDIO_CD:
call
My_MCI_Stop
;- SUBROUTINE call
My_KillTimer
;- SUBROUTINE call
My_SendMessageA
;- SUBROUTINE ;-----------------------------------------------------------------------------; API "MCIWndCreate" registers the MCIWnd window class and creates an MCIWnd
; child window for using MCI services.
; It can also open an MCI device or file and associate it with the MCI window.
;-----------------------------------------------------------------------------push
OFFSET CDAdevice
;szFile, name MCI device or data file
Page 17

td_win32asm_221.asm
push
54400078h
;dwStyle, defines the window style
push
hInstance
;hInstance, handle of module instance
push
WP1_hWnd
;hwndParent, handle parent window 0=no
call
[p_MCIWndCreate]
;- API Function mov
mcihWnd,eax
;handle of MCI window
pop
eax
;clear stack !
pop
eax
pop
eax
pop
eax
call
My_MoveWindow_MCI
;- SUBROUTINE call
My_MoveWindow_MAIN
;- SUBROUTINE ;-----------------------------------------------------------------------------; API "UpdateWindow" updates the area of the specified window by sending a
; WM_PAINT message to the window if the window's update region is not empty.
;-----------------------------------------------------------------------------push
WP1_hWnd
;hwnd, handle of window
call
UpdateWindow
;- API Function ;-----------------------------------------------------------------------------; API "mciSendCommandA" here sets the time format and audio format ( TMSF )
;-----------------------------------------------------------------------------mov
set_dwTimeFormat,0Ah
;fill MCI_SET_PARMS structure
;MCI_FORMAT_TMSF = 0Ah
mov
set_dwAudio,6401h
;fill MCI_SET_PARMS structure
;MCI_SET_AUDIO_ALL = 4001h
;MCI_SET_ON
= 2000h
;MCI_SET_TIME_FORMAT= 400h
push
OFFSET set_dwCallback
;dwParam, address MCI_SET_PARMS struc.
push
6401h
;fdwCommand, same as above
push
080Dh
;uMsg, command message, MCI_SET
push
-1
;IDDevice, MCI_ALL_DEVICE_ID = -1
call
mciSendCommandA
;- API Function ;-----------------------------------------------------------------------------; API "SendMessageA" sends a MCI_SEEK message, seek to track number
;-----------------------------------------------------------------------------push
TrackNumber
;lParam, seek to track
push
0h
;wParam, not used
push
807h
;uMsg, send MCI_SEEK message
push
mcihWnd
;hwnd, handle of destination window
call
SendMessageA
;- API Function call
My_MCI_Play
;- SUBROUTINE call
My_SetTimer
;- SUBROUTINE jmp
WP1_return
WP1_lParam_0_C10h:
cmp
ax,0C10h
;check if toolbarbutton ID=C10h clicked
jne
WP1_return
;if not 0C10h goto LABEL
;==============================================================================
; API "MessageBoxA" creates a message box, displaying the supported formats
;-----------------------------------------------------------------------------push
0h
;uType, style, 0=MB_OK Button
push
OFFSET WindowName
;lpCaption,pointer to title text
push
OFFSET MB2_Text
;lpText,pointer to text message box
push
WP1_hWnd
;handle of owner window 0=no owner
Page 18

call
jmp

MessageBoxA
WP1_return

td_win32asm_221.asm
;- API Function ;

;==============================================================================
; WM_SYSCOMMAND (value=112h) message recieved ?
;-----------------------------------------------------------------------------WP1_uMsg_112h:
cmp
eax,112h
;check if WM_COMMAND message recieved
jne
WP1_wParam_113h
;if not goto label
mov
eax,WP1_wParam
;extra info about the message
cmp
eax,0F060h
;SC_CLOSE=0F060h received ?
jne
WP1_return
;
call
My_CleanSystem
;- SubRoutine jmp
WP1_return
;==============================================================================
; WM_TIMER (value=113h) message received ?
;-----------------------------------------------------------------------------WP1_wParam_113h:
cmp
eax,113h
;check if WM_TIMER message recieved
jne
WP1_return
;if not goto label
;-----------------------------------------------------------------------------; API "GetWindowTextA" copies the text of the specified window's title bar.
;-----------------------------------------------------------------------------push
30h
;nMaxCount, max number of chars to copy
push
OFFSET TestFileName
;lpString, address of buffer for text
push
mcihWnd
;hWnd, handle of window or control
call
GetWindowTextA
;- API Function ;-----------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.
;-----------------------------------------------------------------------------push
OFFSET TestFileName
;lpsz, address of string
push
WP1_hWnd
;hwnd, handle of window or control
call
SetWindowTextA
;- API Function jmp
WP1_return
;==============================================================================
; API "DefWindowProcA" calls the window procedure to provide default processing
; for any window messages that an application does not process.
; This function ensures that every message is processed.
; It is called with the same parameters received by the window procedure.
;-----------------------------------------------------------------------------WP1_return:
popad
;pop all register from stack
push
WP1_lParam
;extra info about the message
push
WP1_wParam
;extra info about the message
push
WP1_uMsg
;the message number
push
WP1_hWnd
;handle of window who receives message
call
DefWindowProcA
;- API Function mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
10h
;return and clear stack
;##############################################################################
Page 19

td_win32asm_221.asm
;******************************************************************************
; My own subroutine(s) for a compacter code resist here ...
;-----------------------------------------------------------------------------My_CleanSystem:
call
My_MCI_Stop
;- SUBROUTINE ret
My_MCIWndCreate:
;-----------------------------------------------------------------------------; API "MCIWndCreate" registers the MCIWnd window class and creates an MCIWnd
; child window for using MCI services.
; It can also open an MCI device or file and associate it with the MCI window.
; For API MCIWndCreate we push 4 doublewords to the stack, we remove them
; after calling !!!
;-----------------------------------------------------------------------------push
OFFSET MediaFileName
;szFile, name MCI device or data file
push
54400078h
;dwStyle, defines the window style
push
hInstance
;hInstance, handle of module instance
push
WP1_hWnd
;hwndParent, handle parent window 0=no
call
[p_MCIWndCreate]
;- API Function mov
mcihWnd,eax
;handle of MCI window
pop
eax
;clear stack !
pop
eax
pop
eax
pop
eax
ret
My_MCI_Play:
;-----------------------------------------------------------------------------; API "SendMessageA" sends a MCI_PLAY message to autoplay file
;-----------------------------------------------------------------------------push
0h
;lParam, not used
push
0h
;wParam, not used
push
806h
;uMsg, send MCI_PLAY message
push
mcihWnd
;hwnd, handle of destination window
call
SendMessageA
;- API Function ret
My_MCI_Stop:
;-----------------------------------------------------------------------------; API "mciSendCommandA" here stops playing cdaudio (!)
; If we do not call this function CDAUDIO plays always if you close this prg.
;-----------------------------------------------------------------------------push
OFFSET generic_dwCallback
;dwParam, MCI_GENERIC_PARMS structure
push
0h
;fdwCommand, 0h=no command
push
0808h
;uMsg, command message, MCI_STOP
push
-1
;IDDevice, -1 = close all devices
call
mciSendCommandA
;- API Function ret
My_MessageBoxA:
push
0h

;uType, style, 0=MB_OK Button


Page 20

push
push
push
call
ret

OFFSET WindowName
ebx
hWnd
MessageBoxA

td_win32asm_221.asm
;lpCaption,pointer to title text
;lpText,pointer to text message box
;handle of owner window 0=no owner
;- API Function -

My_MoveWindow_MCI:
;-----------------------------------------------------------------------------; API "MoveWindow" changes the position and dimensions of the specified window.
;-----------------------------------------------------------------------------push
01h
;bRepaint, repaint flag
push
20h
;nHeight, height
push
12Ch
;nWidth, width
push
24h
;Y, vertical position
push
4h
;X, horizontal position
push
mcihWnd
;hWnd, handle of window
call
MoveWindow
;- API Function ret
My_MoveWindow_MAIN:
;-----------------------------------------------------------------------------; API "MoveWindow" changes the position and dimensions of the specified window.
;-----------------------------------------------------------------------------push
01h
;bRepaint, repaint flag
push
6Ah
;nHeight, height
push
13Eh
;nWidth, width
push
08h
;Y, vertical position
push
30h
;X, horizontal position
push
WP1_hWnd
;hWnd, handle of window
call
MoveWindow
;- API Function ret
My_SendMessageA:
;-----------------------------------------------------------------------------; API "SendMessageA" sends a WM_CLOSE message directly to the open MCI window
;-----------------------------------------------------------------------------push
0h
;lParam, second message parameter
push
0h
;wParam, first message parameter
push
10h
;uMsg, message to send ( WM_CLOSE )
push
mcihWnd
;hwnd, handle of destination window
call
SendMessageA
;- API Function ret
My_StringRoutine:
;-----------------------------------------------------------------------------; API "lstrcpyA" copy's a string from source to destination.
;-----------------------------------------------------------------------------mov
ax,nFileOffset
;given from OPENFILENAME structure
cwde
;convert word in AX into doubleword EAX
mov
ebx,lpstrFile
;given from OPENFILENAME structure
add
ebx,eax
;calculate OFFSET filename
push
ebx
;lpString2, pointer source string
push
OFFSET MediaFileName
;lpString1, pointer destination string
Page 21

call
ret

lstrcpyA

td_win32asm_221.asm
;- API Function -

My_SetTimer:
;-----------------------------------------------------------------------------; API "SetTimer" creates a timer with the specified time-out value.
;-----------------------------------------------------------------------------push
0h
;tmprc, address timer procedure,0=this
push
1000
;uTimeout, time-out value milliseconds
push
10h
;idTimer, timer identifier, nonzero
push
WP1_hWnd
;hwnd, handle of window for timer msg.
call
SetTimer
;- API Function ret
My_KillTimer:
;-----------------------------------------------------------------------------; API "KillTimer" destroys the specified timer.
;-----------------------------------------------------------------------------push
10h
;uIDEvent, timer identifier
push
WP1_hWnd
;hWnd, handle of window installed timer
call
KillTimer
;- API Function ;-----------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.
;-----------------------------------------------------------------------------push
OFFSET WindowName
;lpsz, address of string
push
WP1_hWnd
;hwnd, handle of window or control
call
SetWindowTextA
;- API Function ret
;******************************************************************************
;==============================================================================
; end Main = end of our program code
;-----------------------------------------------------------------------------end Main
;end of our program code, entry point
;==============================================================================
; To create the exe file use this commands with your Microsoft Assembler/Linker
;-----------------------------------------------------------------------------; ml.exe /c /coff td_win32asm_221.asm
;asm command
; rc.exe /v rsrc.rc
;rc command
; cvtres.exe /machine:ix86 rsrc.res
; link.exe /subsystem:windows td_win32asm_221.obj rsrc.obj
;link command
;==============================================================================

Page 22

S-ar putea să vă placă și