Hi.
I have the following code in a Delphi DLL which is working and shall be ported to C(++) - it is important that the DLL can deal with the IStream refernce.
unit T_D2007_Impl;
interface
uses
ActiveX,
StrUtils,
SysUtils,
Classes,
Math;
type
TPFLog = procedure(AMsg: PAnsiChar; ASeverity: Integer) of object; stdcall;
var
BYTESRETURNED, BYTESTRANSFORMED: Integer;
BYTESLASTREAD: PLongInt;
DLIBMOVE: Int64;
STREAMSTAT: tagSTATSTG;
INSTREAM: IStream;
LOG: TPluginFrameworkLog;
implementation
// Helpers ...
function StreamToString(AStream: IStream): AnsiString;
var
len: Int64;
s: AnsiString;
currentposinstream: Int64;
begin
[login to view URL](STREAMSTAT, STATFLAG_DEFAULT);
DLIBMOVE := 0;
[login to view URL](DLIBMOVE, STREAM_SEEK_CUR, currentposinstream);
len := [login to view URL] - currentposinstream;
SetLength(s, len);
if len > 0 then
[login to view URL](Pointer(s), len, BYTESLASTREAD);
Result := s;
end;
// end of helpers
function AddLoggingCallBack(ALoggingFunction: TPFLog): Boolean;
begin
try
LOG := ALoggingFunction;
Result := true;
except
Result := false;
end;
end;
function SetInStream(const APointerToTheInStream: Pointer): Boolean; export;
begin
try
INSTREAM := IStream(APointerToTheInStream);
Result := true;
except
Result := false;
end;
end;
procedure UpdateStreamStats();
begin
DLIBMOVE := 0;
[login to view URL](STREAMSTAT, STATFLAG_NONAME);
end;
function Read(var Buffer; Count: Longint): Longint; export;
var
len: Int64;
instring2, sizestring, posstring, logstring: AnsiString;
pc: PAnsiChar;
begin
UpdateStreamStats;
len := [login to view URL] - BYTESTRANSFORMED;
if len > 0 then
begin
sizestring := IntToStr([login to view URL]);
posstring := IntToStr(BYTESTRANSFORMED);
logstring := 'Starting to read and transform instring ' + posstring + '/' +
sizestring + '.';;
LOG(PAnsiChar(logstring), 5);
instring2 := StreamToString(INSTREAM);
BYTESTRANSFORMED := Length(instring2);
instring2 := AnsiReplaceStr(instring2,
AnsiString('XXX' + #13 + #10),
AnsiString(''));
instring2 := AnsiReplaceStr(AnsiString(instring2), AnsiString('{'),
AnsiString('['));
instring2 := AnsiReplaceStr(AnsiString(instring2), AnsiString('}'),
AnsiString(']'));
pc := PAnsiChar(instring2);
Move(pc^, Buffer, Length(instring2));
Result := Length(instring2);
BYTESRETURNED := BYTESRETURNED + Result;
posstring := AnsiString(IntToStr(BYTESTRANSFORMED));
logstring := 'Finished to read and transform instring ' + sizestring + '/' +
posstring + '.';
LOG(PAnsiChar(logstring), 5);
end
else
Result := 0;
end;
// end of export functions
exports AddLoggingCallBack, SetInStream, Read;
begin
BYTESRETURNED := 0;
BYTESTRANSFORMED := 0;
byteslastread := nil;
DLIBMOVE := 0;
end.
Hello,
I have a lot of experience with both Delphi and C++, including COM/ActiveX technologies. I can translate your Delphi unit into clean and easy-to-read C or C++ code. You won't be disappointed.
Thank you.
$100 USD in 2 days
5.0 (32 reviews)
4.8
4.8
6 freelancers are bidding on average $141 USD for this job
Hi, I'm Delphi/C expert with years of experience in various areas including conversion to and from pascal. Can you tell me do you have some project that uses this dll that could be used to verify that converted dll is working fine?
Hello,
is this all code that needs to be converted?
My price is for the code that you had posted.
If there are more units I might have to increase my bid a little bit.
I am highly Expert in this field. I'll provide you satisfaction.
So your time and money will be safe when you will award me project thanks. let's discuss more
Hi.. I am Nikhil.
I have working experience of 3+ year in C and C++ Development.
I have done work on:
1. Data Structure like: Set, Vector, Linked list, Stack, Tree(Any type), Graph.
2. STL ( Standard Template Library)
3. Networking Socket, IO programming
4. File Handling and Parsing.
Currently I have done similar projects for collage students like:
1. Implemented Chess Class
2. Implemented Classes for hotel management.
I delivered him but Employer did not award me project. and Many more...
Let start conversation so you get to know about my skills and ability.
Please give me a chance to do work with you and I am promising you that you will not disappoint by me.
I read your description and understood your requirements. I am very sure that I will do this within 1 to 2 days.
I will write code with comments so you will understand it easily and I will also help you to solve any further query..
If you need any help after project then I will be here. Please give a chance to conversation with you.
I am waiting for your positive response.
Please initiate conversation at least.
Thank you Very much.
Nikhil