I thought I would give a little back to the Progress community.
Here is a sample code I have writtten in v8.3b I thought I would share with you guys. It gives the user login name, and details of the system running.
Feel free to use it.
Regards
Martin
Couldnt see the attach so here is the code listings
[Edited by progresstalk on 09-11-2000 at 11:13 PM]
Here is a sample code I have writtten in v8.3b I thought I would share with you guys. It gives the user login name, and details of the system running.
Feel free to use it.
Regards
Martin
Couldnt see the attach so here is the code listings
Code:
&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
&ANALYZE-RESUME
&Scoped-define WINDOW-NAME W-Win
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS W-Win
/*------------------------------------------------------------------------
File:
Description: from cntnrwin.w - ADM SmartWindow Template
Input Parameters:
<none>
Output Parameters:
<none>
History:
------------------------------------------------------------------------*/
/* This .W file was created with the Progress UIB. */
/*----------------------------------------------------------------------*/
/* Create an unnamed pool to store all the widgets created
by this procedure. This is a good default which assures
that this procedure's triggers and internal procedures
will execute in this procedure's storage, and that proper
cleanup will occur on deletion of the procedure. */
CREATE WIDGET-POOL.
/* *************************** Definitions ************************** */
/* Parameters Definitions --- */
/* Local Variable Definitions --- */
DEF VAR op-vRes AS C NO-UNDO.
DEF VAR op-vmem AS C NO-UNDO .
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
/* ******************** Preprocessor Definitions ******************** */
&Scoped-define PROCEDURE-TYPE SmartWindow
&Scoped-define ADM-CONTAINER WINDOW
/* Name of first Frame and/or Browse and/or first Query */
&Scoped-define FRAME-NAME F-Main
/* Standard List Definitions */
&Scoped-Define ENABLED-OBJECTS RECT-1 vsystem
&Scoped-Define DISPLAYED-OBJECTS vsystem
/* Custom List Definitions */
/* List-1,List-2,List-3,List-4,List-5,List-6 */
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* ************************ Function Prototypes ********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getwindowuser W-Win
FUNCTION getwindowuser RETURNS CHARACTER
(/* */) FORWARD.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Control Definitions ********************** */
/* Define the widget handle for the window */
DEFINE VAR W-Win AS WIDGET-HANDLE NO-UNDO.
/* Definitions of the field level widgets */
DEFINE VARIABLE vsystem AS CHARACTER
VIEW-AS EDITOR
SIZE 63 BY 5 NO-UNDO.
DEFINE RECTANGLE RECT-1
EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
SIZE 68 BY 6.67.
/* ************************ Frame Definitions *********************** */
DEFINE FRAME F-Main
vsystem AT ROW 1.95 COL 5 NO-LABEL
RECT-1 AT ROW 1.24 COL 2
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1
SIZE 136.8 BY 18.86.
/* *********************** Procedure Settings ************************ */
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: SmartWindow
Allow: Basic,Browse,DB-Fields,Query,Smart,Window
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
/* ************************* Create Window ************************** */
&ANALYZE-SUSPEND _CREATE-WINDOW
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
CREATE WINDOW W-Win ASSIGN
HIDDEN = YES
TITLE = "Windows Information"
HEIGHT = 7.1
WIDTH = 72.2
MAX-HEIGHT = 20.24
MAX-WIDTH = 136.8
VIRTUAL-HEIGHT = 20.24
VIRTUAL-WIDTH = 136.8
RESIZE = no
SCROLL-BARS = no
STATUS-AREA = no
BGCOLOR = ?
FGCOLOR = ?
THREE-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION */
&ANALYZE-RESUME
/* *************** Runtime Attributes and UIB Settings ************** */
&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW W-Win
VISIBLE,,RUN-PERSISTENT */
/* SETTINGS FOR FRAME F-Main
*/
ASSIGN
vsystem:READ-ONLY IN FRAME F-Main = TRUE.
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(W-Win)
THEN W-Win:HIDDEN = yes.
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB W-Win
/* ************************* Included-Libraries *********************** */
{src/adm/method/containr.i}
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ************************ Control Triggers ************************ */
&Scoped-define SELF-NAME W-Win
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-Win W-Win
ON END-ERROR OF W-Win /* Windows Information */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
/* This case occurs when the user presses the "Esc" key.
In a persistently run window, just ignore this. If we did not, the
application would exit. */
IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-Win W-Win
ON WINDOW-CLOSE OF W-Win /* Windows Information */
DO:
/* This ADM code must be left here in order for the SmartWindow
and its descendents to terminate properly on exit. */
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&UNDEFINE SELF-NAME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK W-Win
/* *************************** Main Block *************************** */
/* Include custom Main Block code for SmartWindows. */
{src/adm/template/windowmn.i}
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ********************** Internal Procedures *********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects W-Win _ADM-CREATE-OBJECTS
PROCEDURE adm-create-objects :
/*------------------------------------------------------------------------------
Purpose: Create handles for all SmartObjects used in this procedure.
After SmartObjects are initialized, then SmartLinks are added.
Parameters: <none>
------------------------------------------------------------------------------*/
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CallWindows W-Win
PROCEDURE CallWindows :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
END PROCEDURE.
PROCEDURE GetUserNameA external "advapi32.dll" :
define input-output parameter lpBuffer as char.
define input-output parameter nSize as long.
END PROCEDURE.
PROCEDURE GlobalMemoryStatus external "kernel32.dll":
define input-output parameter lpmemorystatus as memptr.
END PROCEDURE.
PROCEDURE GetSystemInfo external "kernel32.dll":
define input-output parameter lpSystemInfo as memptr.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI W-Win _DEFAULT-DISABLE
PROCEDURE disable_UI :
/*------------------------------------------------------------------------------
Purpose: DISABLE the User Interface
Parameters: <none>
Notes: Here we clean-up the user-interface by deleting
dynamic widgets we have created and/or hide
frames. This procedure is usually called when
we are ready to "clean-up" after running.
------------------------------------------------------------------------------*/
/* Delete the WINDOW we created */
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(W-Win)
THEN DELETE WIDGET W-Win.
IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI W-Win _DEFAULT-ENABLE
PROCEDURE enable_UI :
/*------------------------------------------------------------------------------
Purpose: ENABLE the User Interface
Parameters: <none>
Notes: Here we display/view/enable the widgets in the
user-interface. In addition, OPEN all queries
associated with each FRAME and BROWSE.
These statements here are based on the "Other
Settings" section of the widget Property Sheets.
------------------------------------------------------------------------------*/
DISPLAY vsystem
WITH FRAME F-Main IN WINDOW W-Win.
ENABLE RECT-1 vsystem
WITH FRAME F-Main IN WINDOW W-Win.
{&OPEN-BROWSERS-IN-QUERY-F-Main}
VIEW W-Win.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE getinfo W-Win
PROCEDURE getinfo :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
define output parameter pLabel1 as char.
define output parameter pLabel2 as char.
define variable lpmemorystatus as memptr.
define variable lpsysteminfo as memptr.
define variable procnum as integer no-undo.
define variable proctype as character no-undo.
define variable PctMemInUse as integer no-undo.
define variable SwapFree as integer no-undo.
define variable TotPhysMem as integer no-undo.
define variable FreePhysMem as integer no-undo.
/* set up pointers */
set-size(lpmemorystatus) = 32.
put-long(lpmemorystatus,1) = 32.
set-size(lpsysteminfo) = 40.
RUN GlobalMemoryStatus (INPUT-OUTPUT lpmemorystatus).
RUN GetSystemInfo (INPUT-OUTPUT lpsysteminfo).
ASSIGN
PctMemInUse = GET-LONG(lpmemorystatus,5)
TotPhysMem = GET-LONG(lpmemorystatus,9) / 1024
FreePhysMem = GET-LONG(lpmemorystatus,13) / 1024
ProcNum = GET-SHORT(lpsysteminfo,1)
ProcType = STRING(GET-LONG(lpsysteminfo,25))
SwapFree = GET-LONG(lpmemorystatus,21) / 1024.
CASE procnum:
WHEN 0 THEN ProcType = "Intel " + (IF ProcType = "586" THEN "Pentium" ELSE ProcType).
WHEN 1 THEN ProcType = "MIPS " + Proctype.
WHEN 2 THEN ProcType = "ALPHA " + Proctype.
WHEN 3 THEN ProcType = "PowerPC " + ProcType.
OTHERWISE ProcType = "unknown processor".
END CASE.
pLabel1 = SESSION:WINDOW-SYSTEM + " running on an " + ProcType.
pLabel2 = "Phys. memory: " + STRING(TotPhysMem, ">>>>>>>K") + " -"
+ STRING(FreePhysMem, ">>>>>>>K free").
/* free pointers */
set-size(lpmemorystatus) = 0.
set-size(lpsysteminfo) = 0.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-initialize W-Win
PROCEDURE local-initialize :
/*------------------------------------------------------------------------------
Purpose: Override standard ADM method
Notes:
------------------------------------------------------------------------------*/
/* Code placed here will execute PRIOR to standard behavior. */
/* Dispatch standard ADM method. */
RUN dispatch IN THIS-PROCEDURE ( INPUT 'initialize':U ) .
/* Code placed here will execute AFTER standard behavior. */
DO WITH FRAME {&FRAME-NAME}:
RUN GetInfo IN THIS-PROCEDURE (OUTPUT op-vmem,OUTPUT op-vRes).
ASSIGN
vsystem:SCREEN-VALUE =
CHR(13) + ' System : ' +
op-vmem +
CHR(13) + CHR(13) + ' Resource: ' +
op-vres +
CHR(13) + CHR(13) + ' Login : ' +
getWindowUser() +
CHR(13)
vsystem:SENSITIVE = TRUE
.
END.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ************************ Function Implementations ***************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getwindowuser W-Win
FUNCTION getwindowuser RETURNS CHARACTER
(/* */):
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
DEF VAR vUser AS CHAR NO-UNDO.
DEF VAR vSize AS INT INIT 128 NO-UNDO.
ASSIGN vUser = FILL(" ",vSize).
RUN GetUserNameA IN THIS-PROCEDURE
(INPUT-OUTPUT vUser,
INPUT-OUTPUT vSize).
RETURN vUser.
END FUNCTION.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
[Edited by progresstalk on 09-11-2000 at 11:13 PM]