Share via


IGenID::InitializeCounter Method [C++]

Use this method to create or reset a global, sequential counter.

Definition

[C++]

HRESULT IGenID::InitializeCounter(BSTRbstrCounterName,
  longdwInitialValue);

[Visual Basic]

Sub InitializeCounter(bstrCounterName As String,
  dwInitialValue As Long)

Parameters

  • bstrCounterName[C++]
    [in] A BSTR that contains the counter name.
  • bstrCounterName[Visual Basic]
    A String that contains the counter name.
  • dwInitialValue[C++]
    [in] An Integer that contains the initial value of the counter.
  • dwInitialValue[Visual Basic]
    A Long that contains the initial value of the counter.

Return Values

[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic] None.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

Any number of counters may be created. If the counter already exists, its value is reset to the specified initial value.

A global counter will work across multiple computers.

The Initialize method must be called before calling the InitializeCounter method.

[C++]

The dwInitialValue parameter contains valid data only if the method completes successfully.

[Visual Basic]

Example

' oGenID``is a Commerce GenID object

oGenID.InitializeCounter("OrderCounter", 213)

See Also

[C++]GenID Object

[Visual Basic]GenID Object

Copyright © 2005 Microsoft Corporation.
All rights reserved.