Help with Delphi.

Soldato
Joined
5 Jul 2003
Posts
16,206
Location
Atlanta, USA
Hi.
Im writing a program for my project that'll run some commands to run benchmarks on some applications.
What i want to do is once the application has closed, that my program copys the results file to a specific directory and then opens the directory.

Can anyone tell me or give me tips on how to do that please?
Thanks in advance all.
:)
 
Maybe something like this (what do you mean by "Open the directory"? Open it in explorer? That's what I've shown below):

Code:
uses ShellAPI;

var
  FailIfTargetExists : Boolean;
  ExistingFileName, NewFileName : String;
begin
  FailIfTargetExists := False; // or True if you prefer
  ExistingFileName := 'C:\source.txt';
  NewFileName := 'C:\target.txt';

  CopyFile(PAnsiChar(ExistingFileName), PAnsiChar(NewFileName), FailIfTargetExists);

  ShellExecute( 0, 'open', 'C:\', nil, nil, SW_SHOW );
  // or, to, to include the explorer directory tree
  //ShellExecute(handle, 'explore', 'C:\', nil, nil, SW_SHOW);
end;
 
So that'd go behind each button that requires it, with the paths in the command edited for each button as well?

Thanks for the reply bty.
Much appriciated.
:)
 
BoomAM said:
So that'd go behind each button that requires it, with the paths in the command edited for each button as well?

Thanks for the reply bty.
Much appriciated.
:)

Umm yeah, possibly. Though of course, ideally, you shouldn't just copy and paste the code into seperate event handlers for a bunch of buttons if the only difference is going to be the paths etc... It'd be better to try and eliminate the duplication somehow, perhaps by using an array of buttons/paths and having the handling routine determine which path is relevant from/by the button that sent/called the click message/method (again, please not with a if then elseif or case statement...)

HTH


HTH
 
Would it work behind each button though?

I dont really need it to be 'tidy' & efficient in all honesty.
I just need it to 'work', to show proof of concept for my project.
As long as the function works 'as advertised', i'll have enough to write about.
In a way, i suppose with it being 'untidy', it'll give me more to write about. :p

Thanks again bty. Much appriciated.
 
BoomAM said:
Would it work behind each button though?
Yeah that'd be the idea. ;) You need to try it out yourself and see if it does what you want.

BoomAM said:
I dont really need it to be 'tidy' & efficient in all honesty.
I just need it to 'work', to show proof of concept for my project.
As long as the function works 'as advertised', i'll have enough to write about.
In a way, i suppose with it being 'untidy', it'll give me more to write about. :p

OK fair enough, I guess if you're just mocking up something quick 'n dirty then it probably doesn't matter much what the code looks like... :)
 
Bit more help please. :)
Im just putting the finishing touches on my Project, and for the life of me, i cannot remember how i can get a txt file to display 'in' Delphi. So that it appears, scrollable, in a memo box or something similar.
Can someone point out the obvious thing that im forgetting to do (that i also supposidly learned in my first programming lecture 2 years ago! lol).

Thanks in advance all. :)
 
BoomAM said:
Bit more help please. :)
Im just putting the finishing touches on my Project, and for the life of me, i cannot remember how i can get a txt file to display 'in' Delphi. So that it appears, scrollable, in a memo box or something similar.
Can someone point out the obvious thing that im forgetting to do (that i also supposidly learned in my first programming lecture 2 years ago! lol).

Thanks in advance all. :)

If you investigate/look up the TMemo component in the help, you'll notice it keeps its contents in the TStrings object (essentially a list/array of strings.) If you then look up the TStrings component you'll notice it has LoadFromFile() and SaveToFile() methods. Ergo:

Code:
Memo.Lines.LoadFromFile('c:\blah.txt');

(Aside: If you type "LoadFromFile" into the Delphi editor, and press F1 while the cursor is on the word, the help system will list all the classes that contain a LoadFromFile method.)

HTH
 
Thanks.
Right. Got my program completely working. Apart from one thing.

Is there a way i can have my program run completely off a CD?
The program itself makes calls out to several txt files, and a few other smaller programs.
Is there a way for me to plonk all of the files it uses on a CD and have it access it all from there, in the same location as itself?

Thanks in advance. :)
 
Easy, just have all the files in the same folder as your apps exe and make sure the app does not have a path to reference the files. I take it you do not need to write to any of these files?
 
No writing too.
So.
Rarther than the paths being, for example c:\blah\blah.txt, it'd just be 'blah.txt'?
 
Back
Top Bottom