Program counter

D

Ducoltd

I'm a newbie at programming and I'm trying to write a program that
allows me to count the number of times a program is accessed with the
result to increment a log file. I can get it to work(ish) with vbs if
the user opens up the program first and then opens the file, but as
you can imagine most users open up the file by double clicking in
explorer or via shortcuts. Has anyone got any advice or can point me in
the right direction

Anyway thanks in advance!
 
J

Jeffrey Schwab

I'm a newbie at programming and I'm trying to write a program that
allows me to count the number of times a program is accessed with the
result to increment a log file. I can get it to work(ish) with vbs if
the user opens up the program first and then opens the file, but as
you can imagine most users open up the file by double clicking in
explorer or via shortcuts. Has anyone got any advice or can point me in
the right direction

What program is used to open the file when the user double-clicks its icon?
 
D

Ducoltd

I created a .exe from vbs script (i tried this language first as like i
said im new to programming) and assoitiated the .exe with all pdf's the
problem was that my script only includes the command to run adobe and
not pass the selected file info
 
J

Jeffrey Schwab

When you reply, please include enough context so that someone can read
the post from top to bottom and follow the conversation.
I created a .exe from vbs script (i tried this language first as like
i said im new to programming) and assoitiated the .exe with all pdf's
the problem was that my script only includes the command to run adobe
and not pass the selected file info

Since this is a Java news group, I can't really help with the actual
code here unless you want to try solving the problem in Java. If you
really want to stick with VB, try posting your code in a VB-related news
group.

It sounds like your program is getting invoked whenever the user opens a
relevant file (PDF), so your program can do whatever it likes when that
happens. In order to keep a count of the number of times the program
has been invoked, your program might include the following steps:

- try to open a config file for read/write, e.g.
%HomeDrive%%HomePath%\_yourProgramRC
- read the count from the file if it is present, else initialize
the count to zero
- overwrite the file contents with the new count, i.e. the old
count plus one
- run adobe, passing it the relevant command-line arguments and
process environment

The current count will always be stored in the config file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top