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 6079105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:54:32+00:00 2026-05-23T10:54:32+00:00

I’m converting this code from C++ to Delphi but I don’t get the following

  • 0

I’m converting this code from C++ to Delphi but I don’t get the following part of the code. Can anyone explain me what the following code means; what’s happening to the szBuff buffer ?

I’m pretty sure it’s such kind of formatting (replacement), but I don’t even know what is expected as a result and I can’t find any sensible documentation of the used functions (maybe I’m just a lame 🙂

Can anyone help me with the translation of this code to Delphi (or direct me to proper documentation) ?

I don’t like this how do you convert kind of questions by myself, so I mentioned at least function names in the question title so it might searchable to someone else in the future.

function TSecInfo.BuildSecurityAttributes(var SecAttrs: TSecurityAttributes): boolean;
var
  pszSidUser: PChar;
  szBuff: array [0..1024] of Char;
begin

// pszSidUser at this time contains user SID like this
// S-1-5-21-1454471165-1004336348-1606980848-5555

// TCHAR szBuff[1024]; // I'm not sure with array [0..1024] of Char;

  _tcscpy(szBuff, _T("D:"));
  _tcscat(szBuff, _T("(A;;GA;;;"));
  _tcscat(szBuff, pszSidUser);
  _tcscat(szBuff, _T(")"));
  _tcscat(szBuff, _T("(A;;GWGR;;;AN)"));
  _tcscat(szBuff, _T("(A;;GWGR;;;WD)"));

...

  _tcscat(szBuff, _T("S:(ML;;NW;;;S-1-16-0)"));

end;

For those who are interested in what’s the whole code from the link about I can tell it should be a trick how to access network pipes for writing as an anonymous user on Windows Vista above. To the whole article follow this link.

Thanks for your time
Regards

  • 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-05-23T10:54:32+00:00Added an answer on May 23, 2026 at 10:54 am

    _tcscpy and _tcscat are TCHAR macro versions of C standard library functions strcpy and strcat for copying and concatenating C strings. They evaluate to ANSI or Unicode versions depending on whether or the type of project you are targeting. It’s really C code rather than C++ code in my view.

    In Delphi you would simply use string variables like this:

    function TSecInfo.BuildSecurityAttributes(var SecAttrs: TSecurityAttributes): boolean;
    var
      pszSidUser: PChar;
      Buff: string;
    begin
      // pszSidUser at this time contains user SID like this
      // S-1-5-21-1454471165-1004336348-1606980848-5555
    
      Buff := 'D:(A;;GA;;;'+pszSidUser+')(A;;GWGR;;;AN)(A;;GWGR;;;WD)S:(ML;;NW;;;S-1-16-0)';
      SomeOtherWindowsAPICall(PChar(Buff));    
    end;
    

    Presumably in the C code there is a call to another Windows API function that receives an LPCTSTR. The C code will pass szBuff but you can simply pass PChar(Buff) as I have shown above.

    The C code is using a fixed length buffer because it doesn’t have available a dynamically allocated string class like Delphi’s string or std::string in C++. Fixed length buffers like this often lead to buffer overruns. In Delphi don’t use a fixed length buffer if you can avoid it.

    This is a classic example of why languages with built in string handling are so much easier to work with than C.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.