Einzelnen Beitrag anzeigen

Friedhelm Drecktrah
(Gast)

n/a Beiträge
 
#9

AW: Rückgabe-Pointer PUTF8String aus DLL in String umwandeln?

  Alt 17. Jan 2020, 15:26
Das läuft bei mir:

program SDLDemo;

{$APPTYPE CONSOLE}
{$R *.res}

uses
System.SysUtils;

type
TSdlAudio = class
public
procedure GetAudioDeviceNames();
end;

const
SDL_INIT_TIMER = $00000001;
SDL_INIT_AUDIO = $00000010;
SDL_INIT_VIDEO = $00000020; // SDL_INIT_VIDEO implies SDL_INIT_EVENTS
SDL_INIT_JOYSTICK = $00000200; // SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS
SDL_INIT_HAPTIC = $00001000;
SDL_INIT_GAMECONTROLLER = $00002000; // SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK
SDL_INIT_EVENTS = $00004000;
SDL_INIT_SENSOR = $00008000;
SDL_INIT_NOPARACHUTE = $00100000; // compatibility; this flag is ignored.

DEVICE_TYPE_OUTPUT = 0;
DEVICE_TYPE_INPUT_CAPTURE = 1;

function SDL_Init(flags: integer): integer; cdecl; external 'SDL2.dll';
function SDL_GetNumAudioDevices(isCapture: integer): integer; cdecl; external 'SDL2.dll';
function SDL_GetAudioDeviceName(index: integer; isCapture: integer): PAnsiChar; cdecl; external 'SDL2.dll';

{ TSdlAudio }

procedure TSdlAudio.GetAudioDeviceNames();
var
initResult: integer;

numDevices: integer;
deviceId: integer;

deviceName: PAnsiChar;
begin
initResult := SDL_Init(SDL_INIT_AUDIO);
Writeln('initResult: ' + initResult.ToString());

numDevices := SDL_GetNumAudioDevices(0);
Writeln('numDevices: ' + numDevices.ToString());

for deviceId := 0 to numDevices - 1 do
begin
deviceName := SDL_GetAudioDeviceName(deviceId, DEVICE_TYPE_OUTPUT);
Writeln('deviceName: ' + deviceName);
end;
end;

var
sdlAudio: TSdlAudio;

begin
try
sdlAudio := TSdlAudio.Create;
sdlAudio.GetAudioDeviceNames();
sdlAudio.Free;

Writeln;
Writeln('Enter drücken...');
ReadLn;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;

end.


Gruß

Geändert von Friedhelm Drecktrah (17. Jan 2020 um 15:56 Uhr)
  Mit Zitat antworten Zitat