Home > Software design >  How can I add a number/text to a winform so that every copy of the application is uniquely identifia
How can I add a number/text to a winform so that every copy of the application is uniquely identifia

Time:09-28

I want to make a simple application for Windows that displays an image containing some contact info like email and phone numbers. I install the same application on multiple computers running Windows. However, for every copy of that application, I want it to contain a unique number (invoice number, for example) right above the image as text to help me identify the individual and their purchase to better address their complaint/issue.

I am unable to decide the best way to do so. Obviously, I need to change the text in the textbox for every subsequent build. I need it to be so that anyone can easily enter the unique ID without disturbing the source or causing issues with the code.

I need to add a functionality so that

  • There is a nested winform at first time execution that asks me to enter the unique ID
  • Once saved in the textbox, the unique ID permanently stays even if the system is restarted
  • Once saved, the individual cannot change the unique ID

Clearly, I'm fairly new to C# and I have just started to create simple applications integrating excel and word.

Is there any easy/better way to do this? I have been searching the internet for ideas/snippets of code with similar functionality, but could not find any.

I don't want to generate a new number here, I already have the numbers and need to enter them for every copy of the application.

Thanks!

CodePudding user response:

You need to use the user settings area to store the data.

https://docs.microsoft.com/en-us/previous-versions/aa730869(v=vs.80)?redirectedfrom=MSDN

CodePudding user response:

Use Settings.settings file with settings that are stored permanently. I have done a sample app for you to see how it works: https://drive.google.com/file/d/1TfJYYbtw23_3h6z-UmleuMxrCk4hyG7e/view?usp=sharing

  • Related