using System; using System.Text; using System.Runtime.InteropServices; using PersistentSecurity; //****************************************************************** //* //* This example demonstrates the sgShowClient() function. //* It retrieves information about what the current process //* has checked out. //* //****************************************************************** class ShowClient { static void Main() { int ret,count=0; StringBuilder msg = new StringBuilder(1025); StringBuilder serverhost = new StringBuilder(256); StringBuilder clienthost = new StringBuilder(256); StringBuilder user = new StringBuilder(64); StringBuilder component = new StringBuilder(20); StringBuilder version = new StringBuilder(20); PSProlibProxy.sgSetAttrInt(PSProlibProxy.SG_ATTRTYPE.SG_ATTR_LICENSETYPE,(int)PSProlibProxy.SG_LICENSETYPE.SG_LICENSETYPE_FLOATING); ret = PSProlibProxy.sgCheckout("monitor","6.0"); if (ret != PSProlibProxy.SG_SUCCESS) { PSProlibProxy.sgGetLastErrorString(msg); Console.WriteLine("{0}",msg); Environment.Exit(0); } // IMPORTANT: Even thought the version for "widget" is 5.0 in the license file // if we check out an earlier version and only a 6.0 license is available it will // consume one of the 6.0 licenses ret = PSProlibProxy.sgCheckout("widget","5.0"); if (ret != PSProlibProxy.SG_SUCCESS) { PSProlibProxy.sgGetLastErrorString(msg); Console.WriteLine("{0}",msg); Environment.Exit(0); } // IMPORTANT!! if you check out the same component again, the count will increment ret = PSProlibProxy.sgCheckout("widget","5.0"); if (ret != PSProlibProxy.SG_SUCCESS) { PSProlibProxy.sgGetLastErrorString(msg); Console.WriteLine("{0}",msg); Environment.Exit(0); } for(;;) { ret = PSProlibProxy.sgShowClient(serverhost,clienthost,user, component,version,ref count); if (ret == PSProlibProxy.SG_NO_MORE_CLIENT_COMPONENTS) break; Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}",serverhost, clienthost,user,component,version,count); } PSProlibProxy.sgCheckin("monitor","6.0"); // NOTE: Even if you don't check-in the second "widget", it will be // returned to the license pool when the process exits. PSProlibProxy.sgCheckin("widget","5.0"); Environment.Exit(0); } }