Solved

open a txt witn an app

Posted on 2000-05-05
9
144 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
  • 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 20 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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