PDA

View Full Version : Application Help


thetford
02-09-2007, 04:16 PM
I’m trying to write a small utility, below are the basic functions of this utility app. I’m trying to learn, so I’ll just ask as I go, but here is the end result of what I am trying to accomplish.

Application needs to
A – run in the background at startup.
B – monitor the users license.
C – replace activation file with a non-working file in the event that the user discontinues service.

thetford
02-09-2007, 04:18 PM
First question, how do I determine if the user has a specific exe file on their PC. I need my app to check if a certain exe is installed on the users computer, if so application runs in the background, if not application closes.

longedge
02-10-2007, 05:29 PM
Check out the File.DoesExist and Folder.DoesExist actions to enable you to do this.

thetford
02-12-2007, 09:20 AM
thanks for the help, I tried that actually, I can't seem to make it work. The folder IS THERE, but it always tells me that it is not found. Thanks in advance.

here is the code I used:

does_exist = Folder.DoesExist("_ProgramFilesFolder..\\CM");

-- Display a dialog telling the user whether or not the folder exists.
if does_exist then
Dialog.Message("Notice", "Yes, the folder does exist on your system.", MB_OK, MB_ICONINFORMATION);
else
Dialog.Message("Notice", "No, the folder does not exist on your system.", MB_OK, MB_ICONINFORMATION);
end

thetford
02-12-2007, 09:35 AM
OK, I know what was happing. I have four hard drives on this PC, ALL four harddrives have Program File Folders, so I changed the code to reflect the hard path i.e.

C:\\Program Files\\CM

OK now it sees it, but why was it not finding it on the C: drive before? How do I "dynamically" solve this problem?

longedge
02-12-2007, 10:48 AM
The global variable _ProgramFilesFolder gives you the starting point and then you concatenate it with the rest of the path i.e.

result = Folder.DoesExist(_ProgramFilesFolder.."\\CM");

You were defining the text _ProgramFilesFolder.. as part of the folder name note the position of the double quotes - HTH

thetford
02-16-2007, 10:31 PM
Thanks for the help lonedge! I have made a lot of progress over the last day. I just love AMS! I suppose I'll have to break down and buy 6.0. It's just hard to justify the purchase, since I only use it on an educational or hobby basis. I also have RealBasic, maybe one day I will figure it out!

Thanks again

longedge
02-17-2007, 09:36 AM
I just love AMS! I suppose I'll have to break down and buy 6.0.

That makes at least 2 of us then :D and you are very welcome. AMS is a great piece of software and the help everyone here in the forum gives each other just ices the cake :)

thetford
02-17-2007, 12:33 PM
Yes, I just can't say enough good things about this company. The first thing I bought was SF6.0, I think it was three or four years ago, whenever it was just released. I wrote a Game Modification for Hearts of Iron (by Paradox). This was my first attempt ever at any kind of programming\scripting. It was not that complicated, .csv & text files, graphics, etc.. but I needed an installer for it. After looking around I choose indigo rose. About a year later I bought AMS5.0 & later upgraded it to pro, I have never looked back! IR is the best.

A little history about what I'm trying to do. The first thing I did with AMS was write a credit repair self-help CD. I got caught up in an "identity" theft situation that left my credit, well less than great. It took me about two years to get everything straightened out. I took all of my hard earned knowledge & compiled it on a cd - never made any money out of it, but I have a friend that liked the idea, so I turned it over to him & he re-did it completely, actually wrote a program, with add on modules & the works. He didn't make much off it, and decided to cancel it do to rampent software piracy, since I have some history with it, I asked if I could take a stab at a security device that would make it at least too hard for the average joe to work around it. (all has is a serial number for protection)
So was born the app I'm working on!

After some internet research, I'm wondering about a USB dongle key? Could I buy a usb drive, write an app for it that transfers an activation file when plugged in? Any thoughts?:huh

thetford
02-17-2007, 05:12 PM
Question

the following code gives me the error message: line two, argument 2 must be of string type

--check CM file version
cm_version = File.GetVersionInfo("C:\\Program Files\\CM\\CM.exe");
cm_compatible = String.CompareFileVersions("1.13.3.35", cm_version);

Anybody?

thetford
02-18-2007, 11:19 PM
OK, I just can't figure out how to get my app to monitor the system processes for another app to run.

I just don't understand, what am I missing?

key_found = INIFile.GetValue("C:\\Program FIles\\CM\\SM.ini", "PROGRAM", "KEYFOUND");
instances_of_file = 0;

while key_found == "NO" do
--search for process
file_to_check_for = "dongle.exe";
processes = System.EnumerateProcesses();
for j, file_path in processes do
file = String.SplitPath(file_path);
if (String.Lower(file.Filename..file.Extension)) == file_to_check_for then
INIFile.SetValue("C:\\Program Files\\CM\\SM.ini", "PROGRAM", "KEYFOUND", "YES");
--System.TerminateProcess(j); *original*
end
end
end

Basically, I have a small security program on a USB flash drive i.e. "dongle.exe" I need my app to see this process when it starts, and I need it to also see when the program terminates.

any help please, I'm stuck!:huh

longedge
02-19-2007, 04:24 AM
It's best to start new posts for each subject but if you haven't already resolved the other two problems here then -

File.GetVersionInfo
1. Is only available in AMS5Pro and assuming you have the Pro version.
2. Returns a table and not a string.

In your ini file problem, is "System.EnumerateProcesses" a function that you have created yourself? If not it's not an action in AMS5 as far as I know.

thetford
02-19-2007, 10:10 AM
Hmm the System.enumerateProcess code I took from the AMS 6.0 help file (I don't have 6.0, but I kept the help file after the demo expired)

Yes, I do have the PRO version.

Ok, I guess that I just don't understand tables!

longedge
02-19-2007, 12:28 PM
Hmm the System.enumerateProcess code I took from the AMS 6.0 help file (I don't have 6.0, but I kept the help file after the demo expired)

Yes, I do have the PRO version.

Ok, I guess that I just don't understand tables!

Well you've shown me at least one of the actions that has been introduced in Vers 6 :)

I'd suggest sticking with the helpfile for the version you are using.

If you look at the helpfile for File.GetVersionInfo you'll see there are about 12 different elements that could be returned and the first one is .FileVersion so in this code -

checkver = File.GetVersionInfo(_ProgramFilesFolder.."\\AutoPlay Media Studio 5.0 Professional\\ams50.exe");
fv = checkver.FileVersion

will return that first element in the variable fv.

thetford
02-19-2007, 12:37 PM
Yeah, i go back and forth between help files, the 6.0 file has more content:lol

Most of the time the stuff works in 5.0:yes