CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    Beijing
    Posts
    3

    how to get a unique INT value in C++?

    I just want to get a unique INT value to assign it to every record in database as primary key, any API can do it? Any related information is appreciated.

  2. #2
    Join Date
    Aug 2001
    Location
    Germany
    Posts
    166
    a unique INT? You mean through different app-starts?

    You can store Your value in the registry or in an ini-file and increment it.

    Hope this helps

    Mikey

  3. #3
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    May be CoCreateGuid() or UuidCreate() or UuidCreateSequential() suite your needs. These are usually used for generating a unique 128-bit integer in M$ plaftorms.

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125
    Why not just use an autonumber field in the database???????
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured