Counts the number of available workstation licenses
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
LONG pp_semcount(LONG handle, LONG flags, LPSTR prefix_server, LPSTR name, LPLONG number)
<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
Refer to pp_errorstr() for a table of possible return codes and their meaning. Typically, PP_SUCCESS  (count successful) is returned.
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:
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.
' 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)
If count = 0 Then
MsgBox "There are no more licenses available"
PP_SEMOPEN(), PP_SEMUSED(), and PP_SEMCLOSE()