3

I have a more general question but any advice in implementing this in C# will also be very much appreciated. I am making a PC windows based program in C# and the idea is, for this program to send a small amount of data to a database located on a server somewhere, when the computer on which the program is running is connected to the internet. The PC program will be used by many people, but I would like to be able to know, which user (which program) sent the data. So, I would put one program out there for people to download and install. This program would then send some data (which depend on what the user does in the program) to a central database and I would like to know which of the programs out there sent the data. This way I could see what functionality of the program is used the most, do some people mostly use one functionality or more of them,...

The question therefore is, how to make one program but be able to distinguish the different "instances" of that program?

Does anyone have any ideas how to achieve this?

Thank you in advance for all of your answers. Cheers!

p.s.: I should mention that I am just starting to learn PC programming so try to make the answers simple to understand also for a beginner. :)

EEALNT
  • 145
  • 1
  • 13

3 Answers3

9

I'd create a GUID on the client and store it in settings somewhere, then send that with each message.

This can be stored in per user or global settings on the computer so you get user-based or computer-based fidelity.

This has the advantage that you are not storing any personal data, so won't run afoul of privacy laws.

Jackson Pope
  • 14,520
  • 6
  • 56
  • 80
  • @Kiley Naro : OK, so obviously GUID is the preferred way to go here. I do have a concern though: If the user should uninstall the software or format the computer and then reinstall the application, this would result in a new GUID and the database would, from there on, treat this user as a new user. Am I correct in thinking that? Or is there a way around that? Could I not somehow use some data unique to the users computer? Someone mentioned an IP, although that changes if it is not static. – EEALNT Oct 26 '11 at 21:13
  • @user1015043 You are correct in your assumption. You might be able to do something like store the GUID in a registry key, and upon installation check to see if that key exists. If it does, present the user with the option of wiping it clean or leaving it as is. Beyond that, you COULD use the MAC address as that is unique to every network adapter, but then you have to ask yourself what happens if the network adapter changes (as non-integrated network adapters DO exist). – Kiley Naro Oct 26 '11 at 21:16
2

You can use a combination of the MAC address and logged in user name (possibly hashed so you don't end up holding private information) to uniquely identify machine/user combinations.

Community
  • 1
  • 1
Oded
  • 489,969
  • 99
  • 883
  • 1,009
2

Whatever you do, make sure that you ask permission from each user before sending data or you will probably lose goodwill with your users really quickly. In your installer, consider writing a Guid to the file system and reading that GUID each time the program loads. The installer could also have an option like "Send anonymous usage information to improve customer experience". If they uncheck the box, then record that fact as well.

agent-j
  • 27,335
  • 5
  • 52
  • 79
  • Here I have a similar question as in the previous post. Doesn't uninstalling or formatting the computer then set a new GUID and so present the same user as a new one? What exactly did you mean with writing the GUID to the file system? Writing it to a file somewhere on the disk? What kind of files are usually used for such things? Probably not just plain old txt, right? – EEALNT Oct 26 '11 at 21:16
  • I wouldn't think you would be concerned about someone "impersonating" another computer (by guessing a different computer's GUID). I would probably make it a hidden file called "unique.prodkey" (with an extension that doesn't have a default program to open it. This way most of your users will probably never even see the file, but if they do, there won't be a program to open it. – agent-j Nov 01 '11 at 14:34