?
Solved

open a txt witn an app

Posted on 2000-05-05
9
Medium Priority
?
148 Views
Last Modified: 2010-04-04
How to open for example a txt with an app in Delphi? I mean, you should right click with shift pressed on the txt and then choose open with... and then select my app in the list.

What source should this app contain?
Memo1.Lines.LoadFromFile(???);
0
Comment
Question by:Grayl1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 1

Expert Comment

by:Rheingold
ID: 2781568
Hi, if I understand you correct you want your app to be able to process text files that are loaded through the "open with" option of the Win Explorer? If so, you have to handle the Command Line the app gets. The API function is GetCommandLine. It should be something similar in Delphi. The first part of the string this API returns is the path and the filename of your EXE and the second part is path and filename of the TXT file. Just write a quick algo that extracts the second part. Send this part to LoadFromFile then.

Regards
0
 

Author Comment

by:Grayl1
ID: 2781793
Rheingold...

Yes, U has understood me right.
I'm a bit new to Delphi so if you could give me an example...
0
 

Author Comment

by:Grayl1
ID: 2781794
Rheingold...

Yes, U has understood me right.
I'm a bit new to Delphi so if you could give me an example...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:ms99
ID: 2782501
To understand what Rheingolg means just drop a label1 in your application and do this:

label1.caption := '>' + getCommandLine + '<';

Double click on a txt file and you will see something like:

>c:\project1.exe c:\myfile.txt<

Another way is:

memo1.loadFromFile(paramstr(1));

in order to load the file.
0
 

Accepted Solution

by:
ms99 earned 80 total points
ID: 2782505
Sorry:

it's not

memo1.loadFromFile(paramstr(1));

but

memo1.lines.loadFromFile(paramstr(1));

0
 
LVL 17

Expert Comment

by:inthe
ID: 2782554
hi,
GetCommandLine returns the commandline used to start program  ie: project1.exe/ns
example:
edit1.text:=strpas(GetCommandLine);

what your after for this is paramstr() like below:

procedure TForm1.FormCreate(Sender: TObject);
begin
try
memo1.lines.loadfromfile(ParamStr(1))
except
end;
end;
0
 
LVL 17

Expert Comment

by:inthe
ID: 2782556
oops shouldve pushed refresh first ;-)
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2782742
listenning
0
 

Author Comment

by:Grayl1
ID: 2783746
It works ;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 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