|
Antwort |
Registriert seit: 4. Apr 2008 400 Beiträge |
#1
Hallo zusammen!
Ich brauche etwas Hilfe mit dem Apple Bonjour COM Objekt. Und zwar will ich einen Service Registrieren. Das klappt auch, aber nun möchte ich auch noch Parameter als ITXTRecord übergeben. Das klappt irgendwie nicht:
Delphi-Quellcode:
Doch egal was ich mache, FRecord bleibt immer leer. Das 'SetValue' geht nicht.
FServer: TDNSSDService;
FService: IDNSSDService; FRecord: TTXTRecord; FEventManager: IDNSSDEventManager; function RegisterServer : boolean; begin FServer := TDNSSDService.Create(nil); FEventManager := nil; FRecord := TTXTRecord.Create(nil); FRecord.SetValue('key', 'value'); FService := FServer.Register( 0, 0, 'ArbeitsStation', '_raop._tcp', '', '', 6000, FRecord.DefaultInterface, FEventManager); end; Hat da jemand mehr Erfahrungen damit? Die Bonjour_TLB.pas habe ich mir per Typenbibliothek Import selber erzeugt:
Delphi-Quellcode:
unit Bonjour_TLB;
// ************************************************************************ // // WARNUNG // ------- // Die in dieser Datei deklarierten Typen wurden aus Daten einer Typbibliothek // generiert. Wenn diese Typbibliothek explizit oder indirekt (über eine // andere Typbibliothek) reimportiert wird oder wenn der Befehl // 'Aktualisieren' im Typbibliotheks-Editor während des Bearbeitens der // Typbibliothek aktiviert ist, wird der Inhalt dieser Datei neu generiert und // alle manuell vorgenommenen Änderungen gehen verloren. // ************************************************************************ // // $Rev: 17244 $ // Datei am 30.05.2011 18:34:32 erzeugt aus der unten beschriebenen Typbibliothek. // ************************************************************************ // // Typbib.: C:\Windows\SysWOW64\dnssdX.dll (1) // LIBID: {18FBED6D-F2B7-4EC8-A4A4-46282E635308} // LCID: 0 // Hilfedatei: // Hilfe-String: Apple Bonjour Library 1.0 // Liste der Abhäng.: // (1) v2.0 stdole, (C:\Windows\SysWOW64\stdole2.tlb) // Fehler: // Hinweis: Parameter 'record' im _IDNSSDEvents.ServiceResolved geändert zu 'record_' // Hinweis: Parameter 'record' im _IDNSSDEvents.RecordRegistered geändert zu 'record_' // Hinweis: Parameter 'record' im IDNSSDService.Register geändert zu 'record_' // Hinweis: Parameter 'record' im IDNSSDService.RegisterRecord geändert zu 'record_' // Hinweis: Parameter 'record' im IDNSSDService.AddRecord geändert zu 'record_' // Fehler beim Erzeugen von Palettenbitmap von (TDNSSDService) : Server C:\Windows\SysWOW64\dnssdX.dll enthält keine Symbole // Fehler beim Erzeugen von Palettenbitmap von (TTXTRecord) : Server C:\Windows\SysWOW64\dnssdX.dll enthält keine Symbole // Fehler beim Erzeugen von Palettenbitmap von (TDNSSDRecord) : Server C:\Windows\SysWOW64\dnssdX.dll enthält keine Symbole // Fehler beim Erzeugen von Palettenbitmap von (TDNSSDEventManager) : Server C:\Windows\SysWOW64\dnssdX.dll enthält keine Symbole // ************************************************************************ // // *************************************************************************// // HINWEIS: // Von $IFDEF_LIVE_SERVER_AT_DESIGN_TIME überwachte Einträge, werden von // Eigenschaften verwendet, die Objekte zurückgeben, die explizit mit einen Funktionsaufruf // vor dem Zugriff über die Eigenschaft erzeugt werden müssen. Diese Einträge wurden deaktiviert, // um deren unbeabsichtigte Benutzung im Objektinspektor zu verhindern. Sie können sie // aktivieren, indem Sie LIVE_SERVER_AT_DESIGN_TIME definieren oder sie selektiv // aus den $IFDEF-Blöcken entfernen. Solche Einträge müssen jedoch programmseitig // mit einer Methode der geeigneten CoClass vor der Verwendung // erzeugt werden. {$TYPEDADDRESS OFF} // Unit muss ohne Typüberprüfung für Zeiger compiliert werden. {$WARN SYMBOL_PLATFORM OFF} {$WRITEABLECONST ON} {$VARPROPSETTER ON} {$ALIGN 4} interface uses Windows, ActiveX, Classes, Graphics, OleServer, StdVCL, Variants; // *********************************************************************// // In der Typbibliothek deklarierte GUIDS. Die folgenden Präfixe werden verwendet: // Typbibliotheken : LIBID_xxxx // CoClasses : CLASS_xxxx // DISPInterfaces : DIID_xxxx // Nicht-DISP-Interfaces: IID_xxxx // *********************************************************************// const // Haupt- und Nebenversionen der Typbibliothek BonjourMajorVersion = 1; BonjourMinorVersion = 0; LIBID_Bonjour: TGUID = '{18FBED6D-F2B7-4EC8-A4A4-46282E635308}'; DIID__IDNSSDEvents: TGUID = '{21AE8D7F-D5FE-45CF-B632-CFA2C2C6B498}'; IID_IDNSSDService: TGUID = '{29DE265F-8402-474F-833A-D4653B23458F}'; IID_IDNSSDEventManager: TGUID = '{7FD72324-63E1-45AD-B337-4D525BD98DAD}'; IID_ITXTRecord: TGUID = '{8FA0889C-5973-4FC9-970B-EC15C925D0CE}'; IID_IDNSSDRecord: TGUID = '{9CE603A0-3365-4DA0-86D1-3F780ECBA110}'; CLASS_DNSSDService: TGUID = '{24CD4DE9-FF84-4701-9DC1-9B69E0D1090A}'; CLASS_TXTRecord: TGUID = '{AFEE063C-05BA-4248-A26E-168477F49734}'; CLASS_DNSSDRecord: TGUID = '{5E93C5A9-7516-4259-A67B-41A656F6E01C}'; CLASS_DNSSDEventManager: TGUID = '{BEEB932A-8D4A-4619-AEFE-A836F988B221}'; // *********************************************************************// // Deklaration von in der Typbibliothek definierten Aufzählungen // *********************************************************************// // Konstanten für enum DNSSDFlags type DNSSDFlags = TOleEnum; const kDNSSDFlagsMoreComing = $00000001; kDNSSDFlagsDefault = $00000004; kDNSSDFlagsNoAutoRename = $00000008; kDNSSDFlagsShared = $00000010; kDNSSDFlagsUnique = $00000020; kDNSSDFlagsBrowseDomains = $00000040; kDNSSDFlagsRegistrationDomains = $00000080; kDNSSDFlagsLongLivedQuery = $00000100; kDNSSDFlagsAllowRemoteQuery = $00000200; kDNSSDFlagsForceMulticast = $00000400; kDNSSDFlagsForce = $00000800; kDNSSDFlagsReturnIntermediates = $00001000; kDNSSDFlagsNonBrowsable = $00002000; // Konstanten für enum DNSSDRRType type DNSSDRRType = TOleEnum; const kDNSSDType_A = $00000001; kDNSSDType_NS = $00000002; kDNSSDType_MD = $00000003; kDNSSDType_MF = $00000004; kDNSSDType_CNAME = $00000005; kDNSSDType_SOA = $00000006; kDNSSDType_MB = $00000007; kDNSSDType_MG = $00000008; kDNSSDType_MR = $00000009; kDNSSDType_NULL = $0000000A; kDNSSDType_WKS = $0000000B; kDNSSDType_PTR = $0000000C; kDNSSDType_HINFO = $0000000D; kDNSSDType_MINFO = $0000000E; kDNSSDType_MX = $0000000F; kDNSSDType_TXT = $00000010; kDNSSDType_RP = $00000011; kDNSSDType_AFSDB = $00000012; kDNSSDType_X25 = $00000013; kDNSSDType_ISDN = $00000014; kDNSSDType_RT = $00000015; kDNSSDType_NSAP = $00000016; kDNSSDType_NSAP_PTR = $00000017; kDNSSDType_SIG = $00000018; kDNSSDType_KEY = $00000019; kDNSSDType_PX = $0000001A; kDNSSDType_GPOS = $0000001B; kDNSSDType_AAAA = $0000001C; kDNSSDType_LOC = $0000001D; kDNSSDType_NXT = $0000001E; kDNSSDType_EID = $0000001F; kDNSSDType_NIMLOC = $00000020; kDNSSDType_SRV = $00000021; kDNSSDType_ATMA = $00000022; kDNSSDType_NAPTR = $00000023; kDNSSDType_KX = $00000024; kDNSSDType_CERT = $00000025; kDNSSDType_A6 = $00000026; kDNSSDType_DNAME = $00000027; kDNSSDType_SINK = $00000028; kDNSSDType_OPT = $00000029; kDNSSDType_APL = $0000002A; kDNSSDType_DS = $0000002B; kDNSSDType_SSHFP = $0000002C; kDNSSDType_IPSECKEY = $0000002D; kDNSSDType_RRSIG = $0000002E; kDNSSDType_NSEC = $0000002F; kDNSSDType_DNSKEY = $00000030; kDNSSDType_DHCID = $00000031; kDNSSDType_NSEC3 = $00000032; kDNSSDType_NSEC3PARAM = $00000033; kDNSSDType_HIP = $00000037; kDNSSDType_SPF = $00000063; kDNSSDType_UINFO = $00000064; kDNSSDType_UID = $00000065; kDNSSDType_GID = $00000066; kDNSSDType_UNSPEC = $00000067; kDNSSDType_TKEY = $000000F9; kDNSSDType_TSIG = $000000FA; kDNSSDType_IXFR = $000000FB; kDNSSDType_AXFR = $000000FC; kDNSSDType_MAILB = $000000FD; kDNSSDType_MAILA = $000000FE; kDNSSDType_ANY = $000000FF; // Konstanten für enum DNSSDRRClass type DNSSDRRClass = TOleEnum; const kDNSSDClass_IN = $00000001; // Konstanten für enum DNSSDAddressFamily type DNSSDAddressFamily = TOleEnum; const kDNSSDAddressFamily_IPv4 = $00000001; kDNSSDAddressFamily_IPv6 = $00000002; // Konstanten für enum DNSSDProtocol type DNSSDProtocol = TOleEnum; const kDNSSDProtocol_UDP = $00000010; kDNSSDProtocol_TCP = $00000020; // Konstanten für enum DNSSDError type DNSSDError = TOleEnum; const kDNSSDError_NoError = $00000000; kDNSSDError_Unknown = $FFFEFFFF; kDNSSDError_NoSuchName = $FFFEFFFE; kDNSSDError_NoMemory = $FFFEFFFD; kDNSSDError_BadParam = $FFFEFFFC; kDNSSDError_BadReference = $FFFEFFFB; kDNSSDError_BadState = $FFFEFFFA; kDNSSDError_BadFlags = $FFFEFFF9; kDNSSDError_Unsupported = $FFFEFFF8; kDNSSDError_NotInitialized = $FFFEFFF7; kDNSSDError_AlreadyRegistered = $FFFEFFF5; kDNSSDError_NameConflict = $FFFEFFF4; kDNSSDError_Invalid = $FFFEFFF3; kDNSSDError_Firewall = $FFFEFFF2; kDNSSDError_Incompatible = $FFFEFFF1; kDNSSDError_BadInterfaceIndex = $FFFEFFF0; kDNSSDError_Refused = $FFFEFFEF; kDNSSDError_NoSuchRecord = $FFFEFFEE; kDNSSDError_NoAuth = $FFFEFFED; kDNSSDError_NoSuchKey = $FFFEFFEC; kDNSSDError_NATTraversal = $FFFEFFEB; kDNSSDError_DoubleNAT = $FFFEFFEA; kDNSSDError_BadTime = $FFFEFFE9; kDNSSDError_BadSig = $FFFEFFE8; kDNSSDError_BadKey = $FFFEFFE7; kDNSSDError_Transient = $FFFEFFE6; kDNSSDError_ServiceNotRunning = $FFFEFFE5; kDNSSDError_NATPortMappingUnsupported = $FFFEFFE4; kDNSSDError_NATPortMappingDisabled = $FFFEFFE3; kDNSSDError_NoRouter = $FFFEFFE2; kDNSSDError_PollingMode = $FFFEFFE1; type // *********************************************************************// // Forward-Deklaration von in der Typbibliothek definierten Typen // *********************************************************************// _IDNSSDEvents = dispinterface; IDNSSDService = interface; IDNSSDServiceDisp = dispinterface; IDNSSDEventManager = interface; IDNSSDEventManagerDisp = dispinterface; ITXTRecord = interface; ITXTRecordDisp = dispinterface; IDNSSDRecord = interface; IDNSSDRecordDisp = dispinterface; // *********************************************************************// // Deklaration von in der Typbibliothek definierten CoClasses // (HINWEIS: Hier wird jede CoClass ihrem Standard-Interface zugewiesen) // *********************************************************************// DNSSDService = IDNSSDService; TXTRecord = ITXTRecord; DNSSDRecord = IDNSSDRecord; DNSSDEventManager = IDNSSDEventManager; // *********************************************************************// // DispIntf: _IDNSSDEvents // Flags: (4096) Dispatchable // GUID: {21AE8D7F-D5FE-45CF-B632-CFA2C2C6B498} // *********************************************************************// _IDNSSDEvents = dispinterface ['{21AE8D7F-D5FE-45CF-B632-CFA2C2C6B498}'] procedure DomainFound(const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const domain: WideString); dispid 1; procedure DomainLost(const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const domain: WideString); dispid 2; procedure ServiceFound(const browser: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const serviceName: WideString; const regtype: WideString; const domain: WideString); dispid 3; procedure ServiceLost(const browser: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const serviceName: WideString; const regtype: WideString; const domain: WideString); dispid 4; procedure ServiceResolved(const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; const hostname: WideString; port: {??Word}OleVariant; const record_: ITXTRecord); dispid 5; procedure ServiceRegistered(const service: IDNSSDService; flags: DNSSDFlags; const name: WideString; const regtype: WideString; const domain: WideString); dispid 6; procedure QueryRecordAnswered(const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant; ttl: LongWord); dispid 7; procedure RecordRegistered(const record_: IDNSSDRecord; flags: DNSSDFlags); dispid 8; procedure AddressFound(const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const hostname: WideString; addressFamily: DNSSDAddressFamily; const address: WideString; ttl: LongWord); dispid 9; procedure MappingCreated(const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; externalAddress: LongWord; addressFamily: DNSSDAddressFamily; protocol: DNSSDProtocol; internalPort: {??Word}OleVariant; externalPort: {??Word}OleVariant; ttl: LongWord); dispid 10; procedure OperationFailed(const service: IDNSSDService; error: DNSSDError); dispid 11; end; // *********************************************************************// // Interface: IDNSSDService // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {29DE265F-8402-474F-833A-D4653B23458F} // *********************************************************************// IDNSSDService = interface(IDispatch) ['{29DE265F-8402-474F-833A-D4653B23458F}'] function EnumerateDomains(flags: DNSSDFlags; ifIndex: LongWord; const eventManager: IDNSSDEventManager): IDNSSDService; safecall; function Browse(flags: DNSSDFlags; interfaceIndex: LongWord; const regtype: WideString; const domain: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; safecall; function Resolve(flags: DNSSDFlags; ifIndex: LongWord; const serviceName: WideString; const regtype: WideString; const domain: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; safecall; function Register(flags: DNSSDFlags; ifIndex: LongWord; const name: WideString; const regtype: WideString; const domain: WideString; const host: WideString; port: Word; const record_: ITXTRecord; const eventManager: IDNSSDEventManager): IDNSSDService; safecall; function QueryRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; const eventManager: IDNSSDEventManager): IDNSSDService; safecall; function RegisterRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant; ttl: LongWord; const eventManager: IDNSSDEventManager): IDNSSDRecord; safecall; function AddRecord(flags: DNSSDFlags; rrtype: DNSSDRRType; rdata: OleVariant; ttl: LongWord): IDNSSDRecord; safecall; procedure ReconfirmRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant); safecall; procedure GetProperty(const prop: WideString; var value: OleVariant); safecall; function GetAddrInfo(flags: DNSSDFlags; ifIndex: LongWord; addressFamily: DNSSDAddressFamily; const hostname: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; safecall; function NATPortMappingCreate(flags: DNSSDFlags; ifIndex: LongWord; addressFamily: DNSSDAddressFamily; protocol: DNSSDProtocol; internalPort: Word; externalPort: Word; ttl: LongWord; const eventManager: IDNSSDEventManager): IDNSSDService; safecall; procedure Stop; safecall; end; // *********************************************************************// // DispIntf: IDNSSDServiceDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {29DE265F-8402-474F-833A-D4653B23458F} // *********************************************************************// IDNSSDServiceDisp = dispinterface ['{29DE265F-8402-474F-833A-D4653B23458F}'] function EnumerateDomains(flags: DNSSDFlags; ifIndex: LongWord; const eventManager: IDNSSDEventManager): IDNSSDService; dispid 1; function Browse(flags: DNSSDFlags; interfaceIndex: LongWord; const regtype: WideString; const domain: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; dispid 2; function Resolve(flags: DNSSDFlags; ifIndex: LongWord; const serviceName: WideString; const regtype: WideString; const domain: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; dispid 3; function Register(flags: DNSSDFlags; ifIndex: LongWord; const name: WideString; const regtype: WideString; const domain: WideString; const host: WideString; port: {??Word}OleVariant; const record_: ITXTRecord; const eventManager: IDNSSDEventManager): IDNSSDService; dispid 4; function QueryRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; const eventManager: IDNSSDEventManager): IDNSSDService; dispid 5; function RegisterRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant; ttl: LongWord; const eventManager: IDNSSDEventManager): IDNSSDRecord; dispid 6; function AddRecord(flags: DNSSDFlags; rrtype: DNSSDRRType; rdata: OleVariant; ttl: LongWord): IDNSSDRecord; dispid 7; procedure ReconfirmRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant); dispid 8; procedure GetProperty(const prop: WideString; var value: OleVariant); dispid 9; function GetAddrInfo(flags: DNSSDFlags; ifIndex: LongWord; addressFamily: DNSSDAddressFamily; const hostname: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; dispid 10; function NATPortMappingCreate(flags: DNSSDFlags; ifIndex: LongWord; addressFamily: DNSSDAddressFamily; protocol: DNSSDProtocol; internalPort: {??Word}OleVariant; externalPort: {??Word}OleVariant; ttl: LongWord; const eventManager: IDNSSDEventManager): IDNSSDService; dispid 11; procedure Stop; dispid 12; end; // *********************************************************************// // Interface: IDNSSDEventManager // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {7FD72324-63E1-45AD-B337-4D525BD98DAD} // *********************************************************************// IDNSSDEventManager = interface(IDispatch) ['{7FD72324-63E1-45AD-B337-4D525BD98DAD}'] end; // *********************************************************************// // DispIntf: IDNSSDEventManagerDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {7FD72324-63E1-45AD-B337-4D525BD98DAD} // *********************************************************************// IDNSSDEventManagerDisp = dispinterface ['{7FD72324-63E1-45AD-B337-4D525BD98DAD}'] end; // *********************************************************************// // Interface: ITXTRecord // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {8FA0889C-5973-4FC9-970B-EC15C925D0CE} // *********************************************************************// ITXTRecord = interface(IDispatch) ['{8FA0889C-5973-4FC9-970B-EC15C925D0CE}'] procedure SetValue(const key: WideString; value: OleVariant); safecall; procedure RemoveValue(const key: WideString); safecall; function ContainsKey(const key: WideString): WordBool; safecall; function GetValueForKey(const key: WideString): OleVariant; safecall; function GetCount: LongWord; safecall; function GetKeyAtIndex(index: LongWord): WideString; safecall; function GetValueAtIndex(index: LongWord): OleVariant; safecall; end; // *********************************************************************// // DispIntf: ITXTRecordDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {8FA0889C-5973-4FC9-970B-EC15C925D0CE} // *********************************************************************// ITXTRecordDisp = dispinterface ['{8FA0889C-5973-4FC9-970B-EC15C925D0CE}'] procedure SetValue(const key: WideString; value: OleVariant); dispid 1; procedure RemoveValue(const key: WideString); dispid 2; function ContainsKey(const key: WideString): WordBool; dispid 3; function GetValueForKey(const key: WideString): OleVariant; dispid 4; function GetCount: LongWord; dispid 5; function GetKeyAtIndex(index: LongWord): WideString; dispid 6; function GetValueAtIndex(index: LongWord): OleVariant; dispid 7; end; // *********************************************************************// // Interface: IDNSSDRecord // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {9CE603A0-3365-4DA0-86D1-3F780ECBA110} // *********************************************************************// IDNSSDRecord = interface(IDispatch) ['{9CE603A0-3365-4DA0-86D1-3F780ECBA110}'] procedure Update(flags: DNSSDFlags; rdata: OleVariant; ttl: LongWord); safecall; procedure Remove(flags: DNSSDFlags); safecall; end; // *********************************************************************// // DispIntf: IDNSSDRecordDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {9CE603A0-3365-4DA0-86D1-3F780ECBA110} // *********************************************************************// IDNSSDRecordDisp = dispinterface ['{9CE603A0-3365-4DA0-86D1-3F780ECBA110}'] procedure Update(flags: DNSSDFlags; rdata: OleVariant; ttl: LongWord); dispid 1; procedure Remove(flags: DNSSDFlags); dispid 2; end; // *********************************************************************// // Die Klasse CoDNSSDService stellt die Methoden Create und CreateRemote zur // Verfügung, um Instanzen des Standard-Interface IDNSSDService, dargestellt // von CoClass DNSSDService, zu erzeugen. Diese Funktionen können // von einem Client verwendet werden, der die CoClasses automatisieren // will, die von dieser Typbibliothek dargestellt werden. // *********************************************************************// CoDNSSDService = class class function Create: IDNSSDService; class function CreateRemote(const MachineName: string): IDNSSDService; end; // *********************************************************************// // OLE-Server-Proxy-Klassendeklaration // Server-Objekt : TDNSSDService // Hilfe-String : DNSSDService Class // Standard-Interface: IDNSSDService // Def. Intf. DISP? : No // Ereignis-Interface: // TypeFlags : (2) CanCreate // *********************************************************************// {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} TDNSSDServiceProperties= class; {$ENDIF} TDNSSDService = class(TOleServer) private FIntf: IDNSSDService; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps: TDNSSDServiceProperties; function GetServerProperties: TDNSSDServiceProperties; {$ENDIF} function GetDefaultInterface: IDNSSDService; protected procedure InitServerData; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Connect; override; procedure ConnectTo(svrIntf: IDNSSDService); procedure Disconnect; override; function EnumerateDomains(flags: DNSSDFlags; ifIndex: LongWord; const eventManager: IDNSSDEventManager): IDNSSDService; function Browse(flags: DNSSDFlags; interfaceIndex: LongWord; const regtype: WideString; const domain: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; function Resolve(flags: DNSSDFlags; ifIndex: LongWord; const serviceName: WideString; const regtype: WideString; const domain: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; function Register(flags: DNSSDFlags; ifIndex: LongWord; const name: WideString; const regtype: WideString; const domain: WideString; const host: WideString; port: Word; const record_: ITXTRecord; const eventManager: IDNSSDEventManager): IDNSSDService; function QueryRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; const eventManager: IDNSSDEventManager): IDNSSDService; function RegisterRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant; ttl: LongWord; const eventManager: IDNSSDEventManager): IDNSSDRecord; function AddRecord(flags: DNSSDFlags; rrtype: DNSSDRRType; rdata: OleVariant; ttl: LongWord): IDNSSDRecord; procedure ReconfirmRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant); procedure GetProperty(const prop: WideString; var value: OleVariant); function GetAddrInfo(flags: DNSSDFlags; ifIndex: LongWord; addressFamily: DNSSDAddressFamily; const hostname: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; function NATPortMappingCreate(flags: DNSSDFlags; ifIndex: LongWord; addressFamily: DNSSDAddressFamily; protocol: DNSSDProtocol; internalPort: Word; externalPort: Word; ttl: LongWord; const eventManager: IDNSSDEventManager): IDNSSDService; procedure Stop; property DefaultInterface: IDNSSDService read GetDefaultInterface; published {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} property Server: TDNSSDServiceProperties read GetServerProperties; {$ENDIF} end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} // *********************************************************************// // OLE-Server-Eigenschaften-Proxy-Klasse // Server-Objekt : TDNSSDService // (Dieses Objekt wird vom Eigenschaftsinspektor der IDE verwendet, // um die Eigenschaften dieses Servers zu bearbeiten) // *********************************************************************// TDNSSDServiceProperties = class(TPersistent) private FServer: TDNSSDService; function GetDefaultInterface: IDNSSDService; constructor Create(AServer: TDNSSDService); protected public property DefaultInterface: IDNSSDService read GetDefaultInterface; published end; {$ENDIF} // *********************************************************************// // Die Klasse CoTXTRecord stellt die Methoden Create und CreateRemote zur // Verfügung, um Instanzen des Standard-Interface ITXTRecord, dargestellt // von CoClass TXTRecord, zu erzeugen. Diese Funktionen können // von einem Client verwendet werden, der die CoClasses automatisieren // will, die von dieser Typbibliothek dargestellt werden. // *********************************************************************// CoTXTRecord = class class function Create: ITXTRecord; class function CreateRemote(const MachineName: string): ITXTRecord; end; // *********************************************************************// // OLE-Server-Proxy-Klassendeklaration // Server-Objekt : TTXTRecord // Hilfe-String : TXTRecord Class // Standard-Interface: ITXTRecord // Def. Intf. DISP? : No // Ereignis-Interface: // TypeFlags : (2) CanCreate // *********************************************************************// {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} TTXTRecordProperties= class; {$ENDIF} TTXTRecord = class(TOleServer) private FIntf: ITXTRecord; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps: TTXTRecordProperties; function GetServerProperties: TTXTRecordProperties; {$ENDIF} function GetDefaultInterface: ITXTRecord; protected procedure InitServerData; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Connect; override; procedure ConnectTo(svrIntf: ITXTRecord); procedure Disconnect; override; procedure SetValue(const key: WideString; value: OleVariant); procedure RemoveValue(const key: WideString); function ContainsKey(const key: WideString): WordBool; function GetValueForKey(const key: WideString): OleVariant; function GetCount: LongWord; function GetKeyAtIndex(index: LongWord): WideString; function GetValueAtIndex(index: LongWord): OleVariant; property DefaultInterface: ITXTRecord read GetDefaultInterface; published {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} property Server: TTXTRecordProperties read GetServerProperties; {$ENDIF} end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} // *********************************************************************// // OLE-Server-Eigenschaften-Proxy-Klasse // Server-Objekt : TTXTRecord // (Dieses Objekt wird vom Eigenschaftsinspektor der IDE verwendet, // um die Eigenschaften dieses Servers zu bearbeiten) // *********************************************************************// TTXTRecordProperties = class(TPersistent) private FServer: TTXTRecord; function GetDefaultInterface: ITXTRecord; constructor Create(AServer: TTXTRecord); protected public property DefaultInterface: ITXTRecord read GetDefaultInterface; published end; {$ENDIF} // *********************************************************************// // Die Klasse CoDNSSDRecord stellt die Methoden Create und CreateRemote zur // Verfügung, um Instanzen des Standard-Interface IDNSSDRecord, dargestellt // von CoClass DNSSDRecord, zu erzeugen. Diese Funktionen können // von einem Client verwendet werden, der die CoClasses automatisieren // will, die von dieser Typbibliothek dargestellt werden. // *********************************************************************// CoDNSSDRecord = class class function Create: IDNSSDRecord; class function CreateRemote(const MachineName: string): IDNSSDRecord; end; // *********************************************************************// // OLE-Server-Proxy-Klassendeklaration // Server-Objekt : TDNSSDRecord // Hilfe-String : DNSSDRecord Class // Standard-Interface: IDNSSDRecord // Def. Intf. DISP? : No // Ereignis-Interface: // TypeFlags : (2) CanCreate // *********************************************************************// {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} TDNSSDRecordProperties= class; {$ENDIF} TDNSSDRecord = class(TOleServer) private FIntf: IDNSSDRecord; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps: TDNSSDRecordProperties; function GetServerProperties: TDNSSDRecordProperties; {$ENDIF} function GetDefaultInterface: IDNSSDRecord; protected procedure InitServerData; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Connect; override; procedure ConnectTo(svrIntf: IDNSSDRecord); procedure Disconnect; override; procedure Update(flags: DNSSDFlags; rdata: OleVariant; ttl: LongWord); procedure Remove(flags: DNSSDFlags); property DefaultInterface: IDNSSDRecord read GetDefaultInterface; published {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} property Server: TDNSSDRecordProperties read GetServerProperties; {$ENDIF} end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} // *********************************************************************// // OLE-Server-Eigenschaften-Proxy-Klasse // Server-Objekt : TDNSSDRecord // (Dieses Objekt wird vom Eigenschaftsinspektor der IDE verwendet, // um die Eigenschaften dieses Servers zu bearbeiten) // *********************************************************************// TDNSSDRecordProperties = class(TPersistent) private FServer: TDNSSDRecord; function GetDefaultInterface: IDNSSDRecord; constructor Create(AServer: TDNSSDRecord); protected public property DefaultInterface: IDNSSDRecord read GetDefaultInterface; published end; {$ENDIF} // *********************************************************************// // Die Klasse CoDNSSDEventManager stellt die Methoden Create und CreateRemote zur // Verfügung, um Instanzen des Standard-Interface IDNSSDEventManager, dargestellt // von CoClass DNSSDEventManager, zu erzeugen. Diese Funktionen können // von einem Client verwendet werden, der die CoClasses automatisieren // will, die von dieser Typbibliothek dargestellt werden. // *********************************************************************// CoDNSSDEventManager = class class function Create: IDNSSDEventManager; class function CreateRemote(const MachineName: string): IDNSSDEventManager; end; TDNSSDEventManagerDomainFound = procedure(ASender: TObject; const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const domain: WideString) of object; TDNSSDEventManagerDomainLost = procedure(ASender: TObject; const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const domain: WideString) of object; TDNSSDEventManagerServiceFound = procedure(ASender: TObject; const browser: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const serviceName: WideString; const regtype: WideString; const domain: WideString) of object; TDNSSDEventManagerServiceLost = procedure(ASender: TObject; const browser: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const serviceName: WideString; const regtype: WideString; const domain: WideString) of object; TDNSSDEventManagerServiceResolved = procedure(ASender: TObject; const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; const hostname: WideString; port: {??Word}OleVariant; const record_: ITXTRecord) of object; TDNSSDEventManagerServiceRegistered = procedure(ASender: TObject; const service: IDNSSDService; flags: DNSSDFlags; const name: WideString; const regtype: WideString; const domain: WideString) of object; TDNSSDEventManagerQueryRecordAnswered = procedure(ASender: TObject; const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant; ttl: LongWord) of object; TDNSSDEventManagerRecordRegistered = procedure(ASender: TObject; const record_: IDNSSDRecord; flags: DNSSDFlags) of object; TDNSSDEventManagerAddressFound = procedure(ASender: TObject; const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; const hostname: WideString; addressFamily: DNSSDAddressFamily; const address: WideString; ttl: LongWord) of object; TDNSSDEventManagerMappingCreated = procedure(ASender: TObject; const service: IDNSSDService; flags: DNSSDFlags; ifIndex: LongWord; externalAddress: LongWord; addressFamily: DNSSDAddressFamily; protocol: DNSSDProtocol; internalPort: {??Word}OleVariant; externalPort: {??Word}OleVariant; ttl: LongWord) of object; TDNSSDEventManagerOperationFailed = procedure(ASender: TObject; const service: IDNSSDService; error: DNSSDError) of object; // *********************************************************************// // OLE-Server-Proxy-Klassendeklaration // Server-Objekt : TDNSSDEventManager // Hilfe-String : DNSSDEventManager Class // Standard-Interface: IDNSSDEventManager // Def. Intf. DISP? : No // Ereignis-Interface: _IDNSSDEvents // TypeFlags : (2) CanCreate // *********************************************************************// {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} TDNSSDEventManagerProperties= class; {$ENDIF} TDNSSDEventManager = class(TOleServer) private FOnDomainFound: TDNSSDEventManagerDomainFound; FOnDomainLost: TDNSSDEventManagerDomainLost; FOnServiceFound: TDNSSDEventManagerServiceFound; FOnServiceLost: TDNSSDEventManagerServiceLost; FOnServiceResolved: TDNSSDEventManagerServiceResolved; FOnServiceRegistered: TDNSSDEventManagerServiceRegistered; FOnQueryRecordAnswered: TDNSSDEventManagerQueryRecordAnswered; FOnRecordRegistered: TDNSSDEventManagerRecordRegistered; FOnAddressFound: TDNSSDEventManagerAddressFound; FOnMappingCreated: TDNSSDEventManagerMappingCreated; FOnOperationFailed: TDNSSDEventManagerOperationFailed; FIntf: IDNSSDEventManager; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps: TDNSSDEventManagerProperties; function GetServerProperties: TDNSSDEventManagerProperties; {$ENDIF} function GetDefaultInterface: IDNSSDEventManager; protected procedure InitServerData; override; procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Connect; override; procedure ConnectTo(svrIntf: IDNSSDEventManager); procedure Disconnect; override; property DefaultInterface: IDNSSDEventManager read GetDefaultInterface; published {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} property Server: TDNSSDEventManagerProperties read GetServerProperties; {$ENDIF} property OnDomainFound: TDNSSDEventManagerDomainFound read FOnDomainFound write FOnDomainFound; property OnDomainLost: TDNSSDEventManagerDomainLost read FOnDomainLost write FOnDomainLost; property OnServiceFound: TDNSSDEventManagerServiceFound read FOnServiceFound write FOnServiceFound; property OnServiceLost: TDNSSDEventManagerServiceLost read FOnServiceLost write FOnServiceLost; property OnServiceResolved: TDNSSDEventManagerServiceResolved read FOnServiceResolved write FOnServiceResolved; property OnServiceRegistered: TDNSSDEventManagerServiceRegistered read FOnServiceRegistered write FOnServiceRegistered; property OnQueryRecordAnswered: TDNSSDEventManagerQueryRecordAnswered read FOnQueryRecordAnswered write FOnQueryRecordAnswered; property OnRecordRegistered: TDNSSDEventManagerRecordRegistered read FOnRecordRegistered write FOnRecordRegistered; property OnAddressFound: TDNSSDEventManagerAddressFound read FOnAddressFound write FOnAddressFound; property OnMappingCreated: TDNSSDEventManagerMappingCreated read FOnMappingCreated write FOnMappingCreated; property OnOperationFailed: TDNSSDEventManagerOperationFailed read FOnOperationFailed write FOnOperationFailed; end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} // *********************************************************************// // OLE-Server-Eigenschaften-Proxy-Klasse // Server-Objekt : TDNSSDEventManager // (Dieses Objekt wird vom Eigenschaftsinspektor der IDE verwendet, // um die Eigenschaften dieses Servers zu bearbeiten) // *********************************************************************// TDNSSDEventManagerProperties = class(TPersistent) private FServer: TDNSSDEventManager; function GetDefaultInterface: IDNSSDEventManager; constructor Create(AServer: TDNSSDEventManager); protected public property DefaultInterface: IDNSSDEventManager read GetDefaultInterface; published end; {$ENDIF} procedure Register; resourcestring dtlServerPage = 'ActiveX'; dtlOcxPage = 'ActiveX'; implementation uses ComObj; class function CoDNSSDService.Create: IDNSSDService; begin Result := CreateComObject(CLASS_DNSSDService) as IDNSSDService; end; class function CoDNSSDService.CreateRemote(const MachineName: string): IDNSSDService; begin Result := CreateRemoteComObject(MachineName, CLASS_DNSSDService) as IDNSSDService; end; procedure TDNSSDService.InitServerData; const CServerData: TServerData = ( ClassID: '{24CD4DE9-FF84-4701-9DC1-9B69E0D1090A}'; IntfIID: '{29DE265F-8402-474F-833A-D4653B23458F}'; EventIID: ''; LicenseKey: nil; Version: 500); begin ServerData := @CServerData; end; procedure TDNSSDService.Connect; var punk: IUnknown; begin if FIntf = nil then begin punk := GetServer; Fintf:= punk as IDNSSDService; end; end; procedure TDNSSDService.ConnectTo(svrIntf: IDNSSDService); begin Disconnect; FIntf := svrIntf; end; procedure TDNSSDService.DisConnect; begin if Fintf <> nil then begin FIntf := nil; end; end; function TDNSSDService.GetDefaultInterface: IDNSSDService; begin if FIntf = nil then Connect; Assert(FIntf <> nil, 'DefaultInterface ist NULL. Die Komponente ist nicht mit dem Server verbunden. Sie müssen vor dieser Operation "Connect" oder "ConnectTo" aufrufen'); Result := FIntf; end; constructor TDNSSDService.Create(AOwner: TComponent); begin inherited Create(AOwner); {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps := TDNSSDServiceProperties.Create(Self); {$ENDIF} end; destructor TDNSSDService.Destroy; begin {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps.Free; {$ENDIF} inherited Destroy; end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} function TDNSSDService.GetServerProperties: TDNSSDServiceProperties; begin Result := FProps; end; {$ENDIF} function TDNSSDService.EnumerateDomains(flags: DNSSDFlags; ifIndex: LongWord; const eventManager: IDNSSDEventManager): IDNSSDService; begin Result := DefaultInterface.EnumerateDomains(flags, ifIndex, eventManager); end; function TDNSSDService.Browse(flags: DNSSDFlags; interfaceIndex: LongWord; const regtype: WideString; const domain: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; begin Result := DefaultInterface.Browse(flags, interfaceIndex, regtype, domain, eventManager); end; function TDNSSDService.Resolve(flags: DNSSDFlags; ifIndex: LongWord; const serviceName: WideString; const regtype: WideString; const domain: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; begin Result := DefaultInterface.Resolve(flags, ifIndex, serviceName, regtype, domain, eventManager); end; function TDNSSDService.Register(flags: DNSSDFlags; ifIndex: LongWord; const name: WideString; const regtype: WideString; const domain: WideString; const host: WideString; port: Word; const record_: ITXTRecord; const eventManager: IDNSSDEventManager): IDNSSDService; begin Result := DefaultInterface.Register(flags, ifIndex, name, regtype, domain, host, port, record_, eventManager); end; function TDNSSDService.QueryRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; const eventManager: IDNSSDEventManager): IDNSSDService; begin Result := DefaultInterface.QueryRecord(flags, ifIndex, fullname, rrtype, rrclass, eventManager); end; function TDNSSDService.RegisterRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant; ttl: LongWord; const eventManager: IDNSSDEventManager): IDNSSDRecord; begin Result := DefaultInterface.RegisterRecord(flags, ifIndex, fullname, rrtype, rrclass, rdata, ttl, eventManager); end; function TDNSSDService.AddRecord(flags: DNSSDFlags; rrtype: DNSSDRRType; rdata: OleVariant; ttl: LongWord): IDNSSDRecord; begin Result := DefaultInterface.AddRecord(flags, rrtype, rdata, ttl); end; procedure TDNSSDService.ReconfirmRecord(flags: DNSSDFlags; ifIndex: LongWord; const fullname: WideString; rrtype: DNSSDRRType; rrclass: DNSSDRRClass; rdata: OleVariant); begin DefaultInterface.ReconfirmRecord(flags, ifIndex, fullname, rrtype, rrclass, rdata); end; procedure TDNSSDService.GetProperty(const prop: WideString; var value: OleVariant); begin DefaultInterface.GetProperty(prop, value); end; function TDNSSDService.GetAddrInfo(flags: DNSSDFlags; ifIndex: LongWord; addressFamily: DNSSDAddressFamily; const hostname: WideString; const eventManager: IDNSSDEventManager): IDNSSDService; begin Result := DefaultInterface.GetAddrInfo(flags, ifIndex, addressFamily, hostname, eventManager); end; function TDNSSDService.NATPortMappingCreate(flags: DNSSDFlags; ifIndex: LongWord; addressFamily: DNSSDAddressFamily; protocol: DNSSDProtocol; internalPort: Word; externalPort: Word; ttl: LongWord; const eventManager: IDNSSDEventManager): IDNSSDService; begin Result := DefaultInterface.NATPortMappingCreate(flags, ifIndex, addressFamily, protocol, internalPort, externalPort, ttl, eventManager); end; procedure TDNSSDService.Stop; begin DefaultInterface.Stop; end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} constructor TDNSSDServiceProperties.Create(AServer: TDNSSDService); begin inherited Create; FServer := AServer; end; function TDNSSDServiceProperties.GetDefaultInterface: IDNSSDService; begin Result := FServer.DefaultInterface; end; {$ENDIF} class function CoTXTRecord.Create: ITXTRecord; begin Result := CreateComObject(CLASS_TXTRecord) as ITXTRecord; end; class function CoTXTRecord.CreateRemote(const MachineName: string): ITXTRecord; begin Result := CreateRemoteComObject(MachineName, CLASS_TXTRecord) as ITXTRecord; end; procedure TTXTRecord.InitServerData; const CServerData: TServerData = ( ClassID: '{AFEE063C-05BA-4248-A26E-168477F49734}'; IntfIID: '{8FA0889C-5973-4FC9-970B-EC15C925D0CE}'; EventIID: ''; LicenseKey: nil; Version: 500); begin ServerData := @CServerData; end; procedure TTXTRecord.Connect; var punk: IUnknown; begin if FIntf = nil then begin punk := GetServer; Fintf:= punk as ITXTRecord; end; end; procedure TTXTRecord.ConnectTo(svrIntf: ITXTRecord); begin Disconnect; FIntf := svrIntf; end; procedure TTXTRecord.DisConnect; begin if Fintf <> nil then begin FIntf := nil; end; end; function TTXTRecord.GetDefaultInterface: ITXTRecord; begin if FIntf = nil then Connect; Assert(FIntf <> nil, 'DefaultInterface ist NULL. Die Komponente ist nicht mit dem Server verbunden. Sie müssen vor dieser Operation "Connect" oder "ConnectTo" aufrufen'); Result := FIntf; end; constructor TTXTRecord.Create(AOwner: TComponent); begin inherited Create(AOwner); {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps := TTXTRecordProperties.Create(Self); {$ENDIF} end; destructor TTXTRecord.Destroy; begin {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps.Free; {$ENDIF} inherited Destroy; end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} function TTXTRecord.GetServerProperties: TTXTRecordProperties; begin Result := FProps; end; {$ENDIF} procedure TTXTRecord.SetValue(const key: WideString; value: OleVariant); begin DefaultInterface.SetValue(key, value); end; procedure TTXTRecord.RemoveValue(const key: WideString); begin DefaultInterface.RemoveValue(key); end; function TTXTRecord.ContainsKey(const key: WideString): WordBool; begin Result := DefaultInterface.ContainsKey(key); end; function TTXTRecord.GetValueForKey(const key: WideString): OleVariant; begin Result := DefaultInterface.GetValueForKey(key); end; function TTXTRecord.GetCount: LongWord; begin Result := DefaultInterface.GetCount; end; function TTXTRecord.GetKeyAtIndex(index: LongWord): WideString; begin Result := DefaultInterface.GetKeyAtIndex(index); end; function TTXTRecord.GetValueAtIndex(index: LongWord): OleVariant; begin Result := DefaultInterface.GetValueAtIndex(index); end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} constructor TTXTRecordProperties.Create(AServer: TTXTRecord); begin inherited Create; FServer := AServer; end; function TTXTRecordProperties.GetDefaultInterface: ITXTRecord; begin Result := FServer.DefaultInterface; end; {$ENDIF} class function CoDNSSDRecord.Create: IDNSSDRecord; begin Result := CreateComObject(CLASS_DNSSDRecord) as IDNSSDRecord; end; class function CoDNSSDRecord.CreateRemote(const MachineName: string): IDNSSDRecord; begin Result := CreateRemoteComObject(MachineName, CLASS_DNSSDRecord) as IDNSSDRecord; end; procedure TDNSSDRecord.InitServerData; const CServerData: TServerData = ( ClassID: '{5E93C5A9-7516-4259-A67B-41A656F6E01C}'; IntfIID: '{9CE603A0-3365-4DA0-86D1-3F780ECBA110}'; EventIID: ''; LicenseKey: nil; Version: 500); begin ServerData := @CServerData; end; procedure TDNSSDRecord.Connect; var punk: IUnknown; begin if FIntf = nil then begin punk := GetServer; Fintf:= punk as IDNSSDRecord; end; end; procedure TDNSSDRecord.ConnectTo(svrIntf: IDNSSDRecord); begin Disconnect; FIntf := svrIntf; end; procedure TDNSSDRecord.DisConnect; begin if Fintf <> nil then begin FIntf := nil; end; end; function TDNSSDRecord.GetDefaultInterface: IDNSSDRecord; begin if FIntf = nil then Connect; Assert(FIntf <> nil, 'DefaultInterface ist NULL. Die Komponente ist nicht mit dem Server verbunden. Sie müssen vor dieser Operation "Connect" oder "ConnectTo" aufrufen'); Result := FIntf; end; constructor TDNSSDRecord.Create(AOwner: TComponent); begin inherited Create(AOwner); {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps := TDNSSDRecordProperties.Create(Self); {$ENDIF} end; destructor TDNSSDRecord.Destroy; begin {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps.Free; {$ENDIF} inherited Destroy; end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} function TDNSSDRecord.GetServerProperties: TDNSSDRecordProperties; begin Result := FProps; end; {$ENDIF} procedure TDNSSDRecord.Update(flags: DNSSDFlags; rdata: OleVariant; ttl: LongWord); begin DefaultInterface.Update(flags, rdata, ttl); end; procedure TDNSSDRecord.Remove(flags: DNSSDFlags); begin DefaultInterface.Remove(flags); end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} constructor TDNSSDRecordProperties.Create(AServer: TDNSSDRecord); begin inherited Create; FServer := AServer; end; function TDNSSDRecordProperties.GetDefaultInterface: IDNSSDRecord; begin Result := FServer.DefaultInterface; end; {$ENDIF} class function CoDNSSDEventManager.Create: IDNSSDEventManager; begin Result := CreateComObject(CLASS_DNSSDEventManager) as IDNSSDEventManager; end; class function CoDNSSDEventManager.CreateRemote(const MachineName: string): IDNSSDEventManager; begin Result := CreateRemoteComObject(MachineName, CLASS_DNSSDEventManager) as IDNSSDEventManager; end; procedure TDNSSDEventManager.InitServerData; const CServerData: TServerData = ( ClassID: '{BEEB932A-8D4A-4619-AEFE-A836F988B221}'; IntfIID: '{7FD72324-63E1-45AD-B337-4D525BD98DAD}'; EventIID: '{21AE8D7F-D5FE-45CF-B632-CFA2C2C6B498}'; LicenseKey: nil; Version: 500); begin ServerData := @CServerData; end; procedure TDNSSDEventManager.Connect; var punk: IUnknown; begin if FIntf = nil then begin punk := GetServer; ConnectEvents(punk); Fintf:= punk as IDNSSDEventManager; end; end; procedure TDNSSDEventManager.ConnectTo(svrIntf: IDNSSDEventManager); begin Disconnect; FIntf := svrIntf; ConnectEvents(FIntf); end; procedure TDNSSDEventManager.DisConnect; begin if Fintf <> nil then begin DisconnectEvents(FIntf); FIntf := nil; end; end; function TDNSSDEventManager.GetDefaultInterface: IDNSSDEventManager; begin if FIntf = nil then Connect; Assert(FIntf <> nil, 'DefaultInterface ist NULL. Die Komponente ist nicht mit dem Server verbunden. Sie müssen vor dieser Operation "Connect" oder "ConnectTo" aufrufen'); Result := FIntf; end; constructor TDNSSDEventManager.Create(AOwner: TComponent); begin inherited Create(AOwner); {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps := TDNSSDEventManagerProperties.Create(Self); {$ENDIF} end; destructor TDNSSDEventManager.Destroy; begin {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps.Free; {$ENDIF} inherited Destroy; end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} function TDNSSDEventManager.GetServerProperties: TDNSSDEventManagerProperties; begin Result := FProps; end; {$ENDIF} procedure TDNSSDEventManager.InvokeEvent(DispID: TDispID; var Params: TVariantArray); begin case DispID of -1: Exit; // DISPID_UNKNOWN 1: if Assigned(FOnDomainFound) then FOnDomainFound(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {LongWord}, Params[3] {const WideString}); 2: if Assigned(FOnDomainLost) then FOnDomainLost(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {LongWord}, Params[3] {const WideString}); 3: if Assigned(FOnServiceFound) then FOnServiceFound(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {LongWord}, Params[3] {const WideString}, Params[4] {const WideString}, Params[5] {const WideString}); 4: if Assigned(FOnServiceLost) then FOnServiceLost(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {LongWord}, Params[3] {const WideString}, Params[4] {const WideString}, Params[5] {const WideString}); 5: if Assigned(FOnServiceResolved) then FOnServiceResolved(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {LongWord}, Params[3] {const WideString}, Params[4] {const WideString}, Params[5] { ??Word OleVariant}, IUnknown(TVarData(Params[6]).VPointer) as ITXTRecord {const ITXTRecord}); 6: if Assigned(FOnServiceRegistered) then FOnServiceRegistered(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {const WideString}, Params[3] {const WideString}, Params[4] {const WideString}); 7: if Assigned(FOnQueryRecordAnswered) then FOnQueryRecordAnswered(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {LongWord}, Params[3] {const WideString}, Params[4] {DNSSDRRType}, Params[5] {DNSSDRRClass}, Params[6] {OleVariant}, Params[7] {LongWord}); 8: if Assigned(FOnRecordRegistered) then FOnRecordRegistered(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDRecord {const IDNSSDRecord}, Params[1] {DNSSDFlags}); 9: if Assigned(FOnAddressFound) then FOnAddressFound(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {LongWord}, Params[3] {const WideString}, Params[4] {DNSSDAddressFamily}, Params[5] {const WideString}, Params[6] {LongWord}); 10: if Assigned(FOnMappingCreated) then FOnMappingCreated(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDFlags}, Params[2] {LongWord}, Params[3] {LongWord}, Params[4] {DNSSDAddressFamily}, Params[5] {DNSSDProtocol}, Params[6] { ??Word OleVariant}, Params[7] { ??Word OleVariant}, Params[8] {LongWord}); 11: if Assigned(FOnOperationFailed) then FOnOperationFailed(Self, IUnknown(TVarData(Params[0]).VPointer) as IDNSSDService {const IDNSSDService}, Params[1] {DNSSDError}); end; {case DispID} end; {$IFDEF LIVE_SERVER_AT_DESIGN_TIME} constructor TDNSSDEventManagerProperties.Create(AServer: TDNSSDEventManager); begin inherited Create; FServer := AServer; end; function TDNSSDEventManagerProperties.GetDefaultInterface: IDNSSDEventManager; begin Result := FServer.DefaultInterface; end; {$ENDIF} procedure Register; begin RegisterComponents(dtlServerPage, [TDNSSDService, TTXTRecord, TDNSSDRecord, TDNSSDEventManager]); end; end.
Delphi 2010, Update 4 & 5
|
Zitat |
Registriert seit: 13. Jan 2004 Ort: Hamm(Westf) 1.929 Beiträge Delphi 12 Athens |
#2
Gibt es eine Lösung?
Ich überlege Bonjour/Zeroconf oder OpenSLP oder etwas proprietäres für eine Client-Server Anwendung zu nutzen. Es nervt den Support, daß alle Clients rekonfiguriert werden müssen, wenn der Server umzieht.
Andreas
Monads? Wtf are Monads? |
Zitat |
Registriert seit: 14. Apr 2008 3.006 Beiträge Delphi 2009 Professional |
#3
Gibt es eine Lösung?
Ich überlege Bonjour/Zeroconf oder OpenSLP oder etwas proprietäres für eine Client-Server Anwendung zu nutzen. Es nervt den Support, daß alle Clients rekonfiguriert werden müssen, wenn der Server umzieht. Um nach dem Aufspüren des Servers von ihm weitere Konfigurationsparameter abzurufen, wäre ein Webservice (z.B. JSON über HTTP) geeignet.
Michael Justin
|
Zitat |
Registriert seit: 13. Jan 2004 Ort: Hamm(Westf) 1.929 Beiträge Delphi 12 Athens |
#4
Gibt es eine Lösung?
Ich überlege Bonjour/Zeroconf oder OpenSLP oder etwas proprietäres für eine Client-Server Anwendung zu nutzen. Es nervt den Support, daß alle Clients rekonfiguriert werden müssen, wenn der Server umzieht. Um nach dem Aufspüren des Servers von ihm weitere Konfigurationsparameter abzurufen, wäre ein Webservice (z.B. JSON über HTTP) geeignet. Korrektur: Meintest du sowas hier? https://en.wikipedia.org/wiki/SRV_record das sieht gut aus oder?
Zitat:
SRV Records are also used by Outlook 2007, 2010 and Macintosh 10.6 mail to locate the Exchange Autodiscover service
Andreas
Monads? Wtf are Monads? Geändert von QuickAndDirty (23. Jul 2013 um 17:50 Uhr) |
Zitat |
Ansicht |
Linear-Darstellung |
Zur Hybrid-Darstellung wechseln |
Zur Baum-Darstellung wechseln |
ForumregelnEs ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus. Trackbacks are an
Pingbacks are an
Refbacks are aus
|
|
Nützliche Links |
Heutige Beiträge |
Sitemap |
Suchen |
Code-Library |
Wer ist online |
Alle Foren als gelesen markieren |
Gehe zu... |
LinkBack |
LinkBack URL |
About LinkBacks |