Jump to content
Tuts 4 You

Need help with Delphi


T-rad

Recommended Posts

I started playing with Delphi again after a couple of years and now I am feeling dumb, really dumb. Is there a function in Delphi that reads an ascii string, say 54 2D 72 61 64 (T-rad) as 64 00 00 00 54 2D 72 61 (d...T-ra) string type

 

Thanks for any help

T-rad

Link to comment

I'm not sure if I understand you correctly. :)

Zero-terminated strings are "PChar" in Delphi. Or "PAnsiChar" in later versions. They have nothing in front of them.
Delphi strings have dword in front of them, telling string length (and some other stuff you don't care about). So, to get "64 00 00 00" in front of string, you just set it's length to 0x64.

Example code:

uses Windows, Classes, Sysutils;
var
   p : PAnsiChar;
   s : AnsiString;
begin
   p := 't-rad';       // 00413314  74 2D 72 61 64 00 00 00                          t-rad...
   s := p;             // 02230FC0  05 00 00 00 74 2D 72 61 64                       �...t-rad
   SetLength(s, 100);  // 022226A8  64 00 00 00 74 2D 72 61 64                       d...t-rad
end.

Is this what you needed?

 

Link to comment

thanks.. but I'm not sure i stated it correctly. the string is divided into DWORD's and looks to be reversed. If the string were in groups of four there would be no 0 bytes following the last char.

a longer example...."T-rad123456789" would look like this 38 39 00 00 34 35 36 37 64 31 32 33 54 2D 72 61 (89..4567d123T-ra) instead of this 74 2D 72 61 64 31 32 33 34 35 36 37 38 39 00 00 (T-rad123456789).

Hope this makes sense.

Thanks

Link to comment

Ok, that's something totally different, I misunderstood your question. :) 

I don't think there is a standard function for something like that.. In addition to that, it's quite uncommon to have 00 inside the strings. 

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...