Reputation: 235
I have a question , Can I execute statements only once at first application execution ? can it be done without registery keys or installer?
Upvotes: 1
Views: 1600
Reputation: 1358
Since you do not explain why you don't want to/can use any "common" method for storing state parameters for your application, I will assume that it's for anti-piracy purposes.
I guess it all depends to the depths you want to go.
So, here's something I've done on several commercial applications I've developed (mainly, but not limited, to prevent piracy):
Consequent executions of the program can then easily detect "parameters/values/settings" by "detecting" such changes.
Again, this is a quite complex and rather obscure way to store start-up arguments (or states) for an application, but again, depending on what you are looking for, this is a quite secure and effective method.
Here's a sample demonstrating the "basics" of this method: HiddenParams
Upvotes: 1
Reputation: 65554
Simply store a value in the App.Config
<appSettings>
<add key="HasExecuted" value ="0"/>
In code:
If Convert.ToBoolean(ConfigurationManager.AppSettings("HasExecuted")) = False Then
'Do something only once
End If
Here is a guide to saving/updating the AppConfig: Update app.config system.net setting at runtime
Upvotes: 2