PP_SEMCOUNT()
Counts the number of available workstation licenses
Applies to:
Win32, Win64
Syntax-VB:
Declare Function pp_semcount(ByVal handle As Long, ByVal flags As Long, ByVal prefix_server As String, ByVal name As String, ByRef number As Long) As Long
Syntax-C:
LONG pp_semcount(LONG handle, LONG flags, LPSTR prefix_server, LPSTR name, LPLONG number)
Arguments:
<handle> is the handle to the License File given by pp_lfopen()
<flags> reserved - set to zero
<prefix_server> is the complete path to the Network Semaphore Files or the TCP/IP address of the server counting the number of simultaneous users
<name> is a 4-character identifier to use to count the workstations.
<number> is the location to place the count data
Returns:
Refer to pp_errorstr() for a table of possible return codes and their meaning. Typically, PP_SUCCESS [1] (count successful) is returned.
Description:
This function calculates the number of allowed licenses MINUS the number of locked licenses which is the number of available licenses. Currently, only the type of SEM_FILE counting is available. The parameter <prefix_server> contains the complete path to the network semaphore files, INCLUDING a trailing backslash (\) character. The <name> parameter contains the first four characters of the semaphore files. The locked semaphore files will be counted and the number will be returned.
The semaphore files are named by the path and prefix you choose. The files are numbered starting at 0 through 9999 and are zero padded with a file extension of .net. An example list of files using "f:\appname\data\" for <prefix_server> and "sema" for <name> is:
f:\appname\data\sema000.net
f:\appname\data\sema001.net
.
f:\appname\data\sema9999.net
This function will attempt to open and lock the semaphore files in the given path for the number of workstations that is in the License File field "number of allowed users." It ignores the field "number of current users" when calculating the result.
Note that in large network installations, the time delay for each workstation will increase as the semaphore files are scanned for the next available license.
Example:
' Calculate the number of available users
' lfhandle contains the License File
' handle which was initialized earlier.
Dim rc As Long, count As Long
rc = pp_semcount(lfhandle, 0, "m:\appname\data\", "sema", count)
If rc <> PP_SUCCESS Then
MsgBox "Encountered error number " & Str(rc)
End
End If
If count = 0 Then
MsgBox "There are no more licenses available"
End
End If
See Also: