[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

C++ into Delphi

Posted on 2000-01-26
3
Medium Priority
?
1,029 Views
Last Modified: 2010-05-18
Is there anyone who can translate these C++ code into Delphi ?

BYTE *BuildCommandReply(int comid, int nReplyCode, char *svReply, int *pnReqLen)
{
      BYTE *buffer;
      struct bo_command_header *hdr;
      int buflen,nReplyLen;
      
      buflen=sizeof(struct bo_command_header) + sizeof(int);
      nReplyLen=0;
      if(svReply!=NULL) {
            nReplyLen = (lstrlen(svReply)+1);
            buflen += nReplyLen;
      }
      

      buffer=(BYTE *) malloc(buflen);
      if(buffer==NULL) {
            *pnReqLen=0;
            return NULL;
      }
      memset(buffer,0,buflen);

      hdr=(struct bo_command_header *)buffer;      

      hdr->cmdlen=buflen;
      hdr->comid=comid;
      hdr->command=-1;
      hdr->flags=CMDFLAG_REPLY;
      hdr->nArg1=nReplyCode;
      hdr->nArg2Len=nReplyLen;
      hdr->nArg3Len=0;
      if(svReply!=NULL) {
            lstrcpyn((char *)buffer+sizeof(struct bo_command_header),svReply,nReplyLen);
      }

      *pnReqLen=buflen;            
      return buffer;
}
0
Comment
Question by:zeko
  • 2
3 Comments
 
LVL 1

Expert Comment

by:AttarSoftware
ID: 2388423
type
  pByte = ^byte
  pLongint = ^longint ;
  pBo_Command_Header = ^tBo_Command_Header ;

function BuildCommandReply( comid, nReplyCode : longint ; svReply : pChar ; pnReqLen : pLongint ) : pByte ;
var
  buffer : pByte ;
  hdr : pBo_Command_Header ;
  buflen,nReplyLen : longint ;
begin
  buflen := sizeof( tBo_command_header ) + sizeof( longint ) ;
  nReplyLen := 0 ;
  if( svReply <> nil ) then
  begin
    nReplyLen := ( strlen( svReply ) + 1 ) ;
    Inc( bufLen, nReplyLen ) ;
  end ;

  buffer := allocMem( buflen ) ;
  if( buffer = nil ) then
  begin
    pnReqLen^ = 0 ;
    result := nil ;
    exit ;
  end ;

  FillChar( buffer^, buflen, #0 ) ;

  hdr := pBo_command_header( buffer ) ;

  hdr^.cmdlen := buflen;
  hdr^.comid := comid;
  hdr^.command := -1;
  hdr^.flags := CMDFLAG_REPLY;
  hdr^.nArg1 := nReplyCode;
  hdr^.nArg2Len := nReplyLen;
  hdr^.nArg3Len := 0;
  if( svReply <> nil ) then
    CopyMemory( pointer( longint( buffer ) + sizeof( tBo_command_header ) ), svReply, nReplyLen ) ;

  pnReqLen^ := buflen ;
  result := buffer ;
end ;

Or something like that (I havent tried compiling this as you ae missing the tBo_Command_Header structure...)

Good luck...

Tim :O)

PS:  Got to be worth 50 points at least?
0
 

Author Comment

by:zeko
ID: 2392192
Post me an answer, Attar Software .
0
 
LVL 1

Accepted Solution

by:
AttarSoftware earned 200 total points
ID: 2392325
Woohoo :)

Thanks :)

Tim.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question