Click here to Skip to main content
15,444,993 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

i have an application. My requirement is that application should open for only 10 times. if it is opened 11th time or greater it should display a message box and exit.

I tried storing the count in registry but it working when we tried in single PC only.
My requirement is If the application has opened in 10 different PCs, it should not open for the 11th time.

Can we store and update the values in project resources?

Please can any one help me?
How to solve this problem?

I need to deploy my application in different Client locations which are not connected through a LAN
Posted
Updated 20-Feb-12 17:55pm
v2
Comments
SteveAdey 13-Feb-12 10:05am     CRLF
Try accessing the registry remotely from the other PCs. I've given this a 4, as I think it's an interesting question.
Sanju Sanju 15-Feb-12 2:32am    
It will be fine if there is LAN. but i need the same for those PCs which are not connected in a LAN also
SteveAdey 15-Feb-12 16:54pm    
Then without the power of the ether, I think you may be stuffed, there has to be some way of the machines knowing about each other, otherwise what you are asking is impossible.

ok, first of all what you asked is not possible without each computer having internet access.
first way is to create a database in a central computer, check the initialization count and update a table each time the program runs. this is the easiest and most convenient way.
another way is to put the power of cloud to use. create a microsoft skydrive account. create a file there that stores how many times the program had run. on initialization of your program, download that file using skydrive .net api link, update it, and upload it. do not forget to encrypt the file contents to prevent tampering with it.
if you do not have any means to operate a central server or skydrive, as an alternate way, you can use google docs. this is a long way and not optimized in any means, but its what comes to my mind now. using google docs api, store how many times the application had run in a spreadsheet.
as a funny way, create a twitter account and tweet zero. on opening the program, read the final tweet and retweet the update using twitter api.
I'd stick with skydrive though
 
Share this answer
 
v2
Comments
Michael dg 13-Feb-12 8:38am    
I'll recommend this one.
SteveAdey 13-Feb-12 10:01am    
I'd recommend your one Michael ;-) It doesn't need internet access.
MCY 13-Feb-12 10:13am    
yet still needs lan access :)
SteveAdey 13-Feb-12 10:48am    
Yeah, but your's would need lan and internet access. I'd also assume (could be wrongly) that since there are multiple PCs without internet access, that they would be networked.
MCY 13-Feb-12 12:55pm    
I thought he sold several copies to different locations. for different offices of a company for example, so they do not have lan. but if they are all in the same network (same building maybe) a lan solution will also work.
by the way. you can also create a windows service application and installed it on one of the computers.
the windows service application will listen for incoming count request and answered it with the current execution count. in communication with the windows service and the other windows application, you can use .NET Remoting or the WCF.
 
Share this answer
 
v2
Comments
SteveAdey 13-Feb-12 10:02am     CRLF
Of course it would have to build it as a peer to peer system in case that 'one' computer was off, so they could all act as counter keepers. Makes it a little more complex though. This would be by far the most robust solution.
MCY 13-Feb-12 10:12am    
yeah good one. but Steve's point is true & p2p system may be little complex
Michael dg 14-Feb-12 2:11am    
well we can say it as p2p. but my point was one windows service will act as a central counter or replacement for the central database. :)
SteveAdey 14-Feb-12 4:27am    
My point was, that it shouldn't be one windows service, I wasn't just rewording what you said. i.e. distributed counters.
Sanju Sanju 21-Feb-12 0:01am    
Im not familiar with WCF and remoting. will it work for systems which doesnt have Lan ?? If yes, please give me an example on how to create this?
Of course it will work for single PC if you store the count on the local machine. But if you put it on a centralized storage, say, a database where all of the applications will connect, retrive, and update the count, I believe that will do the trick.
 
Share this answer
 
Comments
Sanju Sanju 9-Feb-12 0:15am     CRLF
Thank you For your quick responce. Yes but there is no Centralized location and also no internet connection. Im not able to maintain a database. i need the solution with out database
walterhevedeich 9-Feb-12 0:30am    
The database is only an example. You can use other data sources as long as all your applications are able to access it, through network(not necessarily with Internet connection). If you cannot make a setup like that, I believe there's no other way.
Hi,
You may see below articles:
Limiting the Number of Instances Running
 
Share this answer
 
Comments
Sanju Sanju 9-Feb-12 0:20am     CRLF
Thank you Al Moje. My requirement is not to restrict the number of instances but to restrict the number of executioons.
use the global.asax page for this one and use Session for temporary storage and
and make some condition or use javascript

visit this forums below for more information that is related to your question

http://forums.asp.net/t/1188819.aspx/1[^]

http://www.daniweb.com/web-development/aspnet/threads/5145[^]


please vote or Accept solution
If this will help you
Thanks
 
Share this answer
 
v2
Comments
Sanju Sanju 9-Feb-12 1:29am    
Zyck thanks for your reply. But im using windows application. Is there any way for windows app?
zyck 9-Feb-12 6:32am    
wrong answer hehehe by the way you can use DataTable or HashTable
MCY 11-Feb-12 15:33pm    
yeah figured out something is wrong hehe
Check this out http://tap-source.com/?p=281[^]

Should be what you need.

Ok, just read your comment and this link won't help.

You could look at using the registry to store this kind of thing, but it's generally an easy thing to get around if you really want to get around your restriction.
 
Share this answer
 
v2
Comments
MCY 11-Feb-12 15:39pm    
registry wont work for multiple computers
SteveAdey 13-Feb-12 6:25am    
That wasn't initially stipulated. Garbage in, garbage out ;-)
MCY 13-Feb-12 12:52pm    
heh :)
SteveAdey 13-Feb-12 10:04am    
The registry could work for multiple computers as you can access registries remotely.
You should store couter value in Application["count"] of global.asax page.
 
Share this answer
 
Comments
MCY 11-Feb-12 15:34pm    
it is a windows app

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900