In Delphi 2009, you need to modify the bass_deviceinfo structure definition in bass. Pas. Otherwise, garbled characters will occur:
// Change bass_deviceinfo = Record Name: pchar; // description DRIVER: pchar; // driver flags: DWORD; end; // to bass_deviceinfo = Record Name: pansichar; // description DRIVER: pansichar; // driver flags: DWORD; end;
In this example:
Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; listbox1: tlistbox; procedure formcreate (Sender: tobject); Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses bass; Procedure tform1.formcreate (Sender: tobject); begin if hiword (bass_getversion) bass Version then MessageBox (0, '"Bass. dll" file version is not suitable! ', Nil, mb_iconerror); listbox1.align: = altop; button1.caption: = 'get current audio output device list'; end; Procedure tform1.button1click (Sender: tobject); var info: bass_deviceinfo; i: integer; begin I: = 1; while bass_getdeviceinfo (I, Info) Do begin listbox1.items. add (string (info. name); Inc (I); end.
Form file:
Object form1: tform1 left = 0 Top = 0 caption = 'form1 'clientheight = 125 clientwidth = 195 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false oncreate = formcreate pixelsperinch = 96 textheight = 13 object button1: tbutton left = 8 Top = 86 width = 179 Height = 25 caption = 'button1' taborder = 0 onclick = button1click end object listbox1: tlistbox left = 24 Top = 8 width = 113 Height = 73 itemheight = 13 taborder = 1 endend