Jump to content


Check out our Community Blogs

SirStorm25

Member Since 26 Aug 2008
Offline Last Active Dec 06 2008 07:54 AM
-----

Topics I've Started

Records and TStringLists?

30 November 2008 - 06:35 AM

Hi All!

How do I use Arrays with records? When I do the following:
[COLOR="Blue"]type
  aRecord = record
    arry: Array[0..9] of string[255];
  end;

var
  R: aRecord;
  F: File of aRecord;
  A: Array[0..9] of string[255];
begin
  A[0]:= 'Hello World!';
  R.Arry:= A;
  Assign(F, 'OutFile.dat');
  ReWrite(F);
  Write(F, R);
  Close(F);
end; [/COLOR]
However, it returns "Incompatible Types"???

Hope you can help!
Regards

Matt.

Parsing TStrings!

04 October 2008 - 01:38 PM

Hi All!

I was wondering if the below is possible:

When the user clicks the button, the program takes all the text from Memo1.Lines and for each new line (in delphi, #13+#10) and replaces all new lines (#13+#10) with \line .

I have tried using the tutorial available on delphi.about.com:

procedure ParseDelimited(const sl : TStrings; const value : string; const delimiter : string) ;
var
   dx : integer;
   ns : string;
   txt : string;
   delta : integer;
begin
   delta := Length(delimiter) ;
   txt := value + delimiter;
   sl.BeginUpdate;
   sl.Clear;
   try
     while Length(txt) > 0 do
     begin
       dx := Pos(delimiter, txt) ;
       ns := Copy(txt,0,dx-1) ;
       sl.Add(ns) ;
       txt := Copy(txt,dx+delta,MaxInt) ;
     end;
   finally
     sl.EndUpdate;
   end;
end;

but i'm no good with TStrings (confuses me ).

Any Ideas?

Regards
SirStorm25.

EXE File!

25 September 2008 - 10:26 AM

Hi all, i was wondering how I would achieve the below:

The user enters some text into a TEdit, then they click a button, when the button is clicked it creates a file (EXE) that when ran displays the text the user entered (Console App). Basically, like a small compiler that can only do the 1 thing.
I've heard about TImageFileHeader, but i've no idea how to use that to create a console app.

procedure TForm1.WritePEHeader(ProgName: string; MsgText: string);

const
  PESig: DWORD = $00004550;

  DOSStub: array[0..111] of Byte = (
    $4D, $5A, $6C, $00, $01, $00, $00, $00, $04, $00, $11, $00, $FF, $FF,
    $03, $00, $00, $01, $00, $00, $00, $00, $00, $00, $40, $00, $00, $00,
    $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
    $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
    $00, $00, $00, $00, $70, $00, $00, $00, $0E, $1F, $BA, $0E, $00, $B4,
    $09, $CD, $21, $B8, $00, $4C, $CD, $21, $54, $68, $69, $73, $20, $70,
    $72, $6F, $67, $72, $61, $6D, $20, $72, $65, $71, $75, $69, $72, $65,
    $73, $20, $57, $69, $6E, $33, $32, $0D, $0A, $24, $24, $41, $50, $24);

  IDataRVA = $1000;
  CodeRVA = $2000;
  BSSRVA = $3000;

var
  PEData: TImageFileHeader;

  F: File;
begin
  AssignFile(F, GetCurrentDir + '\output.exe');
  ReWrite(F);
  BlockWrite (F, DOSStub, SizeOf(DOSStub));

  BlockWrite (F, PESig, SizeOf(PESig));
  PEHeader.Machine:= $120;
  PEHeader.NumberOfSections:= $3;
  PEHeader.TimeDateStamp:= $340;
  PEHeader.Characteristics:= $3000;
  BlockWrite(F, PEData, SizeOf(PEData));
end;

But, I don't really know how to make it load as a console app and display the text, then pause.

Hope you can help!
SirStorm25.

File - to - String!

14 September 2008 - 01:45 AM

Hi All!
I was wondering if there was a way to load any kind of file (text or binary) into a string ( Delphi 2009 ), i've tried using the File2String function in ExeMod, however, Delphi 2009 doesn't seem to like it...

Reason: I'm trying to use the AddFile2Exe function in exemod, however, it doesn't seem to work. Ive found out it must be something to do with the File2String and delphi 2009's love of unicode :D...

Hope you can help!
Regards
SirStorm25

Small Question - Files and Folders!

26 August 2008 - 11:53 AM

Hi All!
I was wondering if anyone knew the code for the things below:

1. The user puts a folder into a TEdit (C:\Folder1\), then clicks a button, the program then saves a list of all files and folders included in the folder to a file e.g C:\File1.txt.

2. The user specifies a file made with the above, then tyhe program deletes the files and folders listed in the file.

Hope you can help!!
Regards

SirStorm25.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download