![]() |
[Fehler] URL.pas(32): Inkompatible Typen: 'HKEY' und 'String'
Hallo,
Ich will zur Laufzeit eine Webseite aufrufen und erhalte in folgender Funktion die Fehlermeldung, die den Threadtitel bildet:
Delphi-Quellcode:
Wer kann helfen?
procedure OpenURL(Url: string);
var ts: string; begin with TRegistry.Create do try //Hier kommt die Fehlermeldung des Compilers rootkey := 'HKEY_CLASSES_ROOT'; //Was muss ich anders definieren??? OpenKey('\htmlfile\shell\open\command', False); try ts := ReadString(''); except ts := ''; end; CloseKey; finally Free; end; if ts = '' then Exit; // remove quotes and commandline parameters ts := Copy(ts, Pos('"', ts) + 1, Length(ts)); ts := Copy(ts, 1, Pos('"', ts) - 1); ShellExecute(0, 'open', PChar(ts), PChar(url), nil, SW_SHOW); end; |
AW: [Fehler] URL.pas(32): Inkompatible Typen: 'HKEY' und 'String'
Das ist aber umständlich. Es reicht doch Folgendes:
Delphi-Quellcode:
Noch ein kleiner Hinweis:
function OpenURL(const url: string): Boolean;
begin Result := ShellExecute(0, 'open', PChar(url), nil, nil, SW_SHOW) > 32; end; // Anwendungsbeispiel if not OpenURL('http://www.delphipraxis.net') then RaiseLastWin32Error; Die Funktion OpenURL() kann auch potentiell gefährliche Dinge (Dateien mit Viren) öffnen. Deshalb ggf. die URL prüfen bevor man sie öffnet. |
AW: [Fehler] URL.pas(32): Inkompatible Typen: 'HKEY' und 'String'
Das ist kein String sondern eine Konstante:
Delphi-Quellcode:
rootkey := HKEY_CLASSES_ROOT;
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:50 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz