Skip to content

Rationalise how TCPInfoEx is set and used #4

@delphidabbler

Description

@delphidabbler

Creation of required TCPInfoEx record could be rationalised.

There are numerous type names created as would be required if the the structure was a public API translation, but aren't used here.

Additionally, the ANSI and Unicode versions of TCPInfoEx are so similar that we can rely on compiler to compile correct version without explicit conditional compilation.

Here's what I suggest:

type
  TCPInfoEx = packed record
      // max length in bytes of a character in the code page
      MaxCharSize: UINT;
      // default character used to translate strings to the specific code page
      DefaultChar: array[0..MAX_DEFAULTCHAR-1] of Byte;
      // fixed-length array of lead byte ranges: all elements null if none
      LeadByte: array[0..MAX_LEADBYTES-1] of Byte;
      //  unicode default char used in translations from the specific code page
      UnicodeDefaultChar: WideChar;
      // code page value
      CodePage: UINT;
      // full localised name of the code page
      // - Char is automatically set to correct AnsiChar or WideChar by compiler
      // - depending on whether UNICODE is defined, so conditional 
      // - compilation isn't necessary
      CodePageName: array[0..MAX_PATH-1] of Char;
  end;

  PCPInfoEx = ^TCPInfoEx;  // *** only define this if strictly necessary 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions