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

后端 未结 4 759
忘了有多久
忘了有多久 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:10

    The answer to this is mind boggling. On the one hand I made a completely stupid, very simple mistake, but on the other hand it should never - as far as I can see - have worked in ANY version of Delphi!

    The problem was nothing what-so-ever to do with the Unicode/non-unicodeness of any strings, but was actually due to a type mismatch in the PORT parameter.

    I was passing in the result of ReverseBytes(Port) - that parameter expected a uint16_t, i.e. a Word value. My Port property was however declared (lazily) as an Integer!!

    Once I fixed this and had Port declared as a Word, it now works on both D2007- and D2009+ versions of Delphi.

    Very weird.

    I can only think that some other edge-case behaviour of the compiler that might have somehow affected this was changed when Unicode support was introduced.

提交回复
热议问题