'窗体中的代码 VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx" Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" Begin VB.Form frmMain Caption = "Mp3Player" ClientHeight = 4275 ClientLeft = 60 ClientTop = 450 ClientWidth = 8205 LinkTopic = "Form1" LockControls = -1 'True ScaleHeight = 4275 ScaleWidth = 8205 StartUpPosition = 2 'CenterScreen Begin VB.TextBox Text4 Height = 375 Left = 5880 TabIndex = 10 Text = "1000" Top = 3240 Width = 855 End Begin VB.TextBox Text3 Height = 375 Left = 360 TabIndex = 9 Top = 720 Width = 6975 End Begin VB.TextBox Text2 Height = 375 Left = 360 TabIndex = 8 Top = 360 Width = 6975 End Begin VB.TextBox Text1 Height = 375 Left = 360 TabIndex = 7 Top = 0 Width = 6975 End Begin VB.CommandButton Command7 Caption = "停止" Height = 615 Left = 4920 TabIndex = 6 Top = 1920 Width = 855 End Begin VB.CommandButton Command6 Caption = "快近" Height = 615 Left = 4920 TabIndex = 5 Top = 3480 Width = 855 End Begin VB.CommandButton Command5 Caption = "快退" Height = 615 Left = 4920 TabIndex = 4 Top = 2760 Width = 855 End Begin VB.CommandButton Command4 Caption = "暂停" Height = 615 Left = 3870 TabIndex = 3 Top = 1920 Width = 855 End Begin VB.CommandButton Command3 Caption = "播放" Height = 615 Left = 2895 TabIndex = 2 Top = 1920 Width = 855 End Begin MSComDlg.CommonDialog CommonDialog1 Left = 1320 Top = 3360 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin VB.CommandButton Command1 Caption = "打开和播放一个媒体文件" Height = 615 Left = 480 TabIndex = 1 Top = 1920 Width = 2172 End Begin VB.Timer Timer1 Enabled = 0 'False Interval = 500 Left = 2040 Top = 3360 End Begin ComctlLib.ProgressBar ProgressBar1 Height = 255 Left = 360 TabIndex = 0 Top = 1440 Width = 4815 _ExtentX = 8493 _ExtentY = 450 _Version = 327682 Appearance = 1 End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim Multimedia As New MmediaPrivate Sub Command1_Click() With CommonDialog1 .Filter = "Mp3 (*.mp3)|*.mp3|WaveAudio (*.wav)|*.wav|Video files (*.avi)|*.avi" .FilterIndex = 0 .ShowOpen End With If CommonDialog1.Filename <> "" Then Multimedia.Wait = False Multimedia.mmOpen CommonDialog1.Filename ProgressBar1.Value = 0 ProgressBar1.Max = Multimedia.Length End IfEnd SubPrivate Sub Command3_Click() Timer1.Enabled = True Multimedia.mmPlayEnd SubPrivate Sub Command4_Click() Multimedia.mmPause End Sub Private Sub Command5_Click() If Multimedia.Status <> "playing" Then Exit SubDim curv As Long Dim stepv As Longcurv = Multimedia.Position stepv = Val(Text4.Text)If curv - stepv > 0 Then Multimedia.mmSeek (curv - stepv): Multimedia.mmPlay
End SubPrivate Sub Command6_Click() If Multimedia.Status <> "playing" Then Exit SubDim curv As Long Dim maxv As Long Dim stepv As Longcurv = Multimedia.Position maxv = Multimedia.Length stepv = Val(Text4.Text)If curv + stepv < maxv Then Multimedia.mmSeek (curv + stepv): Multimedia.mmPlayEnd Sub Private Sub Command7_Click() Multimedia.mmStop End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Multimedia.mmStop End SubPrivate Sub Timer1_Timer() Text1.Text = Multimedia.Status Text2.Text = Multimedia.Position Text3.Text = Multimedia.Length ProgressBar1.Value = Multimedia.Position
If ProgressBar1.Value = ProgressBar1.Max Then Multimedia.mmClose Timer1.Enabled = False End IfEnd Sub
'类模块中的代码 名为Mmdia.cls Option ExplicitPrivate sAlias As String ' Used internally to give an alias name to ' the multimedia resourcePrivate sFilename As String ' Holds the filename internally Private nLength As Single ' Holds the length of the filename ' internally Private nPosition As Single ' Holds the current position internally Private sStatus As String ' Holds the current status as a string Private bWait As Boolean ' Determines if VB should wait until play ' is complete before returning.'note that this is all one code line: Private 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 LongPublic Sub mmOpen(ByVal sTheFile As String) ' Declare a variable to hold the value returned by mciSendString Dim nReturn As Long
' Declare a string variable to hold the file type Dim sType As String ' Opens the specified multimedia file, and closes any ' other that may be open If sAlias <> "" Then mmClose End If
' Determine the type of file from the file extension Select Case UCase$(Right$(sTheFile, 3)) Case "WAV" sType = "Waveaudio" Case "AVI" sType = "AviVideo" Case "MID" sType = "Sequencer" Case "MP3" sType = "MPEGVideo" 'sType = "MPEGVideo" 时 可以播放的不仅是Mp3音乐了. '我只是添加了 Case "MP3" sType = "MPEGVideo",不过功能是大大加强哦.
Case Else ' If the file extension is not known then exit the subroutine Exit Sub End Select sAlias = Right$(sTheFile, 3) & Minute(Now) ' At this point there is no file open, and we have determined the ' file type. Now would be a good time to open the new file. ' Note: if the name contains a space we have to enclose it in quotes If InStr(sTheFile, " ") Then sTheFile = Chr(34) & sTheFile & Chr(34) nReturn = mciSendString("Open " & sTheFile & " ALIAS " & sAlias _ & " TYPE " & sType & " wait", "", 0, 0) End SubPublic Sub mmClose() ' Closes the currently opened multimedia file ' Declare a variable to hold the return value from the mciSendString ' command Dim nReturn As Long ' If there is no file currently open then exit the subroutine If sAlias = "" Then Exit Sub
End SubPublic Sub mmPause() ' Pause playback of the file ' Declare a variable to hold the return value from the mciSendString ' command Dim nReturn As Long
' If there is no file currently open then exit the subroutine If sAlias = "" Then Exit Sub
nReturn = mciSendString("Pause " & sAlias, "", 0, 0)End SubPublic Sub mmPlay() ' Plays the currently open file, from the current position ' Declare a variable to hold the return value from the mciSendString ' command Dim nReturn As Long
' If there is no file currently open, then exit the routine If sAlias = "" Then Exit Sub
' Now play the file If bWait Then nReturn = mciSendString("Play " & sAlias & " wait", "", 0, 0) Else nReturn = mciSendString("Play " & sAlias, "", 0, 0) End If End SubPublic Sub mmStop() ' Stop using a file totally, be it playing or whatever ' Declare a variable to hold the return value from mciSendString Dim nReturn As Long
' If there is no file currently open then exit the subroutine If sAlias = "" Then Exit Sub
End SubPublic Sub mmSeek(ByVal nPosition As Single) ' Seeks to a specific position within the file ' Declare a variable to hold the return value from the mciSendString ' function Dim nReturn As Long
nReturn = mciSendString("Seek " & sAlias & " to " & nPosition, "", 0, 0)End SubProperty Get Filename() As String ' Routine to return a value when the programmer asks the ' object for the value of its Filename property Filename = sFilename End PropertyProperty Let Filename(ByVal sTheFile As String) ' Routine to set the value of the filename property, should the programmer ' wish to do so. This implies that the programmer actually wants to open ' a file as well so control is passed to the mmOpen routine mmOpen sTheFile End PropertyProperty Get Wait() As Boolean ' Routine to return the value of the object's wait property. Wait = bWait End PropertyProperty Let Wait(bWaitValue As Boolean) ' Routine to set the value of the object's wait property bWait = bWaitValue End PropertyProperty Get Length() As Single ' Routine to return the length of the currently opened multimedia file ' Declare a variable to hold the return value from the mciSendString Dim nReturn As Long, nLength As Integer ' Declare a string to hold the returned length from the mci Status call Dim sLength As String * 255
' If there is no file open then return 0 If sAlias = "" Then Length = 0 Exit Property End If nReturn = mciSendString("Status " & sAlias & " length", sLength, 255, 0) nLength = InStr(sLength, Chr$(0)) Length = Val(Left$(sLength, nLength - 1)) End PropertyProperty Let Position(ByVal nPosition As Single) ' Sets the Position property effectively by seeking mmSeek nPosition End PropertyProperty Get Position() As Single ' Returns the current position in the file
' Declare a variable to hold the return value from mciSendString Dim nReturn As Integer, nLength As Integer
' Declare a variable to hold the position returned ' by the mci Status position command Dim sPosition As String * 255 ' If there is no file currently opened then exit the subroutine If sAlias = "" Then Exit Property
' Get the position and return nReturn = mciSendString("Status " & sAlias & " position", sPosition, 255, 0) nLength = InStr(sPosition, Chr$(0)) Position = Val(Left$(sPosition, nLength - 1))End PropertyProperty Get Status() As String ' Returns the playback/record status of the current file ' Declare a variable to hold the return value from mciSendString Dim nReturn As Integer, nLength As Integer
' Declare a variable to hold the return string from mciSendString Dim sStatus As String * 255
' If there is no file currently opened, then exit the subroutine If sAlias = "" Then Exit Property nReturn = mciSendString("Status " & sAlias & " mode", sStatus, 255, 0)
nLength = InStr(sStatus, Chr$(0)) Status = Left$(sStatus, nLength - 1)
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmMain
Caption = "Mp3Player"
ClientHeight = 4275
ClientLeft = 60
ClientTop = 450
ClientWidth = 8205
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 4275
ScaleWidth = 8205
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox Text4
Height = 375
Left = 5880
TabIndex = 10
Text = "1000"
Top = 3240
Width = 855
End
Begin VB.TextBox Text3
Height = 375
Left = 360
TabIndex = 9
Top = 720
Width = 6975
End
Begin VB.TextBox Text2
Height = 375
Left = 360
TabIndex = 8
Top = 360
Width = 6975
End
Begin VB.TextBox Text1
Height = 375
Left = 360
TabIndex = 7
Top = 0
Width = 6975
End
Begin VB.CommandButton Command7
Caption = "停止"
Height = 615
Left = 4920
TabIndex = 6
Top = 1920
Width = 855
End
Begin VB.CommandButton Command6
Caption = "快近"
Height = 615
Left = 4920
TabIndex = 5
Top = 3480
Width = 855
End
Begin VB.CommandButton Command5
Caption = "快退"
Height = 615
Left = 4920
TabIndex = 4
Top = 2760
Width = 855
End
Begin VB.CommandButton Command4
Caption = "暂停"
Height = 615
Left = 3870
TabIndex = 3
Top = 1920
Width = 855
End
Begin VB.CommandButton Command3
Caption = "播放"
Height = 615
Left = 2895
TabIndex = 2
Top = 1920
Width = 855
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 1320
Top = 3360
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command1
Caption = "打开和播放一个媒体文件"
Height = 615
Left = 480
TabIndex = 1
Top = 1920
Width = 2172
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 500
Left = 2040
Top = 3360
End
Begin ComctlLib.ProgressBar ProgressBar1
Height = 255
Left = 360
TabIndex = 0
Top = 1440
Width = 4815
_ExtentX = 8493
_ExtentY = 450
_Version = 327682
Appearance = 1
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Multimedia As New MmediaPrivate Sub Command1_Click() With CommonDialog1
.Filter = "Mp3 (*.mp3)|*.mp3|WaveAudio (*.wav)|*.wav|Video files (*.avi)|*.avi"
.FilterIndex = 0
.ShowOpen
End With If CommonDialog1.Filename <> "" Then
Multimedia.Wait = False
Multimedia.mmOpen CommonDialog1.Filename
ProgressBar1.Value = 0
ProgressBar1.Max = Multimedia.Length
End IfEnd SubPrivate Sub Command3_Click()
Timer1.Enabled = True
Multimedia.mmPlayEnd SubPrivate Sub Command4_Click()
Multimedia.mmPause
End Sub
Private Sub Command5_Click()
If Multimedia.Status <> "playing" Then Exit SubDim curv As Long
Dim stepv As Longcurv = Multimedia.Position
stepv = Val(Text4.Text)If curv - stepv > 0 Then Multimedia.mmSeek (curv - stepv): Multimedia.mmPlay
End SubPrivate Sub Command6_Click()
If Multimedia.Status <> "playing" Then Exit SubDim curv As Long
Dim maxv As Long
Dim stepv As Longcurv = Multimedia.Position
maxv = Multimedia.Length
stepv = Val(Text4.Text)If curv + stepv < maxv Then Multimedia.mmSeek (curv + stepv): Multimedia.mmPlayEnd Sub
Private Sub Command7_Click()
Multimedia.mmStop
End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Multimedia.mmStop
End SubPrivate Sub Timer1_Timer()
Text1.Text = Multimedia.Status
Text2.Text = Multimedia.Position
Text3.Text = Multimedia.Length ProgressBar1.Value = Multimedia.Position
If ProgressBar1.Value = ProgressBar1.Max Then
Multimedia.mmClose
Timer1.Enabled = False
End IfEnd Sub
Option ExplicitPrivate sAlias As String ' Used internally to give an alias name to
' the multimedia resourcePrivate sFilename As String ' Holds the filename internally
Private nLength As Single ' Holds the length of the filename
' internally
Private nPosition As Single ' Holds the current position internally
Private sStatus As String ' Holds the current status as a string
Private bWait As Boolean ' Determines if VB should wait until play
' is complete before returning.'note that this is all one code line:
Private 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 LongPublic Sub mmOpen(ByVal sTheFile As String) ' Declare a variable to hold the value returned by mciSendString
Dim nReturn As Long
' Declare a string variable to hold the file type
Dim sType As String ' Opens the specified multimedia file, and closes any
' other that may be open
If sAlias <> "" Then
mmClose
End If
' Determine the type of file from the file extension
Select Case UCase$(Right$(sTheFile, 3))
Case "WAV"
sType = "Waveaudio"
Case "AVI"
sType = "AviVideo"
Case "MID"
sType = "Sequencer"
Case "MP3"
sType = "MPEGVideo"
'sType = "MPEGVideo" 时 可以播放的不仅是Mp3音乐了.
'我只是添加了 Case "MP3" sType = "MPEGVideo",不过功能是大大加强哦.
Case Else
' If the file extension is not known then exit the subroutine
Exit Sub
End Select
sAlias = Right$(sTheFile, 3) & Minute(Now) ' At this point there is no file open, and we have determined the
' file type. Now would be a good time to open the new file.
' Note: if the name contains a space we have to enclose it in quotes
If InStr(sTheFile, " ") Then sTheFile = Chr(34) & sTheFile & Chr(34)
nReturn = mciSendString("Open " & sTheFile & " ALIAS " & sAlias _
& " TYPE " & sType & " wait", "", 0, 0)
End SubPublic Sub mmClose()
' Closes the currently opened multimedia file ' Declare a variable to hold the return value from the mciSendString
' command
Dim nReturn As Long ' If there is no file currently open then exit the subroutine
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Close " & sAlias, "", 0, 0)
sAlias = ""
sFilename = ""
End SubPublic Sub mmPause()
' Pause playback of the file ' Declare a variable to hold the return value from the mciSendString
' command
Dim nReturn As Long
' If there is no file currently open then exit the subroutine
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Pause " & sAlias, "", 0, 0)End SubPublic Sub mmPlay()
' Plays the currently open file, from the current position ' Declare a variable to hold the return value from the mciSendString
' command
Dim nReturn As Long
' If there is no file currently open, then exit the routine
If sAlias = "" Then Exit Sub
' Now play the file
If bWait Then
nReturn = mciSendString("Play " & sAlias & " wait", "", 0, 0)
Else
nReturn = mciSendString("Play " & sAlias, "", 0, 0)
End If
End SubPublic Sub mmStop()
' Stop using a file totally, be it playing or whatever ' Declare a variable to hold the return value from mciSendString
Dim nReturn As Long
' If there is no file currently open then exit the subroutine
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Stop " & sAlias, "", 0, 0)
End SubPublic Sub mmSeek(ByVal nPosition As Single)
' Seeks to a specific position within the file ' Declare a variable to hold the return value from the mciSendString
' function
Dim nReturn As Long
nReturn = mciSendString("Seek " & sAlias & " to " & nPosition, "", 0, 0)End SubProperty Get Filename() As String
' Routine to return a value when the programmer asks the
' object for the value of its Filename property
Filename = sFilename
End PropertyProperty Let Filename(ByVal sTheFile As String)
' Routine to set the value of the filename property, should the programmer
' wish to do so. This implies that the programmer actually wants to open
' a file as well so control is passed to the mmOpen routine
mmOpen sTheFile
End PropertyProperty Get Wait() As Boolean
' Routine to return the value of the object's wait property.
Wait = bWait
End PropertyProperty Let Wait(bWaitValue As Boolean)
' Routine to set the value of the object's wait property
bWait = bWaitValue
End PropertyProperty Get Length() As Single
' Routine to return the length of the currently opened multimedia file ' Declare a variable to hold the return value from the mciSendString
Dim nReturn As Long, nLength As Integer ' Declare a string to hold the returned length from the mci Status call
Dim sLength As String * 255
' If there is no file open then return 0
If sAlias = "" Then
Length = 0
Exit Property
End If nReturn = mciSendString("Status " & sAlias & " length", sLength, 255, 0)
nLength = InStr(sLength, Chr$(0))
Length = Val(Left$(sLength, nLength - 1))
End PropertyProperty Let Position(ByVal nPosition As Single)
' Sets the Position property effectively by seeking
mmSeek nPosition
End PropertyProperty Get Position() As Single
' Returns the current position in the file
' Declare a variable to hold the return value from mciSendString
Dim nReturn As Integer, nLength As Integer
' Declare a variable to hold the position returned
' by the mci Status position command
Dim sPosition As String * 255 ' If there is no file currently opened then exit the subroutine
If sAlias = "" Then Exit Property
' Get the position and return
nReturn = mciSendString("Status " & sAlias & " position", sPosition, 255, 0)
nLength = InStr(sPosition, Chr$(0))
Position = Val(Left$(sPosition, nLength - 1))End PropertyProperty Get Status() As String
' Returns the playback/record status of the current file ' Declare a variable to hold the return value from mciSendString
Dim nReturn As Integer, nLength As Integer
' Declare a variable to hold the return string from mciSendString
Dim sStatus As String * 255
' If there is no file currently opened, then exit the subroutine
If sAlias = "" Then Exit Property nReturn = mciSendString("Status " & sAlias & " mode", sStatus, 255, 0)
nLength = InStr(sStatus, Chr$(0))
Status = Left$(sStatus, nLength - 1)
End Property
我自己写了个sock类,因为WINSOCK不支持引用(做成安装盘有问题,并且不支持多线程)超OUTLOOK软件,提供源代码
楼主: 本软件是我在业余时间完成,我的目标是将它做成国内一流的客户端邮件软件.现在初具模型.正在修改中.它有一下特点:
1. 基于SDK模式开发
2. 大量源代码:软件中用到的所有组件,包括每一个按钮,均是自己所写.形成了自己风格的完整的一套组件库.他们包括:列表,文件管理,菜单等
所有代码均参照标准协议写成3. 由以下功能模块组成:邮件;新闻组;FTP;任务及其在之基础上的相应管理.如文件管理等.
4. 合作方式:转让经营权;根据你们需要提供技术支持;作为贵公司产品发布等,我们可以详细谈.我的联系方式是:[email protected] 13062323245一下为该软件部分运行界面图:
安装盘下:ftp://[email protected]/SmartMai_Setup.EXE代码下:ftp://[email protected]/SmartMail_Code.rarftp密码:uploads建议大家先下安装盘,因为比较新,