Home Backend Development PHP Tutorial Delphi enumeration device usage code_PHP tutorial

Delphi enumeration device usage code_PHP tutorial

Jul 13, 2016 am 10:54 AM
delphi di code use enumerate now Bring your own equipment

delphi enumeration device usage code

Now delphi (2010, xe) already comes with directx related units (...sourcertlwin).
-------------------------------------------------- ----------------------------------

//Enumeration function
function directsoundenumerate(
lpdsenumcallback: tdsenumcallback; //Callback function
lpcontext: pointer //User pointer
): hresult; stdcall; //Return error code, if successful, return s_ok(0)

//The prototype of the callback function required by directsoundenumerate:
tdsenumcallback = function(
lpguid: pguid; //Guid of the device
lpcstrdescription: pchar; //Device description
lpcstrmodule: pchar; //Module identification
lpcontext: pointer //User pointer provided by directsoundenumerate
): bool; stdcall; //Returning true means that we want to continue enumeration. If we no longer want to continue searching, return false

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

This is the common code:
-------------------------------------------------- ----------------------------------

unit unit1;

interface

uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls;

type
tform1 = class(tform)
Listbox1: tlistbox; //Only one 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 not good to use the form control directly in the callback function. Modify it 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;

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

Get 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;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632336.htmlTechArticledelphi enumeration device usage code The current delphi (2010, xe) already comes with directx related units (. ..sourcertlwin).------------------------------------------------ ------------------...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

What software is crystaldiskmark? -How to use crystaldiskmark?

How to download foobar2000? -How to use foobar2000 How to download foobar2000? -How to use foobar2000 Mar 18, 2024 am 10:58 AM

How to download foobar2000? -How to use foobar2000

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

How to use NetEase Mailbox Master

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

How to use Baidu Netdisk app

GE universal remote codes program on any device GE universal remote codes program on any device Mar 02, 2024 pm 01:58 PM

GE universal remote codes program on any device

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange?

Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection' Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection' Mar 10, 2024 pm 04:34 PM

Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection'

How to use Xiaomi Auto app How to use Xiaomi Auto app Apr 01, 2024 pm 09:19 PM

How to use Xiaomi Auto app

See all articles