- Code/Resource
- Windows Develop
- Linux-Unix program
- Internet-Socket-Network
- Web Server
- Browser Client
- Ftp Server
- Ftp Client
- Browser Plugins
- Proxy Server
- Email Server
- Email Client
- WEB Mail
- Firewall-Security
- Telnet Server
- Telnet Client
- ICQ-IM-Chat
- Search Engine
- Sniffer Package capture
- Remote Control
- xml-soap-webservice
- P2P
- WEB(ASP,PHP,...)
- TCP/IP Stack
- SNMP
- Grid Computing
- SilverLight
- DNS
- Cluster Service
- Network Security
- Communication-Mobile
- Game Program
- Editor
- Multimedia program
- Graph program
- Compiler program
- Compress-Decompress algrithms
- Crypt_Decrypt algrithms
- Mathimatics-Numerical algorithms
- MultiLanguage
- Disk/Storage
- Java Develop
- assembly language
- Applications
- Other systems
- Database system
- Embeded-SCM Develop
- FlashMX/Flex
- source in ebook
- Delphi VCL
- OS Develop
- MiddleWare
- MPI
- MacOS develop
- LabView
- ELanguage
- Software/Tools
- E-Books
- Artical/Document
DSTRENUM.C
Package: MSDN_VC98.zip [view]
Upload User: bangxh
Upload Date: 2007-01-31
Package Size: 42235k
Code Size: 5k
Category:
Windows Develop
Development Platform:
Visual C++
- /*==========================================================================
- *
- * Copyright (C) 1995-1996 Microsoft Corporation. All Rights Reserved.
- *
- * File: dstrenum.c
- * Content: Illustrates enumerating DirectSound drivers
- *
- ***************************************************************************/
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- #include <windowsx.h>
- #include <mmsystem.h>
- #include <dsound.h>
- #include <memory.h>
- #include "dsstream.h"
- extern HINSTANCE hInst;
- extern HWND hWndMain;
- /****************************************************************************/
- /* DoDSoundEnumerate() */
- /* */
- /* This function takes care of handling the DirectSound enumeration, which*/
- /* simply means creating a dialog box, at this point... */
- /****************************************************************************/
- BOOL DoDSoundEnumerate( LPGUID lpGUID )
- {
- if( DialogBoxParam( hInst, MAKEINTRESOURCE(IDD_DSENUMBOX), hWndMain,
- DSEnumDlgProc, (LPARAM)lpGUID ))
- return( TRUE );
- return( FALSE );
- }
- /****************************************************************************/
- /* DSEnumDlgProc() */
- /* */
- /* Dialog procedure for the DSound enumeration choice dialog. Allows the */
- /* user to choose from installed drivers. Returns TRUE on error. */
- /****************************************************************************/
- BOOL CALLBACK DSEnumDlgProc( HWND hDlg, UINT msg,
- WPARAM wParam, LPARAM lParam )
- {
- static HWND hCombo;
- static LPGUID lpGUID;
- LPGUID lpTemp;
- int i;
- switch( msg )
- {
- case WM_INITDIALOG:
- hCombo = GetDlgItem( hDlg, IDC_DSENUM_COMBO );
- lpGUID = (LPGUID)lParam;
- if( DirectSoundEnumerate( (LPDSENUMCALLBACK)DSEnumProc, &hCombo ) != DS_OK )
- {
- EndDialog( hDlg, TRUE );
- return( TRUE );
- }
- if( ComboBox_GetCount( hCombo ))
- ComboBox_SetCurSel( hCombo, 0 );
- else
- {
- EndDialog( hDlg, TRUE );
- return( TRUE );
- }
- return( TRUE );
- case WM_COMMAND:
- switch( LOWORD( wParam ))
- {
- case IDOK:
- for( i = 0; i < ComboBox_GetCount( hCombo ); i++ )
- {
- lpTemp = (LPGUID)ComboBox_GetItemData( hCombo, i );
- if( i == ComboBox_GetCurSel( hCombo ))
- {
- if( lpTemp != NULL )
- memcpy( lpGUID, lpTemp, sizeof(GUID));
- else
- lpGUID = NULL;
- }
- if( lpTemp )
- LocalFree( lpTemp );
- }
- // If we got the NULL GUID, then we want to open the default
- // sound driver, so return with an error and the init code
- // will know not to pass in the guID and will send NULL
- // instead.
- if( lpGUID == NULL )
- EndDialog( hDlg, TRUE );
- else
- EndDialog( hDlg, FALSE );
- return( TRUE );
- case IDCANCEL:
- // Force a NULL GUID
- EndDialog( hDlg, TRUE );
- return( TRUE );
- }
- break;
- default:
- return( FALSE );
- }
- return( FALSE );
- }
- /****************************************************************************/
- /* DSEnumProc() */
- /* */
- /* This is the Enumeration procedure called by DirectSoundEnumerate with */
- /* the parameters of each DirectSound Object available in the system. */
- /****************************************************************************/
- BOOL CALLBACK DSEnumProc( LPGUID lpGUID, LPSTR lpszDesc,
- LPSTR lpszDrvName, LPVOID lpContext )
- {
- HWND hCombo = *(HWND *)lpContext;
- LPGUID lpTemp = NULL;
- if( lpGUID != NULL )
- {
- if(( lpTemp = LocalAlloc( LPTR, sizeof(GUID))) == NULL )
- return( TRUE );
- memcpy( lpTemp, lpGUID, sizeof(GUID));
- }
- ComboBox_AddString( hCombo, lpszDesc );
- ComboBox_SetItemData( hCombo,
- ComboBox_FindString( hCombo, 0, lpszDesc ),
- lpTemp );
- return( TRUE );
- }