Hallo
Die Stringübergabe aus der
DLL heraus funktioniert. Ich habe schon einige Funktionen darin implementiert.
Deine Funktion habe ich soweit abgeändert, dass die gefundenen Werte global in einem Record gespeichert werden.
Hier ist der Quellcode:
Delphi-Quellcode:
// globale Variablen
rec_displaydevice = record
DeviceName:string;
DeviceString:string;
Monitorname:String;
end;
var displaydevice:array[1..4] of rec_displaydevice;
var numberdisplaydevice:integer;
function get_NumberDisplayDevice:integer;
Var
Cntr : Cardinal;
Info : TDisplayDevice;
AdapterName : PChar;
OldPos : Integer;
Const
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = $00000001;
DISPLAY_DEVICE_MULTI_DRIVER = $00000002;
DISPLAY_DEVICE_PRIMARY_DEVICE = $00000004;
DISPLAY_DEVICE_MIRRORING_DRIVER = $00000008;
DISPLAY_DEVICE_VGA = $00000010;
Begin
NumberDisplayDevice:=0;
Cntr := 0;
Info.cb := SizeOf(Info);
While EnumDisplayDevices(Nil, Cntr, Info, 0) Do
Begin
NumberDisplayDevice:=NumberDisplayDevice+1;
displaydevice[NumberDisplayDevice].DeviceName:=Info.DeviceName;
displaydevice[NumberDisplayDevice].DeviceName:=Info.DeviceString;
AdapterName := StrAlloc(SizeOf(Info.DeviceName));
StrCopy(AdapterName, Info.DeviceName);
EnumDisplayDevices(AdapterName, 0, Info, 0);
displaydevice[NumberDisplayDevice].Monitorname:=Info.DeviceString;
StrDispose(AdapterName);
Inc(Cntr);
End;
result:=NumberDisplayDevice;
End;