Delphi enumeration device code _ PHP Tutorial

Source: Internet
Author: User
Delphi enumeration device code. Delphi enumeration device use code current delphi (2010, xe) already comes with directx related units (... sourcertlwin). ---------------------------------------------------------------- delphi enumeration device use code

Currently, delphi (2010, xe) has built-in directx-related units (... sourcertlwin ).
--------------------------------------------------------------------------------

// Enumeration function
Function directsoundenumerate (
Lpdsenumcallback: tdsenumcallback; // callback function
Lpcontext: pointer // User pointer
): Hresult; stdcall; // return the error code. if the code is successful, s_ OK (0) is returned)

// Original form of the callback function required by directsoundenumerate:
Tdsenumcallback = function (
Lpguid: pguid; // guid of the device
Lpcstrdescription: pchar; // device description
Lpcstrmodule: pchar; // module id
Lpcontext: pointer // User pointer provided by directsoundenumerate
): Bool; stdcall; // returns true, indicating that the enumeration is to be continued. if you do not continue searching, false is returned.

--------------------------------------------------------------------------------

This is a common code:
--------------------------------------------------------------------------------

Unit unit1;

Interface

Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, stdctrls;

Type
Tform1 = class (tform)
Listbox1: tlistbox; // only a list box is placed on the form.
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;

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 (lpcstrdescription );
If lpcstrmodule <> nil then tstrings (lpcontext). add (lpcstrmodule );
Tstrings (lpcontext). add (emptystr );
Result: = true;
End;

Procedure tform1.formcreate (sender: tobject );
Begin
Directsoundenumerate (enumcallback, listbox1.items );
End;

Http://www.bkjia.com/PHPjc/632336.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632336.htmlTechArticledelphi enumeration device using code now delphi (2010, xe) already comes with directx related units (... sourcertlwin ).--------------------------------------------------------------...

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.