Geolocation Windows API
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo Leute,
ich werde verrückt, ich versuche über die Windows API den Standort zu bekommen, da TLocationSensor nicht (mehr) funktioniert. https://quality.embarcadero.com/browse/RSP-38580 Dafür will ich https://docs.microsoft.com/de-DE/uwp...ew=winrt-22621 benutzen, es gibt dies sogar schon in Delphi Winapi.Devices.Geolocation. Ich habe ein C# Beispielprojekt kompiliert hier funktioniert es einwandfrei (https://github.com/microsoft/Windows...sition.xaml.cs)
Code:
Nun bekomme ich einen Fehler dass die Schnittstelle nicht unterstützt wird, jetzt bin ich komplett gebrochen... :lol:
var accessStatus = await Geolocator.RequestAccessAsync();
switch (accessStatus) { case GeolocationAccessStatus.Allowed: _geolocator = new Geolocator { ReportInterval = 2000 }; _geolocator.PositionChanged += OnPositionChanged; _geolocator.StatusChanged += OnStatusChanged; break; Hier ist ein Ausschnitt meines Codes (der Rest ist im Anhang)t:
Code:
Gibt es hierfür eine Lösung oder eine gute alternative zu TLocationSensor um durchgehend den Standort ermitteln zu können? Dies muss unter Windows und auch Offline (GPS) funktionieren!
procedure statusCompletedAccess(asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus);
TAccessStatusCompletedHandlerCompleted = procedure(asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus) of object; type TAccessStatusCompletedHandler = class(TInspectableObject, AsyncOperationCompletedHandler_1__GeolocationAccessStatus) private FEvent: TAccessStatusCompletedHandlerCompleted; public procedure Invoke(asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus); safecall; constructor Create(AEvent: TAccessStatusCompletedHandlerCompleted); end; constructor TAccessStatusCompletedHandler.Create( AEvent: TAccessStatusCompletedHandlerCompleted); begin FEvent := AEvent; end; procedure TAccessStatusCompletedHandler.Invoke( asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus); begin FEvent(asyncInfo, asyncStatus); end; procedure TForm9.statusCompletedAccess( asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus); begin ShowMessage('JAA!!!'); end; Falls dies aufwendiger ist und jemand das Interesse hat mir dabei zu helfen, könnte ich evtl. meinen Arbeitgeber fragen ob dieser dann auch "entschädigt" wird :D Testprojekt im Anhang. |
AW: Geolocation Windows API
Zitat:
Funktioniert dann das C# Projekt noch? Bei Microsoft Projekten ist teilweise im Manifest ein generisches Zertifikat für höhere Benutzerrechte vorhanden. Bei Einträgen wie Zitat:
Zitat:
Also mit elektronischem Kompass hat man da nur eine rudimentäre Lokalisation. Was soll damit erzielt werden? Geo Lock für Softwareverwendung? Da gibts kommerzielle Lösungen, die per DLL eingebunden werden können. Zitat:
|
AW: Geolocation Windows API
Ich würde es per HTML5 realisieren, benötigt keine kommerzielle Dll und auch nichts von Microsoft :D
|
AW: Geolocation Windows API
Geolocation ohne GPS funktioniert meist so, dass irgendwelche Anbieter W-Lan Router/AP Standorte
erfasst haben und durch die Info welche man gerade "empfängt"/"sieht" man einen ungefähren Standort ermitteln kann, wenn man genügend von denen die in der DB sind gleichzeitig sieht und eine Internetverbindung hat um diese DB abfragen zu können. Vermutlich macht das Geolocation API genau sowas im Hintergrund, wenn kein GPS vorhanden ist. Und nein, da sollte man kein HTML5 dafür brauchen. Dann wäre man ja wieder vom Browser und dessen Umsetzung abhängig, was auch nicht besser wäre. |
AW: Geolocation Windows API
Danke für die umfangreichen & hilfreichen Antworten!
Da habe ich mich evtl. falsch ausgedrückt, natürlich sollte hauptsächlich der GPS-Sensor benutzt werden, wünschenswert wäre falls GPS mal nicht verfügbar ist sollte der Standort aus z.B. WLAN oder IP herkommen, wie die Windows-API es macht. Zitat:
|
AW: Geolocation Windows API
Zitat:
Im Moment interessieren uns nur ERP Programme, die wir bei unseren Kunden verwenden könnten. Für alles andere wird derzeit kein Auftrag angenommen. |
AW: Geolocation Windows API
Bitte sehr:
Delphi-Quellcode:
Beim Debuggen der Zuweisung
type
TAccessStatusCompletedHandler = class(TInspectableObject, AsyncOperationCompletedHandler_1__GeolocationAccessStatus_Delegate_Base, AsyncOperationCompletedHandler_1__GeolocationAccessStatus) private FEvent: TAccessStatusCompletedHandlerCompleted; public procedure Invoke(asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus); safecall; constructor Create(AEvent: TAccessStatusCompletedHandlerCompleted); end;
Delphi-Quellcode:
kommt man in
AsyncOperation.Completed := CompletedHandler;
Delphi-Quellcode:
raus:
TInterfacedObject.QueryInterface
Code:
Hier wird nach der
System.TInterfacedObject.QueryInterface((4082257043, 58823, 23432, (190, 219, 211, 230, 55, 207, 242, 113)),(no value))
:76d2de72 combase.RoGetAgileReference + 0x62 :77b6272b ; C:\Windows\SysWOW64\Geolocation.dll :77b742e1 ; C:\Windows\SysWOW64\Geolocation.dll :77b7637d ; C:\Windows\SysWOW64\Geolocation.dll Unit9.TForm9.Button3Click($43A6380)
Delphi-Quellcode:
gefragt, was als bekannte Hex(-String) Darstellung dem hier entspricht:
IID = (4082257043, 58823, 23432, (190, 219, 211, 230, 55, 207, 242, 113))
Delphi-Quellcode:
.
'{F3524C93-E5C7-5B88-BEDB-D3E637CFF271}'
Das wiederrum ist in Winapi.Devices.Geolocation das Interface
Delphi-Quellcode:
.
AsyncOperationCompletedHandler_1__GeolocationAccessStatus_Delegate_Base
Lessons Learned: 1. Debug-DCU einschalten. 2. Trace into (F7) Debugging nutzen. 3. Bei (COM-)Interface-Geschichten im Zweifelsfall ruhig auch das Eltern-Interface mit in die Klasse ziehen, auch wenn keine Methoden darin definiert sind. |
AW: Geolocation Windows API
Zitat:
Ich krieg zwar keinen Dialog wo man nach der Erlaubnis gefragt wird, aber das denke ich liegt daran dass VCL keine WINUI oder UWP ist. Ich schau mal was ich hier machen kann. Btw. wo enable ich Debug-DCU? |
AW: Geolocation Windows API
Debug DCUs: Projekt/Optionen/Erzeugen/Delphi-Compiler/Compilieren/Mit Debug DCUs
|
AW: Geolocation Windows API
Zitat:
|
AW: Geolocation Windows API
Zitat:
Delphi-Quellcode:
function ToIID(A: Cardinal; B, C: Word; D, E, F, G, H, I, J, K: Byte): string;
begin Result := '{' + IntToHex(A) + '-' + IntToHex(B) + '-' + IntToHex(C) + '-' + IntToHex(D) + IntToHex(E) + '-' + IntToHex(F) + IntToHex(G) + IntToHex(H) + IntToHex(I) + IntToHex(J) + IntToHex(K) + '}'; end; var s: string; begin s := ToIID(4082257043, 58823, 23432, 190, 219, 211, 230, 55, 207, 242, 113); ShowMessage(s); end; |
AW: Geolocation Windows API
ID.ToString TGuidHelper.ToString :stupid:
Zitat:
Ich weiß jetzt nicht, wie es bei dieser Komponente aussieht, aber viele neue Komponenten, im Delphi, greifen intern auf die API der UWP zu, auch wenn du für Win32 (32 oder 64 Bit) kompiliert hast. Wenn ich mich recht erinnere, z.B. bei den Bluetooth-Komponenten. Zitat:
|
AW: Geolocation Windows API
Zitat:
|
AW: Geolocation Windows API
Du nimmst eine Variable von Typ TGUID, füllst deren Felder und dann ...
:angle2: |
AW: Geolocation Windows API
Zitat:
|
AW: Geolocation Windows API
Delphi-Quellcode:
var guid : TGUID;
guid.D1 := 4082257043; guid.D2 := 58823; guid.D3 := 23432; guid.D4[0] := 190; guid.D4[1] := 219; guid.D4[2] := 211; guid.D4[3] := 230; guid.D4[4] := 55; guid.D4[5] := 207; guid.D4[6] := 242; guid.D4[7] := 113; ShowMessage(guid.tostring); |
AW: Geolocation Windows API
Oder ein TGUID.Create mit den binären Daten.
k.A. warum es keine Variante mit den Feld-Parametern gibt oder der String-Variante. wobei der Compiler den String
Delphi-Quellcode:
kennt und man es dort einfach mit
'{...}'
Delphi-Quellcode:
machen kann.
:=
|
AW: Geolocation Windows API
Danke für die Einweisung @SheBang, das funzt :-D
Zitat:
|
AW: Geolocation Windows API
Zitat:
Nur Spaß, mit ein-zwei Zeilen bist du dabei (siehe auch vorige Antworten):
Delphi-Quellcode:
program Project1;
{$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; var IID: TGUID; begin try IID := TGUID.Create(4082257043, 58823, 23432, 190, 219, 211, 230, 55, 207, 242, 113); Writeln(IID.ToString) except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; Readln; end. Das verwendet dann den TGUIDHelper aus System.SysUtils (nein, ich weiß nicht seit wann das drin ist, bitte fragt nicht):
Delphi-Quellcode:
class function TGUIDHelper.Create(A: Cardinal; B, C: Word; D, E, F, G, H, I, J, K: Byte): TGUID;
begin Result.D1 := UInt32(A); Result.D2 := Word(B); Result.D3 := Word(C); Result.D4[0] := D; Result.D4[1] := E; Result.D4[2] := F; Result.D4[3] := G; Result.D4[4] := H; Result.D4[5] := I; Result.D4[6] := J; Result.D4[7] := K; end; |
AW: Geolocation Windows API
Delphi-Quellcode:
procedure guidtest(guid: TGUID);
begin end; const myguid: TGUID = '{F3524C93-E5C7-5B88-BEDB-D3E637CFF271}'; // hier geht es, unten nicht :( procedure TForm21.FormCreate(Sender: TObject); var guid: TGUID; bytes: TBytes; begin guid := TGUID.Create('{F3524C93-E5C7-5B88-BEDB-D3E637CFF271}'); //guid := '{F3524C93-E5C7-5B88-BEDB-D3E637CFF271}'; guid := myguid; // komisch da geht es, warum nicht auch das davor? //guidtest('{F3524C93-E5C7-5B88-BEDB-D3E637CFF271}'); geht auch nicht guidtest(TGUID.Create('{F3524C93-E5C7-5B88-BEDB-D3E637CFF271}')); // den hatte ich auf die Schnelle übersehn .. dachte ihn gibt es (noch) nicht guid := TGUID.Create(4082257043, 58823, 23432, 190, 219, 211, 230, 55, 207, 242, 113); // mit der ByteOrder bin ich mir grade nicht sicher ... kann sein (wird aber bestimmt so sein), das man die ersten LongWord/Word umdrehen muß. bytes := [243, 82, 76, 147, {} 229, 199, {} 91, 136, {} 190, 219, 211, 230, 55, 207, 242, 113]; guid := TGUID.Create(bytes); // als Array guid := TGUID.Create(bytes[0]); // als "irgendwelche" binäre Daten (Zeiger) -> TGUIDHelper.Create(const Data; DataEndian: TEndian=TEndian.Little) end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:16 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz