|
API CD 播放机
(作者: 2000年05月24日 17:24)
[程序语言] Microsoft Visual Basic 4.0,5.0,6.0
[下载源程序] 立即下载
[运行平台] WINDOWS
[源码来源] http://codeguru.developer.com/vb/articles/2165.shtml
[功能描述] 我的CD播放机麻雀虽小,五脏俱全,可以放音乐CD,还具有播放,暂定,停止,倒转,快进,前一首,后一首,打开,关闭和退出功能。我还增加了音量控制等功能。
该程序用到的一些API调用如下:
Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" _
(byval dwError as Long, byval lpstrBuffer as string, _
byval uLength as Long) as Long
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(byval lpstrCommand as string, byval lpstrReturnString as string, _
byval uReturnLength as Long, byval hwndCallback as Long) as Long
'
public hmem as Long
'
public Const SND_ASYNC = &H1
public Const SND_NODEFAULT = &H2
public Const SND_PURGE = &H40
public Const SND_FILENAME = &H20000
'
public Const MMSYSERR_NOERROR = 0
public Const MAXPNAMELEN = 32
public Const MIXER_LONG_NAME_CHARS = 64
public Const MIXER_SHORT_NAME_CHARS = 16
public Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H3&
public Const MIXER_GETCONTROLDETAILSF_VALUE = &H0&
public Const MIXER_SETCONTROLDETAILSF_VALUE = &H0&
public Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2&
public Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &H0&
public Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H1000&
public Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = _
(MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
public Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = _
(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
public Const MIXERLINE_COMPONENTTYPE_SRC_LINE = _
(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
public Const MIXERCONTROL_CT_CLASS_FADER = &H50000000
public Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000
public Const MIXERCONTROL_CONTROLTYPE_FADER = _
(MIXERCONTROL_CT_CLASS_FADER Or _
MIXERCONTROL_CT_UNITS_UNSIGNED)
'
public Const MIXERCONTROL_CONTROLTYPE_VOLUME = _
(MIXERCONTROL_CONTROLTYPE_FADER + 1)
'
public Type MIXERCONTROLDETAILS
cbStruct as Long
dwControlID as Long
cChannels as Long
item as Long
cbDetails as Long
paDetails as Long
End Type
'
public Type MIXERCONTROLDETAILS_UNSIGNED
dwValue as Long
End Type
'
public Type MIXERCONTROL
'
public Type MIXERLINE
'
'Allocates the specified number of bytes from the heap.
'
Declare Function GlobalAlloc Lib "kernel32" (byval wFlags as Long, _
byval dwBytes as Long) as Long
'
'Locks a global memory object and returns a pointer to the
' first byte of the object's memory block. The memory block
' associated with a locked object cannot be moved or discarded.
'
Declare Function GlobalLock Lib "kernel32" (byval hmem as Long) as Long
'
'Frees the specified global memory object and invalidates its handle.
'
Declare Function GlobalFree Lib "kernel32" (byval hmem as Long) as Long
'
Declare Sub CopyPtrFromStruct Lib "kernel32" Alias "RtlMoveMemory" _
(byval ptr as Long, struct as Any, byval cb as Long)
'
Declare Sub CopyStructFromPtr Lib "kernel32" Alias "RtlMoveMemory" _
(struct as Any, byval ptr as Long, byval cb as Long)
'
'Opens a specified mixer device and ensures that the device
' will not be removed until the application closes the handle.
'
Declare Function mixerOpen Lib "winmm.dll" _
(phmx as Long, byval uMxId as Long, byval dwCallback as Long, _
byval dwInstance as Long, byval fdwOpen as Long) as Long
'
'Sets properties of a single control associated with an audio line.
'
Declare Function mixerSetControlDetails Lib "winmm.dll" _
(byval hmxobj as Long, pmxcd as MIXERCONTROLDETAILS, _
byval fdwDetails as Long) as Long
'
'Retrieves information about a specific line of a mixer device.
'
Declare Function mixerGetLineInfo Lib "winmm.dll" _
Alias "mixerGetLineInfoA" (byval hmxobj as Long, _
pmxl as MIXERLINE, byval fdwInfo as Long) as Long
'
'Retrieves one or more controls associated with an audio line.
'
Declare Function mixerGetLineControls Lib "winmm.dll" _
Alias "mixerGetLineControlsA" (byval hmxobj as Long, _
pmxlc as MIXERLINECONTROLS, byval fdwControls as Long) as Long
'
public Function fGetVolumeControl(byval hmixer as Long, _
byval componentType as Long, byval ctrlType as Long, _
byref mxc as MIXERCONTROL) as Boolean
'
|
|
 |