
Extremely Active Member
     
Group: Moderators
Posts: 287
Member No.: 5004
Joined: 11-May 07

|
I am getting this message, "Cannot determine device type from the given filename extension."
Can someone help me find the problem ?
| CODE | .386 .Model Flat ,StdCall option casemap:none
include \Masm32\include\windows.inc include \Masm32\include\kernel32.inc include \Masm32\include\user32.inc include \Masm32\include\winmm.inc includelib \Masm32\lib\kernel32.lib includelib \Masm32\lib\user32.lib includelib \Masm32\lib\winmm.lib
GetModuleHandleA PROTO :DWORD
FindResourceA PROTO :DWORD,:DWORD,:DWORD SizeofResource PROTO :DWORD,:DWORD LoadResource PROTO :DWORD,:DWORD LockResource PROTO :DWORD CreateFileA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD WriteFile PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD CloseHandle PROTO :DWORD
mciSendCommandA PROTO :DWORD,:DWORD,:DWORD,:DWORD
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD ExitProcess PROTO :DWORD
.Data
SoundName db "TDSound",0 ;sound name in resource MB1Titel db "Program Error",0 MB1Text db "MCI Error",0 MB2Titel db "Play_Mp3",0 MB2Text db "Playing an Mp3.",0 FileName db "temp.mp3",0 ;temporary filename Box db " ",0 szFehler DB 100 Dup(?), 0
.data?
hInstance dd ? handleResource dd ? sizeResource dd ? pointerResource dd ?
handleFile dd ? returnFile dd ?
; - MCI_OPEN_PARMS Structure ( API=mciSendCommand ) - open_dwCallback dd ? open_wDeviceID dd ? open_lpstrDeviceType dd ? open_lpstrElementName dd ? open_lpstrAlias dd ?
; - MCI_GENERIC_PARMS Structure generic_dwCallback dd ?
; - MCI_PLAY_PARMS Structure play_dwCallback dd ? play_dwFrom dd ? play_dwTo dd ?
.Code Main:
; Always get your program ID first (API=GetModuleHandleA)
push 0h ;lpModuleHandle, 0=get program handle call GetModuleHandleA mov hInstance,eax ;return value in eax=handle of program
; API "FindResource" determines the location of a resource with the specified ; type and name in the specified module
push 10 ;lpType,address of resource type, RT_RCDATA push OFFSET SoundName ;lpName, address of resource name push hInstance ;hModule, resource-module handle call FindResourceA cmp eax,0h je ErrorPrg mov handleResource,eax
; API "SizeofResource" returns the size, in bytes, of the specified resource.
push handleResource push hInstance call SizeofResource cmp eax,0h je ErrorPrg mov sizeResource,eax
; API "LoadResource" loads the specified resource into global memory.
push handleResource push hInstance call LoadResource cmp eax,0h je ErrorPrg
; API "LockResource" locks the specified resource in memory.
push eax ;hResData, handle to resource to lock call LockResource cmp eax,0h je ErrorPrg mov pointerResource,eax ;pointer to the first byte of the resource
; API "CreateFileA" creates or opens a file, returns a handle to access object.
push 0h ;hTemplateFile, push 80h ;dwFlagsAndAttributes, 80h=normal push 2h ;dwCreationDistribution, CREATE_ALWAYS push 0h ;lpSecurityAttributes, push 0h ;dwShareMode, push 40000000h ;dwDesiredAccess,GENERIC_WRITE push OFFSET FileName ;lpFileName,pointer to filename call CreateFileA cmp eax,-1 ;error ? INVALID_HANDLE_VALUE = -1 je ErrorPrg ; mov handleFile,eax ;store handle in variable
; API "WriteFile" writes data to a file
; It writes the temp file O.K.
push 0h ;lpOverlapped, structure overlapped I/O push OFFSET returnFile ;lpNumberOfBytesWritten, push sizeResource ;nNumberOfBytesToWrite, bytes to write push pointerResource ;lpBuffer, address data write to file push handleFile ;hFile, handle of file to write to call WriteFile cmp eax,0h ;check for error je ErrorPrg ;
; API "CloseHandle" closes an open object handle.
push handleFile ;hObject, handle of object to close call CloseHandle cmp eax,0h ;check for error je ErrorPrg
; API "mciSendCommandA" here opens the device
mov open_lpstrDeviceType,0h ;fill MCI_OPEN_PARMS structure mov open_lpstrElementName,OFFSET FileName
invoke mciSendCommandA,0,MCI_OPEN,MCI_OPEN_ELEMENT,offset open_dwCallback
cmp eax,0h ; EAX = 119h
Invoke mciGetErrorString, Eax, Addr szFehler, 128 Invoke MessageBox, 0, Addr szFehler, Addr Box, MB_OK
; Getting this message, "Cannot determine device type from the given filename extension."
jne ErrorPrg ; ; mciSendCommand ; MCIDEVICEID IDDevice, Device identifier of the MCI device ; UINT uMsg, Command message ; DWORD fdwCommand, Flags for the command message. ; DWORD_PTR dwPa Address of a structure that contains parameters for the command message
; API "mciSendCommandA", MCI_PLAY command begins transmitting output data.
invoke mciSendCommand,open_wDeviceID,MCI_PLAY,MCI_FROM,offset play_dwCallback
cmp eax,0h jne ErrorPrg
; API "MessageBoxA" creates a message box.
invoke MessageBox,0,addr MB2Text,addr MB2Titel,MB_OK
; API "mciSendCommandA" here closes the device
invoke mciSendCommand,open_wDeviceID,MCI_CLOSE,0,offset generic_dwCallback
cmp eax,0h jne ErrorPrg
ExitPrg:
push hInstance ;push our programm handle to exit invoke DeleteFile,offset FileName call ExitProcess ;- API Function -
ErrorPrg:
invoke MessageBox,0,addr MB1Text,addr MB1Titel,MB_OK jmp ExitPrg
end Main ;end of our program code, entry point
And the rsrc.rc file :
#include "c:\Masm32\INCLUDE\resource.h" ;============================================================================== ; ==> Mp3Rsrc : the resource file ;------------------------------------------------------------------------------ TDSound RCDATA temp.mp3 |
|