【正文】
) 如何改變Windows桌面背景? *API函數(shù)聲明 Const SPI_SETDESKWALLPAPER = 20 Const SPIF_UPDATEINIFILE = amp。, vbInformation, 聲卡檢測(cè) Else MsgBox 你的系統(tǒng)不能播放聲音。 : lType = GetDriveType(tmpDrive) 注釋:Win32 API 函數(shù) If (lType = DRIVE_CDROM) Then 注釋:Win32 API 常數(shù) found = True Exit For End If Next If Not found Then tmpDrive = BI_GetCDROMDrive = tmpDrive exit Function errL: msgbox error$ End Function 2如何將文件放入回收站? **API函數(shù)聲明 Public Type SHFILEOPSTRUCT hwnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAnyOperationsAborted As Long hNameMappings As Long lpszProgressTitle As Long End Type Public Declare Function SHFileOperation Lib _ Alias SHFileOperationA (lpFileOp As SHFILEOPSTRUCT) As Long Public Const FO_DELETE = amp。H40 注釋:調(diào)用 Dim SHop As SHFILEOPSTRUCT, strFile as string With SHop .wFunc = FO_DELETE .pFrom = strFile + Chr(0) .fFlags = FOF_ALLOWUNDO End With 2VB中如何使用未安裝的字體? Declare Function AddFontResource Lib gdi32 Alias AddFontResourceA (ByVal lpFileName As String) As Long Declare Function RemoveFontResource Lib gdi32 Alias RemoveFontResourceA (ByVal lpFileName As String) As Long 增加字體: Dim lResult As Long lResult = AddFontResource(c:) 刪除字體: Dim lResult As Long lResult = RemoveFontResource(c:)用MCI命令來(lái)實(shí)現(xiàn)多媒體的播放功能 39?! ublic Declare Function mciSendString Lib Alias mciSendStringA (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Public Declare Function mciGetDeviceID Lib Alias mciGetDeviceIDA (ByVal lpstrName As String) As Long Public Declare Function waveOutGetVolume Lib (ByVal uDeviceID As Long, lpdwVolume As Long) As Long Public Declare Function GetWindowLong Lib user32 Alias GetWindowLongA (ByVal hwnd As Long, ByVal nIndex As Long) As Long Public Declare Function CallWindowProc Lib user32 Alias CallWindowProcA (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Declare Function SetWindowLong Lib user32 Alias SetWindowLongA (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function GetShortPathName Lib kernel32 Alias GetShortPathNameA (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long Enum PlayTypeName File = 1 CDAudio = 2 VCD = 3 RealPlay = 4 End Enum Dim PlayType As PlayTypeName Enum AudioSource AudioStereo = 0 39。left AudioRight = 2 39。======================================================= 39。======================================================= Public Function OpenURL(urlStr As String, Optional hwnd As Long) As Boolean OpenMusic = False Dim MciCommand As String Dim DriverID As String CloseMusic 39。 urlStr amp。 DriverID amp。 hwnd amp。======================================================= 39。======================================================= Public Function OpenMusic(FileName As String, Optional hwnd As Long) As Boolean OpenMusic = False Dim ShortPathName As String * 255 Dim RefShortName As String Dim RefInt As Long Dim MciCommand As String Dim DriverID As String CloseMusic 39。MCI命令 DriverID = GetDriverID(RefShortName) If DriverID = RealPlayer Then PlayType = RealPlay Exit Function End If MciCommand = open amp。 type amp。 alias NOWMUSIC If DriverID = AVIVideo Or DriverID = MPEGVideo Or DriverID = MPEGVideo2 Then If hwnd 0 Then MciCommand = MciCommand + parent amp。 style child hWndMusic = GetWindowHandle prevWndproc = GetWindowLong(hWndMusic, 4) SetWindowLong hWndMusic, 4, AddressOf WndProc Else MciCommand = MciCommand + style overlapped End If End If RefInt = mciSendString(MciCommand, vbNull, 0, 0) mciSendString set NOWMUSIC time format milliseconds, vbNullString, 0, 0 If RefInt = 0 Then OpenMusic = True End Function Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If Msg = amp。======================================================= 39。======================================================= Public Function GetDriverID(ff As String) As String Select Case UCase(Right(ff, 3)) Case MID, RMI, IDI GetDriverID = Sequencer Case WAV GetDriverID = Waveaudio Case ASF, ASX, IVF, LSF, LSX, P2V, WAX, WVX, .WM, WMA, WMX, WMP GetDriverID = MPEGVideo2 Case .RM, RAM, .RA GetDriverID = RealPlayer Case Else GetDriverID = MPEGVideo End Select End Function 39。播放文件 39。====================================================== 39。====================================================== Public Function GetMusicLength() As Long Dim RefStr As String * 80 mciSendString status NOWMUSIC length, RefStr, 80, 0 GetMusicLength = Val(RefStr) End Function 39。獲取當(dāng)前播放進(jìn)度 39。====================================================== 39。====================================================== Public Function SetMusicPos(Position As Long) As Boolean Dim RefInt As Long SetMusicPos = False RefInt = mciSendString(seek NOWMUSIC to amp。====================================================== 39。====================================================== Public Function PauseMusic() As Boolean Dim RefInt As Long PauseMusic = False RefInt = mciSendString(pause NOWMUSIC, vbNull, 0, 0) If RefInt = 0 Then PauseMusic = True End Function 39。關(guān)閉媒體 39。====================================================== 39。====================================================== Public Function SetAudioSource(sAudioSource As AudioSource) As Boolean Dim RefInt As Long Dim strSource As String Select Case sAudioSource Case 1: strSource = left Case 2: strSource = right Case 0: str