-
Jul 10th, 2008, 01:23 AM
#1
Thread Starter
Hyperactive Member
detect first run of my program on any pc[RESOLVED]
hiiiiii guys......
i want to know how to detect first run of my program on a new comp ie wen my prog is installed and run for the first time it should display a welcome msg and den from the next runs it shuld nt come on dat pc...... hope u understood my problem.......
thanks very much waiting for a reply
Last edited by developerno1; Jul 10th, 2008 at 08:26 AM.
Reason: problem solved
-
Jul 10th, 2008, 06:48 AM
#2
Re: detect first run of my program on any pc
You would need to write something off to the folder where the program was installed, or the registry, or something along those lines.
Each time your program ran, it would check for this. If it was found, then it would know it had already been run, and would not show the welcome. If it did not find it, it would know it had not been run on the machine before, and would show the welcome.
-
Jul 10th, 2008, 07:06 AM
#3
Thread Starter
Hyperactive Member
Re: detect first run of my program on any pc
ya i was also thinking on similar lines but i could not figur out which way wud be easy and how to implement in code, can anyone help plzzzzz
-
Jul 10th, 2008, 07:20 AM
#4
Re: detect first run of my program on any pc
Brother, I think I have an idea. Try the below one...
vb Code:
Dim Status As String Open App.Path & "\settings.txt" For Input As #1 Input #1, Status Close #1 If Status = "new" Then MsgBox "Welcome to my program..!" Open App.Path & "\settings.txt" For Output As #1 Print #1, "no" Close #1 End If
Write the above code in the main form's load event... This will sove your problem...
Please note that, you have to create a Text file named "Settings.txt" and type "new" inside. And include this file with your program... Thus it works...
I hope this will help you...
If you found this useful, please rate me........
-
Jul 10th, 2008, 07:41 AM
#5
Re: detect first run of my program on any pc
You should never write anything to the App.Path, since that is typically going to be under Program Files. This is considered a bad practice under XP, and it flat-out won't work under Vista.
Instead, use the registry. If you want to conform to Windows standards, create a registry key for your program as follows:
HKEY_CURRENT_USER\Software\<YourCompany>\<YourProgram>
Then for this particular purpose you'd create a value called something like ShowWelcome or FirstRun.
-
Jul 10th, 2008, 08:25 AM
#6
Thread Starter
Hyperactive Member
-
Jul 10th, 2008, 08:29 AM
#7
Re: detect first run of my program on any pc
Originally Posted by Ellis Dee
You should never write anything to the App.Path, since that is typically going to be under Program Files. This is considered a bad practice under XP, and it flat-out won't work under Vista.
Instead, use the registry. If you want to conform to Windows standards, create a registry key for your program as follows:
HKEY_CURRENT_USER\Software\<YourCompany>\<YourProgram>
Then for this particular purpose you'd create a value called something like ShowWelcome or FirstRun.
Are you saying that the above code doesn't work on XP or Vista...?
I checked it in an XP machine and it worked.. But I dont know whether it works on a Vista machine.. I think to make programs for Vista machines, some changes need to be made for VB programs... I think someone had posted a thread here on 'how to create VB programs for Vista'...
-
Jul 10th, 2008, 08:41 AM
#8
Re: detect first run of my program on any pc[RESOLVED]
It won't work in Vista - and will only work in XP/2000 if you log in as an admin/power user (so not a limited user, as many people do, especially in an office).
The thread you were thinking of is in our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)
-
Jul 10th, 2008, 09:57 AM
#9
Re: detect first run of my program on any pc[RESOLVED]
Potentially, there is a problem with the registry as well.
Many of our clients are now rolling out machines to their employees with the registry locked down.
Because of this, we moved the target for any and all of the settings our software uses to a specific DB table.
Although we didn't know it at the time, this has also positioned us pretty well, with respect to this issue anyway, for moving to Vista.
-
Jul 10th, 2008, 11:12 AM
#10
Re: detect first run of my program on any pc[RESOLVED]
That's an excellent point. If I wanted to store user settings in an environment with a locked-down registry, I'd save to a file (ini, database, whatever) in the user's Application Data folder under the same Company\Program tree structure as the registry uses.
It's one of the few areas you can be guaranteed won't be locked down, and also isn't in plain sight of the user.
-
Jul 10th, 2008, 11:28 AM
#11
Member
Re: detect first run of my program on any pc[RESOLVED]
I always write stuff to the \Documents and Settings\Username\Application Data
or if, during install, they chose "All Users" then \Documents and Settings\All Users\
I use the SHGetSpecialFolder API to get the path
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|