Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Generating a program ID

Generating a program ID

Scheduled Pinned Locked Moved C#
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Muntyness
    wrote on last edited by
    #1

    I have a quick question. I have a program, and I need every instance of the program to have it's own uniqure ID. (E.G the first one opened has and ID of 12345, the second one has an ID of 74982, etc.) At the moment the only way I can see of doing this is getting the process ID. Is this the best way of doing it or are there other, better, ways of generating a unique ID? - Munty

    E L C M 4 Replies Last reply
    0
    • M Muntyness

      I have a quick question. I have a program, and I need every instance of the program to have it's own uniqure ID. (E.G the first one opened has and ID of 12345, the second one has an ID of 74982, etc.) At the moment the only way I can see of doing this is getting the process ID. Is this the best way of doing it or are there other, better, ways of generating a unique ID? - Munty

      E Offline
      E Offline
      ekynox
      wrote on last edited by
      #2

      Why not just use the random number generator and use the current system time as the seed generator. This ought to guarantee a unique sequence of numbers all the time. Or generate a GUID

      1 Reply Last reply
      0
      • M Muntyness

        I have a quick question. I have a program, and I need every instance of the program to have it's own uniqure ID. (E.G the first one opened has and ID of 12345, the second one has an ID of 74982, etc.) At the moment the only way I can see of doing this is getting the process ID. Is this the best way of doing it or are there other, better, ways of generating a unique ID? - Munty

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Process ID is just fine; it is unique in that no two processes can be running simultaneously on the same Windows PC unless their processIDs are different. Why bother to try and come up with some other unique number ? :)

        Luc Pattyn


        try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


        1 Reply Last reply
        0
        • M Muntyness

          I have a quick question. I have a program, and I need every instance of the program to have it's own uniqure ID. (E.G the first one opened has and ID of 12345, the second one has an ID of 74982, etc.) At the moment the only way I can see of doing this is getting the process ID. Is this the best way of doing it or are there other, better, ways of generating a unique ID? - Munty

          C Offline
          C Offline
          Chintan Desai
          wrote on last edited by
          #4

          yup,if it is working with single process class which gurantee to be unique, then y to use time or random class.

          Regards Chintan www.visharadsoft.com (Nothing is so purify as KNOWLEDGE)

          1 Reply Last reply
          0
          • M Muntyness

            I have a quick question. I have a program, and I need every instance of the program to have it's own uniqure ID. (E.G the first one opened has and ID of 12345, the second one has an ID of 74982, etc.) At the moment the only way I can see of doing this is getting the process ID. Is this the best way of doing it or are there other, better, ways of generating a unique ID? - Munty

            M Offline
            M Offline
            Muntyness
            wrote on last edited by
            #5

            Alrighty then, I guess I'll just stick with the Process ID. Thansk All. - Munty

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups