Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8269379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:12:23+00:00 2026-06-08T06:12:23+00:00

I am having a problem acquiring the friendly name (dbcp_name) from DEV_BROADCAST_PORT using delphi.

  • 0

I am having a problem acquiring the friendly name (dbcp_name) from DEV_BROADCAST_PORT using delphi.

I have tried using the microsoft help documentation which says it is a pointer to a null terminated string, but on that page there is a comment which indicates it is a variable-length structure, and dbcp_name is an array that contains the actual characters of the port name.

I have tried to extract this but I currently have not found a way as when I get it to return anything it is complete gibberish.

The code I have used follows:

PDevBroadcastPort = ^DEV_BROADCAST_PORT;

DEV_BROADCAST_PORT = packed record
    dbcp_size : DWORD ;
    dbcp_devicetype : DWORD;
    dbcp_reserved : DWORD ;
    dbcp_name : array[0..0] of ansichar; //TCHAR dbcp_name[1]; not valid
end;

I have tried different values for the length of the array, I had read somewhere that this was the correct declaration but I am not entirely sure. Also the commented out line is what the microsoft document gives for the line in C++

To extract the information I have tried this:

var
  PData: PDevBroadcastPort;

  FName: string;

  ...

  PData := PDevBroadcastPort(Msg.lParam);

  ShowMessage('Length '+Inttostr(length(PData^.dbcp_name)));

  FName := '';

  i:=0;

  while((PData^.dbcp_name[i]) <> #0) and (i < 100) do
      begin
          FName := FName + (PData.dbcp_name[i]);

          i := i +1;

          ShowMessage(FName); 
      end;

I have tried setting the while loop to terminate at the length of the data structure but if I dont set it then it becomes huge.

Any help is appreciated and if I have left out any code which is needed for this question please let me know and I shall acquire it as soon as I can.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:12:26+00:00Added an answer on June 8, 2026 at 6:12 am

    The documentation doesn’t say it’s a pointer to a null-terminated string; it says it is a null-terminated string. That’s typical for arrays that are declared at the end of a record with a length of just one element.

    There’s actually more memory after the designated record size, and that memory holds the remaining characters of the string. A pointer to that record field is also a pointer to the character data.

    FName := PAnsiChar(@PData.dbcp_name);
    

    Your array-traversing code should work, too, assuming you have bounds checking disabled for that stretch of code (or else you’d get an exception when the program detected you reading beyond the first element of the array).

    That all presupposes that PData really is a pointer to a Dev_Broadcast_Port structure. You’ve given no information about what message you’re handing, so I don’t know whether you really have what you think you have.

    If you’re using Delphi 2009 or later, then the TCHAR type in the C declaration is equivalent to Delphi’s WideChar type. Interpreting the field as an array of AnsiChar will get you wrong results, although for most port names, it might appear as though the array is a list of null-terminated one-character strings. Unless you’re sure you have non-Unicode data, you should just use Char and PChar, and let the Delphi version determine which data type you have.

    FName := PChar(@PData.dbcp_name);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problem in using this font in my Application. I have imported
I having problem marshaling an iterator of objects using JAXB User class: @XmlRootElement(name=User) public
m having problem in operating on richtextbox from another class m using backgroundworker class
I'm having problem reading from a plist file I have the Settings.plist file saved
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working
I'm having problem with datagrid view. I have attached an image with the code
hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
m having problem in passing parameter to controller action, i have done the following
Hi I'm having problem refreshing my listview after Async operation. I have a simplecursoradapter,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.