ActiveForm and read deployed files.

Hi all,
I want to deploy a ActiveForm and a file (textfile). Now I want to read the text file and show it in a memo field. How is the pathname to load the txt file.
Memo1.Lines.LoadFromFile('?');

Micha
PROGRAMMING030999Asked:
Who is Participating?
 
intheConnect With a Mentor Commented:
hi,
i found the proper method to get directory of activeform.
GetModuleFilename(HInstance, ModuleName, SizeOf(ModuleName)). ModuleName can be declared as an array [0..255] of Char.

0
 
rwilson032697Commented:
An easier way might be to load the file into the memo field at design time --> No need to deploy an additional file and no worries about where it is.

Cheers,

Raymond.

0
 
PROGRAMMING030999Author Commented:
Hi rwilson,
thanks for your comment and
you are right with a txtfile, *but* the txtfile is only an example.

Micha
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
rwilson032697Commented:
Hmm.. I'm not sure about this, but if you have the Application Object available (though probably not), you could do ExtractFilePath(Application.Exename)+'\MyTextFile.txt';

Cheers,

Raymond.
0
 
intheCommented:
hi
one way is to have a small install program that asks for path names on install so you can then save this path in registry then always know where the file is.
0
 
PROGRAMMING030999Author Commented:
to rwilson:
that I tried already. And I got C:\windows\dektop back.

to inthe:
Do mean a install program in the OCX?

More Questions:
How do I get the root path?

In the inf file there is a DestDir = 11 entry (system folder), is there to modify it? The Macromedia people make a MacroMed folder in the Window directory?


Mich el
0
 
PROGRAMMING030999Author Commented:
Adjusted points to 200
0
 
intheCommented:
you can get the system path by using the  GetSystemDirectory() Api:

For example:

var
lpBuffer: array[0..255] of char;
SysDir: string;
begin
GetSystemDirectory(lpBuffer, 255);
SysDir := lpBuffer;
....
end;

about the install i meant make a small instalation app that copys your files to a folder and writes this path to the registry so when your program needs to know this path to your files it can read the path from the registry.
 
0
 
intheCommented:
this install app could also register your ocx for you if needed.
this is the sort of thing installshield does.
0
 
PROGRAMMING030999Author Commented:
Thanks inthe!
GetSystemDirectory worked.

And did you know, how to get the root path of an ActiveX in the IE?

500 Points for a little example :)

Mich el
0
 
rwilson032697Commented:
In your case it should be <System Directory>\Downloaded Program Files

(Assuming, of course, its downloaded by windows from a web page)

Cheers,

Raymond.
0
 
intheCommented:
well this is guess :

var
ocxpath : cardinal;
begin
ocxpath:=pchar(ExtractFilePath(ParamStr(0))+'blah.ocx');
where blah.ocx is name of your activeX

note:
  this is untested ;-)
0
 
intheCommented:
actually thats wrong what i last said because now the ocx is in the cache loaded by explorer so the paramstr(0) will give iexplorers path name.i dont think it will know what its own proper path is unless you either hardcode it or write it somewhere..
0
 
PROGRAMMING030999Author Commented:
Hi,
I did not need the rootpath now, I think I could use chdir.

Mich el
0
 
PROGRAMMING030999Author Commented:
Thanks again inthe!
0
All Courses

From novice to tech pro — start learning today.