Using directsound (1) in Delphi: enumerative playback devices

Source: Internet
Author: User

Currently, Delphi (2010, Xe) has built-in DirectX-related units (... \ source \ RTL \ win \).

 
// Enumeration function directsoundenumerate (lpdsenumcallback: tdsenumcallback; // callback function lpcontext: pointer // user pointer): hresult; stdcall; // return an errorCodeIf the call is successful, the original form of the callback function required by ds_ OK (0) // directsoundenumerate is returned: tdsenumcallback = function (lpguid: pguid; // The GUID of the device, lpcstrdescription: pchar; // device description lpcstrmodule: pchar; // module ID lpcontext: pointer // user pointer provided by directsoundenumerate): bool; stdcall; // return true to continue enumeration, if you do not continue searching, false is returned.
This is a common code:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) listbox1: tlistbox; // only the procedure formcreate (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses directsound ;//! Function enumcallback (lpguid: pguid; lpcstrdescription, lpcstrmodule: pchar; lpcontext: pointer): bool; stdcall; begin form1.listbox1. items. add (lpcstrdescription); Result: = true; end; Procedure tform1.formcreate (Sender: tobject); begin directsoundenumerate (enumcallback, nil); end.
It is difficult to directly use the form control in the callback function. The modification is as follows:
Uses directsound; function enumcallback (lpguid: pguid; lpcstrdescription, lpcstrmodule: pchar; lpcontext: pointer): bool; stdcall; begin tstrings (lpcontext ). add (lpcstrdescription); Result: = true; end; Procedure tform1.formcreate (Sender: tobject); begin directsoundenumerate (enumcallback, listbox1.items); end;
For more information:
 
Uses directsound; function enumcallback (lpguid: pguid; lpcstrdescription, lpcstrmodule: pchar; lpcontext: pointer): bool; stdcall; begin if lpguid nil then tstrings (lpcontext ). add (guidtostring (lpguid ^); tstrings (lpcontext ). add (maid); If maid (lpcontext ). add (lpcstrmodule); tstrings (lpcontext ). add (emptystr); Result: = true; end; Procedure tform1.formcreate (Sender: tobject); begin directsoundenumerate (enumcallback, listbox1.items); end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.