ZeroConf/Bonjour Code that works in Delphi 7 not working in 2009

后端 未结 4 742
忘了有多久
忘了有多久 2020-12-19 17:16

I have the following declaration for DNSServiceRegister:

  function DNSServiceRegister
      (
      var sdRef: TDNSServiceRef;
      const flags: TDNSServic         


        
4条回答
  •  一向
    一向 (楼主)
    2020-12-19 18:04

    I can't find the declaration instruction for the vars "ServiceName" and "ServiceType" in your code sample.

    Assuming a String type (thus a unicode string), I guess (yes... no D2009 available to test this) lazy typecasting could be an issue:

    name  := ServiceName;
    

    Why not use the following?

    name  := PAnsiChar(AnsiString(ServiceName)) 
    

    Anyhow... just my 2 cts.

    BTW: I always use the pre defined "EmptyStr", "EmptyWideStr" ... so the test would look like:

    if (ServiceName <> EmptyStr) then
    

    which should be safe and avoid the confusion of types.

    On the other side, Delphi may interpret the '' as an ANSIChar like the following declaration do:

    const
      MyParagraphChar = '§';
    

    Not sure... I'm confused - should go home now ;)

提交回复
热议问题