home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft_Programmers_Library.7z / MPL / net / lanpgmr.txt < prev    next >
Encoding:
Text File  |  2013-11-08  |  1.7 MB  |  46,508 lines

Text Truncated. Only the first 1MB is shown below. Download the file for the complete contents.
  1.  Microsoft LAN Manager - Programmer's Reference
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  ────────────────────────────────────────────────────────────────────────────
  11.               Microsoft(R) LAN Manager - Programmer's Reference
  12.  
  13.                               Covers version 2.0
  14.  ────────────────────────────────────────────────────────────────────────────
  15.  
  16.  
  17.                   Network APIs for MS(R) OS/2 and MS-DOS(R)
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  Microsoft Corporation
  27.  
  28.  PUBLISHED BY
  29.  Microsoft Press
  30.  A Division of Microsoft Corporation
  31.  One Microsoft Way, Redmond, Washington 98052-6399
  32.  
  33.  Copyright (C)1990 by Microsoft Corporation. All rights
  34.  reserved.
  35.  
  36.  Information in this document is subject to change without notice and
  37.  does not represent a commitment on the part of Microsoft Corporation.
  38.  The software described in this document
  39.  is furnished under a license agreement or nondisclosure agreement.
  40.  The software may be
  41.  used or copied only in accordance with the terms of the agreement.
  42.  It is against the law to
  43.  copy the software on any medium except as specifically allowed in
  44.  the license or nondisclosure agreement. No part of this manual may
  45.  be reproduced or transmitted in any form or by any means, electronic
  46.  or mechanical, including photocopying and recording, for any purpose
  47.  without the written permission of Microsoft Corporation.
  48.  
  49.  Library of Congress Cataloging-in-Publication Data
  50.  
  51.  Microsoft LAN manager programmer's reference : network APIs for OS/2
  52.  
  53.    and MS-DOS / Microsoft Corporation.
  54.       p.  cm. ─ (Microsoft OS/2 programmer's reference library)
  55.     Includes index.
  56.     ISBN 1-55615-313-9
  57.     1. Local area networks (Computer networks) ─ Computer
  58.  programs.
  59.    2. Microsoft LAN manager (Computer program) 3. OS/2 (Computer
  60.  
  61.    operating system) 4. MS DOS (Computer operating system)
  62.    I. Microsoft. II. Series.
  63.    TK5105.7.M53 1990                90-41578
  64.    004.6'8'02855369 ─ dc20                 CIP
  65.  
  66.  
  67.  Printed and bound in the United States of America.
  68.  
  69.  123456789FGFG43210
  70.  
  71.  Distributed to the book trade in Canada by General Publishing Company,
  72.  Ltd.
  73.  Distributed to the book trade outside the U.S. and Canada by Penguin
  74.  Books Ltd.
  75.  Penguin Books Ltd., Harmondsworth, Middlesex, England
  76.  Penguin Books Australia Ltd., Ringwood, Victoria, Australia
  77.  Penguin Books N.Z. Ltd., 182-190 Wairau Road, Auckland 10, New
  78.  Zealand
  79.  
  80.  British Cataloging in Publication Data available
  81.  
  82.  
  83.  
  84.  CodeView(R), Microsoft(R), MS(R),
  85.  MS-DOS(R), XENIX(R), and the Microsoft logo
  86.  are registered trademarks and Windows(tm) is a trademark
  87.  of Microsoft Corporation.
  88.  
  89.  Apple(R) is a registered trademark of Apple Computer,
  90.  Inc. 386(tm) is a trademark of
  91.  Intel Corporation. IBM(R) is a registered trademark of
  92.  International Business Machines Corporation. Novell(R)
  93.  is a registered trademark of Novell, Inc.
  94.  
  95.  Writers:  Lewis Campbell, Bruce Legge, John Murray, Barry Potter
  96.  Contributors:  Alec Barker, Paul Canniff, Liz Chalmers, Chuck Chan,
  97.  Brendan Dixon,
  98.   Helen Dolmas, Diane Friedman, Danny Glasser, Andy Held, Joe Holman,
  99.  
  100.   Jim Horne, Jeffery Howard, Jan Keller, Rustan Leino, Mark Lewin,
  101.  
  102.   Lesley Link, Pradyumna Misra, Yuval Neeman, Judy Nessen, Larry Osterman,
  103.  
  104.   Thomas Payne, Eric Peterson, A. J. Rizer, Kevin Schofield, Bharat
  105.  Shah,
  106.   Alok Sinha, Ed Stubbs, Lori Walker, Manny Weiser, William Wu, Sue
  107.  Wyble,
  108.   LAN Manager development team
  109.  
  110.  
  111.  
  112.  Document Number:  OEM-D/P787-2Z
  113.  
  114.  
  115.  
  116.  
  117.  Table of Contents
  118.  ────────────────────────────────────────────────────────────────────────────
  119.  
  120.  
  121.  
  122.  Before You Begin
  123.       How to Use This Manual
  124.       Notational Conventions
  125.       For More Information
  126.  
  127.  Chapter 1  Overview of the LAN Manager API
  128.  
  129.       Identifying API Components
  130.              API Function Names
  131.              API Data Structure Names
  132.              API Variable Names
  133.       Including LAN Manager API Definitions
  134.       Calling a LAN Manager API Function
  135.              Calling Privileges
  136.              Parameter Formats
  137.              Using Buffers with API Functions
  138.              Interpreting Return Codes
  139.       Compiling and Linking Applications
  140.       Debugging Tips
  141.              Stack Overflow
  142.              Errors in Hard-Coded Values
  143.              Errors During Pointer Type Conversion
  144.              MS OS/2 Protection Violations and Faults
  145.              MS-DOS, Windows 2.x, and Real-Mode Windows 3.0 Applications
  146.              Windows 3.0 Protected-Mode Applications
  147.  
  148.  Chapter 2  API Function Descriptions
  149.  
  150.       Format Reference Pages
  151.       Access Permissions Category
  152.              Description
  153.              Data Structures
  154.              NetAccessAdd
  155.              NetAccessCheck
  156.              NetAccessDel
  157.              NetAccessEnum
  158.              NetAccessGetInfo
  159.              NetAccessGetUserPerms
  160.              NetAccessSetInfo
  161.              Access Permissions Category Example
  162.       Alert Category
  163.              Description
  164.              Data Structures
  165.              NetAlertRaise
  166.              NetAlertStart
  167.              NetAlertStop
  168.              Alert Category Example
  169.       Auditing Category
  170.              Description
  171.              Data Structures
  172.              NetAuditClear
  173.              NetAuditRead
  174.              NetAuditWrite
  175.              Auditing Category Example
  176.       Character Device Category
  177.              Description
  178.              Data Structures
  179.              NetCharDevControl
  180.              NetCharDevEnum
  181.              NetCharDevGetInfo
  182.              NetCharDevQEnum
  183.              NetCharDevQGetInfo
  184.              NetCharDevQPurge
  185.              NetCharDevQPurgeSelf
  186.              NetCharDevQSetInfo
  187.              Character Device Category Example
  188.       Configuration Category
  189.              Description
  190.              NetConfigGet2
  191.              NetConfigGetAll2
  192.              Configuration Category Example
  193.       Connection Category
  194.              Description
  195.              Data Structures
  196.              NetConnectionEnum
  197.              Connection Category Example
  198.       Domain Category
  199.              Description
  200.              Data Structures
  201.              NetGetDCName
  202.              NetLogonEnum
  203.              Domain Category Example
  204.       Error Logging Category
  205.              Description
  206.              Data Structure
  207.              Error Log Codes
  208.              NetErrorLogClear
  209.              NetErrorLogRead
  210.              NetErrorLogWrite
  211.              Error Logging Category Example
  212.       File Category
  213.              Description
  214.              Data Structures
  215.              NetFileClose2
  216.              NetFileEnum2
  217.              NetFileGetInfo2
  218.              File Category Example
  219.       Group Category
  220.              Description
  221.              Data Structures
  222.              NetGroupAdd
  223.              NetGroupAddUser
  224.              NetGroupDel
  225.              NetGroupDelUser
  226.              NetGroupEnum
  227.              NetGroupGetInfo
  228.              NetGroupGetUsers
  229.              NetGroupSetInfo
  230.              NetGroupSetUsers
  231.              Group Category Example
  232.       Handle Category
  233.              Description
  234.              Data Structures
  235.              NetHandleGetInfo
  236.              NetHandleSetInfo
  237.              Handle Category Example
  238.       Mailslot Category
  239.              Description
  240.              DosDeleteMailslot
  241.              DosMailslotInfo
  242.              DosMakeMailslot
  243.              DosPeekMailslot
  244.              DosReadMailslot
  245.              DosWriteMailslot
  246.              Mailslot Category Example
  247.       Message Category
  248.              Description
  249.              Data Structures
  250.              NetMessageBufferSend
  251.              NetMessageFileSend
  252.              NetMessageLogFileGet
  253.              NetMessageLogFileSet
  254.              NetMessageNameAdd
  255.              NetMessageNameDel
  256.              NetMessageNameEnum
  257.              NetMessageNameFwd
  258.              NetMessageNameGetInfo
  259.              NetMessageNameUnFwd
  260.              Message Category Example
  261.       Print Destination Category
  262.              Description
  263.              Data Structures
  264.              DosPrintDestAdd
  265.              DosPrintDestControl
  266.              DosPrintDestDel
  267.              DosPrintDestEnum
  268.              DosPrintDestGetInfo
  269.              DosPrintDestSetInfo
  270.              Print Destination Category Example
  271.       Print Job Category
  272.              Description
  273.              Data Structures
  274.              DosPrintJobContinue
  275.              DosPrintJobDel
  276.              DosPrintJobEnum
  277.              DosPrintJobGetId
  278.              DosPrintJobGetInfo
  279.              DosPrintJobPause
  280.              DosPrintJobSetInfo
  281.              Print Job Category Example
  282.       Printer Queue Category
  283.              Description
  284.              Data Structures
  285.              DosPrintQAdd
  286.              DosPrintQContinue
  287.              DosPrintQDel
  288.              DosPrintQEnum
  289.              DosPrintQGetInfo
  290.              DosPrintQPause
  291.              DosPrintQPurge
  292.              DosPrintQSetInfo
  293.              Printer Queue Category Example
  294.       Remote Utility Category
  295.              Description
  296.              Data Structures
  297.              NetRemoteCopy
  298.              NetRemoteExec
  299.              NetRemoteMove
  300.              NetRemoteTOD
  301.              Remote Utility Category Example
  302.       Server Category
  303.              Description
  304.              Data Structures
  305.              NetServerAdminCommand
  306.              NetServerDiskEnum
  307.              NetServerEnum2
  308.              NetServerGetInfo
  309.              NetServerSetInfo
  310.              Server Category Example
  311.       Session Category
  312.              Description
  313.              Data Structures
  314.              NetSessionDel
  315.              NetSessionEnum
  316.              NetSessionGetInfo
  317.              Session Category Example
  318.       Share Category
  319.              Description
  320.              Data Structures
  321.              NetShareAdd
  322.              NetShareCheck
  323.              NetShareDel
  324.              NetShareEnum
  325.              NetShareGetInfo
  326.              NetShareSetInfo
  327.              Share Category Example
  328.       Statistics Category
  329.              Description
  330.              Data Structures
  331.              NetStatisticsGet2
  332.              Statistics Category Example
  333.       Service Category
  334.              Description
  335.              Data Structures
  336.              NetServiceControl
  337.              NetServiceEnum
  338.              NetServiceGetInfo
  339.              NetServiceInstall
  340.              NetServiceStatus
  341.              Service Category Example
  342.       Use Category
  343.              Description
  344.              Data Structures
  345.              NetUseAdd
  346.              NetUseDel
  347.              NetUseEnum
  348.              NetUseGetInfo
  349.              Use Category Example
  350.       User Category
  351.              Description
  352.              Data Structures
  353.              NetUserAdd
  354.              NetUserDel
  355.              NetUserEnum
  356.              NetUserGetGroups
  357.              NetUserGetInfo
  358.              NetUserModalsGet
  359.              NetUserModalsSet
  360.              NetUserPasswordSet
  361.              NetUserSetGroups
  362.              NetUserSetInfo
  363.              NetUserValidate2
  364.              User Category Example
  365.       Workstation Category
  366.              Description
  367.              Data Structures
  368.              NetWkstaGetInfo
  369.              NetWkstaSetInfo
  370.              NetWkstaSetUID2
  371.              Workstation Category Example
  372.  
  373.  Appendix A  Return Codes
  374.  
  375.       Return Codes by Class
  376.       LAN Manager and MS OS/2 Return Codes
  377.  
  378.  Appendix B  Upgrading LAN Manager 1.0 Applications
  379.  
  380.       Table of API Changes
  381.       Superseded API Functions
  382.              Superseded Function Descriptions
  383.              NetAuditOpen
  384.              NetErrorLogOpen
  385.              NetStatisticsClear
  386.              NetStatisticsGet
  387.              NetUserValidate
  388.              NetWkstaSetUID
  389.  
  390.  Appendix C  Creating LAN Manager Services
  391.  
  392.       A Simple Service
  393.       How a Service Works
  394.       Installing a Service
  395.              Reporting Installation Status
  396.              Disabling Standard Input and Output
  397.              Parsing Service Parameters
  398.              Installing the Signal Handler
  399.              Spawning the Application Thread
  400.              Completing Installation
  401.       Handling Signals
  402.              Example Service
  403.  
  404.  Appendix D  Building the Sample Programs
  405.  
  406.       Building SAMPLES.LIB
  407.       Building the Sample Programs
  408.       Binding the Sample Programs
  409.       Running the Programs
  410.              SAMPLES.C
  411.              SAMPLES.H
  412.  
  413.  Appendix E  NetBIOS Category
  414.  
  415.              Description
  416.              Data Structures
  417.              NetBiosClose
  418.              NetBiosEnum
  419.              NetBiosGetInfo
  420.              NetBiosOpen
  421.              NetBiosSubmit
  422.              NetBIOS Category Example
  423.  
  424.  Appendix F  Network Considerations for Named Pipes
  425.  
  426.              Description
  427.              MS-DOS Considerations
  428.              Named Pipes Category Example
  429.  
  430.  Appendix G  Workstation and Server Heuristics
  431.  
  432.              Workstation Heuristics
  433.              Server Heuristics
  434.  
  435.  Appendix H  Defined Constants
  436.  
  437.  
  438.  Glossary
  439.  
  440.  
  441.  Index
  442.  
  443.  
  444.  
  445.  
  446.  Before You Begin
  447.  ────────────────────────────────────────────────────────────────────────────
  448.  
  449.  The Microsoft(R) LAN Manager application programming interface (API) is the
  450.  set of functions, datatypes, structures, and constants that enable
  451.  applications to use and control network resources. The Microsoft LAN Manager
  452.  Programmer's Reference describes the components of the LAN Manager API.
  453.  
  454.  To use this book effectively, you should have a sound working knowledge of
  455.  Microsoft Operating System/2 (MS(R) OS/2) and be familiar with systems
  456.  programming in C or in assembly language.
  457.  
  458.  LAN Manager API functions work in essentially the same way with both the MS
  459.  OS/2 and MS-DOS(R) operating systems. However, this book primarily addresses
  460.  the MS OS/2 programming environment. Where appropriate, specific notes about
  461.  MS-DOS are included.
  462.  
  463.  
  464.  How to Use This Manual
  465.  
  466.  The Microsoft LAN Manager Programmer's Reference is intended to be your
  467.  master reference for Microsoft LAN Manager API functions. For background
  468.  information about using LAN Manager API functions, read Chapter 1, "Overview
  469.  of the LAN Manager API," which provides an introduction to the LAN Manager
  470.  API. Read Chapter 2, "API Function Descriptions," for information about
  471.  specific LAN Manager API function categories and individual functions. The
  472.  categories, and the functions within them, are arranged alphabetically.
  473.  
  474.  Read the appendixes for reference information about additional topics, such
  475.  as return codes, constants, named pipes, workstation and server heuristics,
  476.  and upgrading LAN Manager 1.0 applications. Use the glossary to find
  477.  definitions of general network terms and specific LAN Manager terms.
  478.  
  479.  
  480.  Notational Conventions
  481.  
  482.  This manual uses different type styles and special characters to distinguish
  483.  elements of text:
  484.  
  485. ╓┌─────────────────────────────────┌─────────────────────────────────────────╖
  486.  Convention                        Description
  487.  ────────────────────────────────────────────────────────────────────────────
  488.  bold                              Represents function names and portions
  489.                                    of syntax that must be typed exactly as
  490.                                    shown.
  491.  
  492.  italics                           Used for variables (such as parameter
  493.                                    names) and text that represents the type
  494.                                    of text to be entered rather than a
  495.                                    literal series of characters. Also used
  496.                                    for data structure names and names of
  497.                                    data structure elements.
  498.  
  499.  monospace                         Used for data structure syntax, API
  500.                                    function syntax, and code examples.
  501.  
  502.  FULL CAPITALS                     Represent filenames and pathnames.
  503.  
  504.  SMALL CAPITALS                    Used for return codes and constants.
  505.  
  506.  Convention                        Description
  507.  ────────────────────────────────────────────────────────────────────────────
  508. 
  509.  [brackets]                        Represent optional items in syntax
  510.                                    statements. For example, [password]
  511.                                    indicates a password can be used with
  512.                                    the command but is not required. Type
  513.                                    only the information within the brackets,
  514.                                    not the brackets themselves.
  515.  
  516.  . . . (ellipsis)                  Indicates that you can repeat the
  517.                                    previous item(s). For example,
  518.                                    devicename [. . .] indicates that you
  519.                                    can specify more than one device,
  520.                                    separating the devicenames with a space.
  521.  
  522.  ────────────────────────────────────────────────────────────────────────────
  523.  
  524.  
  525.  
  526.  
  527.  For More Information
  528.  
  529.  This manual gives general information about using the LAN Manager API, and
  530.  it details the individual components of the LAN Manager API. For information
  531.  about LAN Manager features, see your LAN Manager administrator's manual(s).
  532.  
  533.  
  534.  For information about MS OS/2, see your MS OS/2 programming manual(s). For
  535.  information about Microsoft Windows(tm), see your Microsoft Windows
  536.  programming manual(s).
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  Chapter 1  Overview of the LAN Manager API
  544.  ────────────────────────────────────────────────────────────────────────────
  545.  
  546.  The Microsoft LAN Manager application programming interface (API) is the set
  547.  of functions, datatypes, structures, and constants that allow applications
  548.  to use and control network resources.
  549.  
  550.  This chapter describes how to create applications that call the LAN Manager
  551.  API functions. You will learn the following:
  552.  
  553.  
  554.    ■   How to identify API functions, data structures, and variables
  555.  
  556.    ■   How to include API definitions in your application
  557.  
  558.    ■   How to call a LAN Manager API function
  559.  
  560.    ■   How to compile and link LAN Manager applications
  561.  
  562.    ■   Tips for debugging LAN Manager applications
  563.  
  564.  
  565.  For a detailed description of each LAN Manager API function and data
  566.  structure, see Chapter 2, "API Function Descriptions."
  567.  
  568.  
  569.  Identifying API Components
  570.  
  571.  The purpose of LAN Manager API functions, data structures, and variables is
  572.  encoded in their names. All function names and data structure names include
  573.  the name of the network resource. LAN Manager API functions and data
  574.  structures (and this manual) are organized by these categories of network
  575.  resources:
  576.  
  577.  (This figure may be found in the printed book.)
  578.  
  579.  
  580.  API Function Names
  581.  
  582.  LAN Manager API function names have at least three parts: a keyword (Dos or
  583.  Net), the name of the network resource manipulated by the function, and a
  584.  verb that identifies the action performed on the network resource.
  585.  
  586.  For example, the API function name NetUserAdd consists of the keyword Net,
  587.  the category User, and the verb Add. Functions in the User category control
  588.  user accounts. Add indicates that the NetUserAdd function adds a user to the
  589.  user accounts database.
  590.  
  591.  Some verbs appear in many categories: Add adds a resource, Del deletes a
  592.  resource, Enum lists all resources of a particular type, GetInfo returns
  593.  information about one particular resource, and SetInfo sets one or all
  594.  parameters for a particular resource.
  595.  
  596.  Other verbs describe familiar operations, such as Read, Write, Open, Clear,
  597.  and Close. Some verbs describe tasks that are specific to network resources,
  598.  such as Purge (for a communication-device or printer queue), Forward (for a
  599.  message name), and Raise (for an alert).
  600.  
  601.  An API function name can also contain an optional fourth part: the object of
  602.  the action. For example, the API function NetGroupDelUser deletes a user
  603.  from the specified group. This function differs from NetGroupDel, which
  604.  deletes the specified group from the user accounts database.
  605.  
  606.  
  607.  API Data Structure Names
  608.  
  609.  LAN Manager API functions use one or more data structures associated with
  610.  each network resource. A data structure name usually contains three parts:
  611.  the name of the resource, the word info, and the level of detail. For
  612.  example, the name share_info_0 indicates that the data structure contains
  613.  information about a share (shared resource) at level 0.
  614.  
  615.  LAN Manager API functions can accept or return information at different
  616.  levels of detail. Level 0 usually means the least detailed information
  617.  (often a single element). Level 1 usually includes all information provided
  618.  at level 0 plus additional data.
  619.  
  620.  A higher level of detail often (but not always) indicates that the data
  621.  structure is a superset of data structures provided at lower levels of
  622.  detail. For complete information about available levels and data structures,
  623.  see the "Data Structures" section for each function category in Chapter 2,
  624.  "API Function Descriptions."
  625.  
  626.  The three data structures of the Share category illustrate the levels of
  627.  detail. The share_info_0 data structure contains only the sharename of a
  628.  particular resource:
  629.  
  630.    struct share_info_0 {
  631.        char  shi0_netname[NNLEN+1];
  632.    };
  633.  
  634.  The constant NNLEN is defined in the NETCONS.H header file, along with other
  635.  constants that also specify string lengths.
  636.  
  637.  The share_info_1 data structure contains not only the sharename of the
  638.  resource, as provided at level 0, but also its type and an optional remark.
  639.  The shi1_pad1 element is used only to align the next structure element
  640.  (shi1_type) on a word boundary. Pad elements should not be used to store
  641.  data.
  642.  
  643.    struct share_info_1 {
  644.        char            shi1_netname[NNLEN+1];
  645.        char            shi1_pad1;
  646.        unsigned short  shi1_type;
  647.        char far *      shi1_remark;
  648.    };
  649.  
  650.  The share_info_2 data structure contains all information present in the
  651.  share_info_1 data structure plus additional information about the sharename
  652.  permissions, path, password, and the number of current and maximum uses:
  653.  
  654.    struct share_info_2 {
  655.        char            shi2_netname[NNLEN+1];
  656.        char            shi2_pad1;
  657.        unsigned short  shi2_type;
  658.        char far *      shi2_remark;
  659.        unsigned short  shi2_permissions;
  660.        unsigned short  shi2_max_uses;
  661.        unsigned short  shi2_current_uses;
  662.        char far *      shi2_path;
  663.        char            shi2_passwd[SHPWLEN+1];
  664.        char            shi2_pad2;
  665.    };
  666.  
  667.  
  668.  API Variable Names
  669.  
  670.  The variable names used in the API function prototypes follow the Microsoft
  671.  LAN Manager naming convention. These rules help anyone reading the code
  672.  identify the type and purpose of the variable. Although this naming
  673.  convention is not required to success- fully call the API functions, it is
  674.  recommended because it helps make applications more readable and improves
  675.  programming quality.
  676.  
  677.  Using the LAN Manager naming convention, variable names have three parts: a
  678.  prefix, a base type, and a qualifier.
  679.  
  680.  The prefix and base type are always written in lowercase characters. From
  681.  the prefix and base type, you can easily determine the type of a variable.
  682.  
  683.  Prefix - The prefix provides information about the variable type, such as
  684.  whether it is an array, count, index, or pointer. Prefixes can be combined
  685.  (for example, an array of pointers to indexes). If the base type completely
  686.  describes the variable, the variable name does not need a prefix. The
  687.  following prefixes are used in this manual:
  688.  
  689.  Prefix  Description  Example
  690.  ────────────────────────────────────────────────────────────────────────────
  691.  a       Array        char             achFileName[ ]
  692.  c       Count        unsigned short   cbAvail
  693.  i       Index        unsigned short   iArgv
  694.  p       Pointer      unsigned char *  pszServer
  695.  ────────────────────────────────────────────────────────────────────────────
  696.  
  697.  Base Type - The base type corresponds to the C-language type. For example,
  698.  ch is used for character, l for long, and s for short. The following base
  699.  types are used in this manual:
  700.  
  701. ╓┌──────────┌───────────────────────┌───────────────┌────────────────────────╖
  702.  Base Type  Description             Example
  703.  ────────────────────────────────────────────────────────────────────────────
  704.  b          Byte                    unsigned char   bMenuSel
  705.  ch         Character               char            chDriveLetter
  706.  f          Boolean flag            unsigned short  fSuccess
  707.  h          Handle                  unsigned short  hLogFile
  708.  l          Long integer            long            lSeconds
  709.  s          Short integer           short           sIdNumber
  710.  sz         Zero-terminated string  char            szRemark[ ]
  711.  uch        Unsigned character      unsigned char   uchBitMask
  712.  ul         Unsigned long           unsigned long   ulSeconds
  713.  us         Unsigned short          unsigned short  usReturnCode
  714.  ────────────────────────────────────────────────────────────────────────────
  715.  
  716.  
  717.  Qualifier - The qualifier is a short word or phrase that indicates how the
  718.  variable is used. The qualifier can use both uppercase and lowercase
  719.  characters; the first letter of each word is capitalized. For example, the
  720.  qualifier Available suggests that the variable has to do with some resource
  721.  that is available. The prefix and base type help pinpoint the variable's
  722.  meaning. If the complete variable name is cbAvailable, the name suggests the
  723.  variable contains a count of available bytes. The variable name fAvailable
  724.  suggests that the variable is a Boolean flag that indicates whether the
  725.  resource is available.
  726.  
  727.  For a description of the naming convention used with MS OS/2, see your MS
  728.  OS/2 programming manual(s).
  729.  
  730.  
  731.  Including LAN Manager API Definitions
  732.  
  733.  LAN Manager API function and data structure definitions are organized by
  734.  category. Your source program can include all the definitions needed for a
  735.  particular category of network resources by using the C-language #define
  736.  statement for that category and the #include <lan.h> statement.
  737.  
  738.  The LAN.H header file is the master file of the set of LAN Manager header
  739.  files. LAN.H is the LAN Manager equivalent of OS2.H, the MS OS/2 master
  740.  header file. When a constant is defined in your source file, the LAN.H file
  741.  includes all the header files associated with that category. You should
  742.  define constants for only those resource categories used in your
  743.  application.
  744.  
  745.  For example, use these statements to provide access to all functions,
  746.  datatypes, structures, and constants associated with workstations, and to
  747.  all LAN Manager error codes:
  748.  
  749.    #define INCL_NETWKSTA
  750.    #define INCL_NETERRORS
  751.    #include <lan.h>
  752.  
  753.  Programs that use the LAN.H master header file can be more easily maintained
  754.  than programs that specify individual header files. For examples of how to
  755.  use the LAN.H header file, see the "Example" section at the end of each
  756.  category in Chapter 2, "API Function Descriptions."
  757.  
  758.  The following table lists each LAN Manager API category and the constants
  759.  that must be defined to include definitions associated with that category:
  760.  
  761. ╓┌──────────────────────────────────┌────────────────────────────────────────╖
  762.  Category                           #define Constant
  763.  ────────────────────────────────────────────────────────────────────────────
  764.  All categories except print        INCL_NET
  765.  Errors for all categories          INCL_NETERRORS
  766.  Access Permissions                 INCL_NETACCESS
  767.  Alert                              INCL_NETALERT
  768.  Audit                              INCL_NETAUDIT
  769.  Character Device                   INCL_NETCHARDEV
  770.  Configuration                      INCL_NETCONFIG
  771.  Connection                         INCL_NETCONNECTION
  772.  Domain                             INCL_NETDOMAIN
  773.  Error Logging                      INCL_NETERRORLOG
  774.  File                               INCL_NETFILE
  775.  Group                              INCL_NETGROUP
  776.  Handle                             INCL_NETHANDLE
  777.  Mailslot                           INCL_NETMAILSLOT
  778.  Message                            INCL_NETMESSAGE
  779.  Category                           #define Constant
  780.  ────────────────────────────────────────────────────────────────────────────
  781. Message                            INCL_NETMESSAGE
  782.  NetBIOS                            INCL_NETBIOS
  783.  Print                              (Uses #include <pmspl.h>)
  784.  Remote Utility                     INCL_NETREMUTIL
  785.  Server                             INCL_NETSERVER
  786.  Service                            INCL_NETSERVICE
  787.  Session                            INCL_NETSESSION
  788.  Share                              INCL_NETSHARE
  789.  Statistics                         INCL_NETSTATS
  790.  Use                                INCL_NETUSE
  791.  User                               INCL_NETUSER
  792.  Workstation                        INCL_NETWKSTA
  793.  ────────────────────────────────────────────────────────────────────────────
  794.  
  795.  
  796.  Note that the categories relating to printer resources cannot be included
  797.  using this method. The structures and definitions for printer resources are
  798.  defined in the PMSPL.H header file. An application should include this
  799.  header file by using an #include statement:
  800.  
  801.    #include <pmspl.h>
  802.  
  803.  
  804.  Calling a LAN Manager API Function
  805.  
  806.  An API function call can succeed if the application has privilege to call
  807.  that API function and if the application provides all necessary parameters
  808.  in the correct format. One parameter required by many API functions is a
  809.  pointer to a buffer. If the buffer is used for input data, it must contain
  810.  the correct data; if the buffer is used for output data, it must be large
  811.  enough to contain the data returned by the API function. The application may
  812.  need to examine the codes returned by the API function and take specific
  813.  action.
  814.  
  815.  
  816.  Calling Privileges
  817.  
  818.  LAN Manager API functions check security on servers that have local security
  819.  enabled and on remote servers. If local security is not enabled, LAN Manager
  820.  does no local checking.
  821.  
  822.  The accounts database, NET.ACC, contains information about all users who are
  823.  allowed access to the computer's resources. Three privilege levels are
  824.  defined: admin, user, and guest. An account with user privilege can also
  825.  have up to four types of operator privilege (an operator privilege allows a
  826.  user to perform some limited administrative functions).  An account with
  827.  user privilege can have the print, comm, server, and accounts operator
  828.  privileges.
  829.  
  830.  
  831.  For remote computers and local computers running a secure shell or other
  832.  form of local security, each API function verifies that the user has
  833.  sufficient privilege to execute the function. For more information about
  834.  security and privilege levels, see your Microsoft LAN Manager
  835.  administrator's manual(s). If your account does not have correct privilege
  836.  levels, contact your system administrator.
  837.  
  838.  The privilege level required for each API function is specified in Chapter
  839.  2, "API Function Descriptions."
  840.  
  841.  
  842.  Parameter Formats
  843.  
  844.  The parameters needed to successfully call each LAN Manager API function are
  845.  defined in Chapter 2, "API Function Descriptions."
  846.  
  847.  Many parameters required by the API functions are ASCIIZ strings that
  848.  represent names such as computernames, sharenames, usernames, and pathnames.
  849.  (An ASCIIZ string is a sequence of ASCII characters terminated by the ASCII
  850.  character NUL, the C-language character constant '\0'. Remember to allow for
  851.  the final NUL when calculating string and buffer lengths.)
  852.  
  853.  One of the most common parameters required by LAN Manager API functions is a
  854.  servername. This parameter usually appears first in the API function call
  855.  and is specified in the function prototypes as pszServer. The servername
  856.  parameter specifies whether the function call is a local or remote call. A
  857.  null pointer or null string indicates that the operation is to be performed
  858.  on the local computer. An ASCIIZ string containing the servername must start
  859.  with two backslash characters (\\). Because the backslash is a special
  860.  character in the C language, you must use additional backslashes when
  861.  specifying servernames. For example, to specify the remote server named
  862.  MARKETING in a C-language program, use the following:
  863.  
  864.    pszServer = "\\\\MARKETING";
  865.  
  866.  Other parameters in LAN Manager API functions follow two naming conventions:
  867.  one for pathnames and one for all other names. Pathnames generally follow
  868.  the naming convention of the installed file system.
  869.  
  870.  The convention for all other names is very similar to the convention used
  871.  for file allocation table (FAT) file system names.
  872.  
  873.  These naming conventions are usually enforced only by Add functions. For
  874.  example, if the supplied name is incorrect, Add functions return an error
  875.  message that indicates an improper name was used; GetInfo functions usually
  876.  return an error that indicates the resource was not found.
  877.  
  878.  Length Restrictions - The file system defines the maximum length of the
  879.  pathname. The FAT file system supports names that have up to eight
  880.  characters, an optional period (.), and an optional filename extension with
  881.  as many as three characters. This is often called the "8.3" format.
  882.  
  883.  The high-performance file system (HPFS) supports longer names. The MS OS/2
  884.  function DosQSysInfo can be used to determine the maximum path length. For
  885.  more information, see your MS OS/2 programming manual(s).
  886.  
  887.  The maximum lengths of other names are defined by constants in the NETCONS.H
  888.  header file. For example, sharenames are limited to the number of characters
  889.  specified by the constant value NNLEN, defined in NETCONS.H. For more
  890.  information, see Appendix H, "Defined Constants."
  891.  
  892.  Character Restrictions  - The file system also defines the set of characters
  893.  allowed in network names. The FAT file system has the most restrictive rules
  894.  and HPFS has the least restrictive rules.
  895.  
  896.  Network names cannot use nonprinting ASCII characters (characters 0x00
  897.  through 0x1F) or any characters recognized as special characters by the
  898.  operating system command shell.
  899.  
  900.  The following characters are not allowed in network names on a computer that
  901.  has the FAT file system installed:
  902.  
  903.  \ / : * ? " <  > | , + = [ ] ;
  904.  
  905.  The following characters are not allowed in network names on a computer that
  906.  has HPFS installed:
  907.  
  908.  \ / : * ? " <  > |
  909.  
  910.  The period (.) is allowed in pathnames as permitted by the file system. It
  911.  is also allowed in other network names. The asterisk (*) is allowed as part
  912.  of the network name by some Mailslot category API functions. For more
  913.  information, see the Mailslot category functions in Chapter 2, "API Function
  914.  Descriptions."
  915.  
  916.  
  917.  Using Buffers with API Functions
  918.  
  919.  Many API functions require a pointer to a buffer. This pointer parameter is
  920.  often associated with other parameters that indicate the level of detail
  921.  provided in the buffer, the size of the buffer, the amount of data
  922.  successfully returned in the buffer, and the amount of data that was
  923.  available to be returned in the buffer.
  924.  
  925.  The buffer can be used for both output and input. GetInfo and Enum functions
  926.  use the buffer for return data; Add and SetInfo functions use the buffer for
  927.  input.
  928.  
  929.  Buffers for Return Data - GetInfo and Enum functions return data in the
  930.  supplied buffer. GetInfo functions return information about a single
  931.  resource; Enum functions return information about all instances of the
  932.  resource type. The supplied buffer should be large enough to contain all
  933.  data returned by the API function.
  934.  
  935.  This data usually consists of fixed-length and variable-length elements.
  936.  Fixed-length elements have a known, defined size; variable-length elements
  937.  are allowed to vary, up to a maximum length. (For example, ASCIIZ strings
  938.  are variable-length elements.) If the buffer cannot hold all available data,
  939.  the API function returns a code that indicates more information is
  940.  available.
  941.  
  942.  Even if the buffer is too small, GetInfo functions report the available
  943.  number of bytes, and Enum functions return the number of records.
  944.  Applications that must optimize memory use can make two calls to these
  945.  functions. So that the application can allocate a buffer large enough to
  946.  hold the return data, the first call determines the size of the buffer
  947.  needed to hold the return data. The second call can then fill the buffer
  948.  with data.
  949.  
  950.  For example, if the application supplies a null buffer pointer and a buffer
  951.  length of 0, the first GetInfo call returns the code NERR_BufTooSmall, but
  952.  also returns a pcbTotalAvail value that indicates the size of the return
  953.  data (in bytes). The application can then allocate a buffer this size and
  954.  make a second GetInfo call with valid buffer pointer and size values.
  955.  
  956.  GetInfo and SetInfo functions are commonly used together. You can call the
  957.  GetInfo function to learn the value of the parameters associated with the
  958.  resource, then change the values of the parameters and call the SetInfo
  959.  function to set the new values.
  960.  
  961.  Buffers for Input Data - Add and SetInfo functions set information about a
  962.  network resource. These functions require a parameter that points to a
  963.  buffer (pbBuffer); this buffer parameter is associated with other parameters
  964.  that represent the level of detail (sLevel) and the buffer size (cbBuffer).
  965.  
  966.  
  967.  SetInfo functions also require a parameter number code (sParmNum) that
  968.  specifies whether to set a single element or all elements of the data
  969.  structure for the resource. If sParmNum is PARMNUM_ALL, all elements are to
  970.  be set, and pbBuffer should point to a buffer that contains the complete
  971.  data structure at the specified level. If sParmNum is any other defined
  972.  value, it should contain a code that specifies the single element of the
  973.  data structure to be set, and pbBuffer should point to a variable that
  974.  contains the new value for that element.
  975.  
  976.  Add and SetInfo functions that specify a remote server will successfully
  977.  transmit variable-length data only if the pointers point outside the
  978.  supplied data buffer. This optimizing technique for remote calls minimizes
  979.  the amount of data transmitted over the network. The buffer is determined by
  980.  the pbBuffer and cbBuffer parameters. To assure that the data is
  981.  transmitted, the buffer size can be set to the size of the fixed-length data
  982.  structure, or all pointers can be reset to point to data that is not within
  983.  the buffer.
  984.  
  985.  To change a string to an empty string, you must use a valid pointer to an
  986.  empty string rather than using a null pointer. If a null pointer is used in
  987.  a SetInfo call, the string is not changed.
  988.  
  989.  
  990.  Interpreting Return Codes
  991.  
  992.  The name of the return code suggests the result. For example,
  993.  NERR_ServerNotStarted means, as the name suggests, that the Server service
  994.  must be started for the API function to succeed. The return code
  995.  NERR_BadTransactConfig indicates that a server is not configured to allow
  996.  interprocess communication. The description for this return code explains
  997.  that to allow remote API function requests, the server must share IPC$ (the
  998.  special interprocess communication resource).
  999.  
  1000.  Typical return codes for each function are included with that function's
  1001.  description in Chapter 2, "API Function Descriptions." Appendix A, "LAN
  1002.  Manager Return Codes," lists all codes that can be returned by LAN Manager
  1003.  API functions. For your con- venience, some MS OS/2 return codes are given;
  1004.  for more information about MS OS/2 return codes, see your MS OS/2
  1005.  programming manual(s).
  1006.  
  1007.  Descriptions of return codes are also available using the MS OS/2
  1008.  DosGetMessage function. If you supply the return code and the LAN Manager
  1009.  error message file NET.MSG as parameters, DosGetMessage returns a string
  1010.  that contains a description
  1011.  
  1012.  of the return code. For more information about DosGetMessage, see your MS
  1013.  OS/2 programming manual(s). For an example, see the Session category example
  1014.  program in Chapter 2, "API Function Descriptions."
  1015.  
  1016.  In a few cases, a code returned by an API function has a meaning that is
  1017.  relevant only for that API function. The "Remarks" section of each API
  1018.  function description in Chapter 2, "API Function Descriptions," describes
  1019.  how to interpret the return codes in these special cases.
  1020.  
  1021.  Return Codes Relating to the Buffer - The return codes NERR_BufTooSmall and
  1022.  ERROR_MORE_DATA are related not only to the buffer, but also to the buffer
  1023.  size and the byte count or record count parameters.
  1024.  
  1025.  If the buffer is too small to store the fixed-length part of the data
  1026.  record, GetInfo functions return NERR_BufTooSmall. In this case, all data in
  1027.  the return buffer is invalid, but the count  of available data bytes,
  1028.  pcbTotalAvail, is valid. The application can use the value of pcbTotalAvail
  1029.  to allocate a buffer large enough to contain the return data, and then make
  1030.  another GetInfo call to obtain the data. If the fixed-length part of the
  1031.  data record does fit but the variable-length part does not fit, GetInfo
  1032.  functions return ERROR_MORE_DATA, and all pointers to variable-length parts
  1033.  are set to NULL.
  1034.  
  1035.  If the available data cannot fit in the supplied buffer, Enum functions
  1036.  return the code ERROR_MORE_DATA. In this case, the Enum function stores in
  1037.  the return buffer as many complete data records as possible (both the
  1038.  fixed-length and variable-length parts). If the complete data record cannot
  1039.  be returned, the function tries to store its fixed-length part in the
  1040.  buffer. If only the fixed-length part fits, the function sets all pointers
  1041.  to variable-length parts to NULL, and then returns ERROR_MORE_DATA.
  1042.  
  1043.  When ERROR_MORE_DATA is returned by an Enum function, the value returned in
  1044.  pcEntriesRead does not necessarily represent the number of complete records
  1045.  in the buffer; it may represent the number of complete records and records
  1046.  that contain only the fixed-length element. In this case, all fixed-length
  1047.  data in the buffer is valid and the value of pcTotalEntries is valid, but
  1048.  some pointers to variable-length data may have been set to NULL if the
  1049.  variable-length data did not fit in the buffer.
  1050.  
  1051.  
  1052.  Compiling and Linking Applications
  1053.  
  1054.  LAN Manager applications can be compiled like any other applications for the
  1055.  target operating system. For example, Microsoft Windows applications
  1056.  compiled with the Microsoft C Optimizing Compiler should use the -Gw switch.
  1057.  
  1058.  
  1059.  The application should be linked with the libraries that contain the LAN
  1060.  Manager API functions. These functions reside in static-link or dynamic-link
  1061.  libraries. The type of link library used depends on the operating system
  1062.  used by the application (MS-DOS, Microsoft Windows 2.x, Microsoft Windows
  1063.  3.0, MS OS/2 1.1, or MS OS/2 1.2).
  1064.  
  1065.  LAN Manager operates in similar ways with MS OS/2, MS-DOS, and Windows,
  1066.  although the operating system allows more functionality when LAN Manager
  1067.  operates with MS OS/2. MS OS/2 supports multiple program threads and all LAN
  1068.  Manager services; when installed with HPFS, MS OS/2 also supports long file
  1069.  names. MS-DOS and Windows support only one program thread, FAT "8.3"
  1070.  filenames, and the Messenger, Netpopup, and Workstation services.
  1071.  
  1072.  In systems with MS-DOS, the LAN Manager API functions reside in the
  1073.  static-link library DOSLAN.LIB. MS-DOS applications are linked with
  1074.  static-link libraries in one step at link time. Only one library is needed.
  1075.  
  1076.  
  1077.  In systems with MS OS/2 and Windows, the LAN Manager API functions reside in
  1078.  the dynamic-link library (.DLL) file. Note that Microsoft Windows 2.x
  1079.  dynamic-link libraries use the file extension .EXE instead of .DLL.
  1080.  
  1081.  More than one link library may be needed for these operating system
  1082.  platforms, depending on the platform and the LAN Manager API functions
  1083.  called by the application. The Print category API functions reside in the
  1084.  PMSPL library; all other API functions reside in the LAN library. These are
  1085.  the link libraries:
  1086.  
  1087.                               Dynamic-Link
  1088.  Platform     Import Library  Library            Function Category
  1089.  ────────────────────────────────────────────────────────────────────────────
  1090.  MS OS/2 1.2  PMSPL.LIB       PMSPL.DLL          Print categories.
  1091.               LAN.LIB         NETAPI.DLL         All other categories.
  1092.                               MAILSLOT.DLL
  1093.                               NETOEM.DLL
  1094.  
  1095.  MS OS/2 1.1  NETSPOOL.LIB    NETSPOOL.DLL       Print categories.
  1096.               LAN.LIB         NETAPI.DLL         All other categories.
  1097.                               MAILSLOT.DLL
  1098.                               NETOEM.DLL
  1099.  
  1100.  Windows 3.0  PMSPL.LIB       PMSPL.DLL          Print categories.
  1101.               LAN.LIB         NETAPI.DLL         All other categories.
  1102.  
  1103.  Windows 2.x  PMSPL.LIB       PMSPL.EXE          Print categories.
  1104.               LAN.LIB         NETAPI.EXE         All other categories.
  1105.  
  1106.  ────────────────────────────────────────────────────────────────────────────
  1107.  
  1108.  
  1109.  
  1110.  Debugging Tips
  1111.  
  1112.  Incorrect buffer sizes and incorrect input parameters often cause software
  1113.  flaws in applications that call LAN Manager API functions. The following
  1114.  sections discuss some common problems and give some tips for debugging LAN
  1115.  Manager applications.
  1116.  
  1117.  
  1118.  Stack Overflow
  1119.  
  1120.  When calling LAN Manager API functions, be sure that at least 4 kilobytes
  1121.  (K) of stack is available, or the API function may exceed the stack limits
  1122.  and cause the application to fail. MS OS/2, MS OS/2 Presentation Manager,
  1123.  and Microsoft Windows also have their own minimum stack size requirements.
  1124.  LAN Manager applications using these platforms require an additional 4K of
  1125.  stack.
  1126.  
  1127.  
  1128.  Errors in Hard-Coded Values
  1129.  
  1130.  The LAN Manager header files define symbolic constants for bit values, mask
  1131.  values, and return codes. You should always use these defined constants
  1132.  instead of hard-coded numeric values. The use of symbolic constants makes an
  1133.  application program easier to debug and maintain.
  1134.  
  1135.  
  1136.  Errors During Pointer Type Conversion
  1137.  
  1138.  LAN Manager API functions, like MS OS/2 API functions, must be referenced
  1139.  using far calls. LAN Manager API function pointer parameters are defined as
  1140.  far pointers in the function prototypes.
  1141.  
  1142.  Other common software flaws can be avoided if you use LAN.H to access the
  1143.  LAN Manager header files.
  1144.  
  1145.  If you include the LAN Manager header files in small or medium memory model
  1146.  programs, all pointer parameters to LAN Manager API functions are promoted
  1147.  to far pointers.
  1148.  
  1149.  You should be aware that values for null pointers can be different for far
  1150.  and near pointers. Null far pointers have the segment:offset value 00:00;
  1151.  most compilers promote near pointers that have the value NULL to far
  1152.  pointers that have the value DS:00. Even when the program explicitly casts
  1153.  the near pointer as a far pointer before the LAN Manager API function call,
  1154.  the pointer is converted to the value DS:00.
  1155.  
  1156.  LAN Manager API functions have been designed to avoid many bugs resulting
  1157.  from pointer promotion. The API functions accept either a null string or a
  1158.  null pointer for the servername parameter. This takes advantage of a feature
  1159.  of many compilers: the compiler places four bytes containing the value 0 at
  1160.  the location DS:00. Although the near pointer promoted to a far pointer may
  1161.  no longer be a null pointer, it points to the location DS:00, which contains
  1162.  a null string.
  1163.  
  1164.  To avoid software flaws, use the symbolic constant NULL rather than the
  1165.  value 0, as shown in the following example:
  1166.  
  1167.    if ((p = malloc(SOME_SIZE)) == NULL) ...
  1168.  
  1169.  
  1170.  MS OS/2 Protection Violations and Faults
  1171.  
  1172.  MS OS/2 runs under protected mode. In protected mode, each process on a
  1173.  computer is protected from errors generated by another process. Software
  1174.  flaws in an application that might crash a system with MS-DOS are trapped by
  1175.  MS OS/2 as process-specific protection violations and faults. This fault may
  1176.  stop that process but will not affect other programs.
  1177.  
  1178.  Protection violations and faults in the LAN Manager API dynamic-link
  1179.  libraries are often caused by invalid input parameters and invalid buffer
  1180.  length values. When API functions access invalid data, MS OS/2 generates a
  1181.  protection fault. For example, a fault can occur if a pointer points beyond
  1182.  the end of a segment or outside a valid memory region.
  1183.  
  1184.  If a fault occurs within a LAN Manager dynamic-link library, check the
  1185.  values of the parameters passed to the API function.
  1186.  
  1187.  
  1188.  MS-DOS, Windows 2.x, and Real-Mode Windows 3.0 Applications
  1189.  
  1190.  Invalid pointer data can cause unpredictable results in LAN Manager
  1191.  applications with MS-DOS, Microsoft Windows 2.x, and real-mode Microsoft
  1192.  Windows 3.0 applications.
  1193.  
  1194.  Windows manages memory resources to optimize memory use and performance.
  1195.  Like any other Windows application, a LAN Manager application should
  1196.  carefully monitor its use of pointers. If Windows moves a data segment as
  1197.  part of its memory management, pointers may no longer be valid; you should
  1198.  lock all buffers before passing them to LAN Manager API functions. For more
  1199.  information, see your Microsoft Windows programming manual(s).
  1200.  
  1201.  
  1202.  Windows 3.0 Protected-Mode Applications
  1203.  
  1204.  Applications written for Microsoft Windows 3.0 can be executed in protected
  1205.  mode. Software flaws in applications running with Windows 3.0 protected mode
  1206.  cause the application to terminate, and control is returned to Windows 3.0.
  1207.  The user is notified of an unrecoverable program error.
  1208.  
  1209.  Software flaws in LAN Manager applications running with Microsoft Windows
  1210.  3.0 protected mode are often caused by invalid input parameters, invalid
  1211.  buffer lengths, and invalid pointer values. If an error occurs, check the
  1212.  values of the parameters passed to the API functions.
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  Chapter 2  API Function Descriptions
  1220.  ────────────────────────────────────────────────────────────────────────────
  1221.  
  1222.  This chapter provides detailed information about each LAN Manager
  1223.  application programming interface (API) function. It describes the syntax of
  1224.  each API function, describes operations the API function performs, and lists
  1225.  the data structures and header files the function uses.
  1226.  
  1227.  This chapter is divided into sections according to API function category.
  1228.  The following function categories are presented in this chapter:
  1229.  
  1230.  (This figure may be found in the printed book.)
  1231.  
  1232.  Each category begins with an overview that explains how the API functions in
  1233.  that category interrelate and how they work with LAN Manager. Data
  1234.  structures common to several or all of the functions are described.
  1235.  
  1236.  A detailed description of each API function follows the overview, and
  1237.  includes the operating system platforms supported by the API function, the
  1238.  privilege level required to successfully execute the API function, the
  1239.  function's syntax, and a detailed description of each parameter.
  1240.  
  1241.  The most common error codes returned by the function are also listed. A list
  1242.  of all error codes returned by the LAN Manager API functions is provided in
  1243.  Appendix A, "Return Codes."
  1244.  
  1245.  At the end of each section you will find an example that demonstrates calls
  1246.  to the API functions in that category.
  1247.  
  1248.  The category sections and the entries within them are ordered
  1249.  alphabetically. To make information easy to find and use, each category and
  1250.  each API within the category begins on a new page.
  1251.  
  1252.  The functionality of some LAN Manager API functions is different in LAN
  1253.  Manager 2.0 from LAN Manager 1.0. Some 1.0 functions are no longer
  1254.  supported, and some 1.0 functions, although still supported by LAN Manager
  1255.  2.0, have been superseded by new functions and should not be used. For
  1256.  information about the functions that have changed, see Appendix B,
  1257.  "Upgrading LAN Manager 1.0 Applications." The NetBIOS category is presented
  1258.  in Appendix E, "NetBIOS Category." It is recommended that you use Mailslot
  1259.  and Named Pipe API functions in LAN Manager 2.0 instead of the NetBIOS API
  1260.  functions.
  1261.  
  1262.  
  1263.  Format Reference Pages
  1264.  
  1265.  This section illustrates what you will see in each API function description.
  1266.  
  1267.  
  1268.  
  1269.  API Function
  1270.  
  1271.  The description of each API function begins with a general description of
  1272.  the purpose of the API function.
  1273.  
  1274.  
  1275.  Operating Systems Supported
  1276.  
  1277.  This section indicates whether the API function can be used remotely,
  1278.  locally only, or if it is not supported by a particular operating system.
  1279.  
  1280.  
  1281.  Privilege Level
  1282.  
  1283.  This section indicates the privilege level a user must have to execute this
  1284.  particular API function.
  1285.  
  1286.  
  1287.  Syntax
  1288.  
  1289.  This section lists the constants that must be defined so that the LAN.H
  1290.  header file will include the appropriate definitions. It also describes, in
  1291.  sequence, each of the parameters required to successfully call the API
  1292.  function.
  1293.  
  1294.  
  1295.  Return Codes
  1296.  
  1297.  This section lists the return codes the API function is most likely to
  1298.  return. Note that this list is not exhaustive. For a complete list of LAN
  1299.  Manager return codes, see Appendix A, "Return Codes."
  1300.  
  1301.  
  1302.  Remarks
  1303.  
  1304.  This section describes important details about the performance of the API
  1305.  function. You should take these details into consideration so your
  1306.  application can successfully call the API function and efficiently use its
  1307.  results.
  1308.  
  1309.  
  1310.  See Also
  1311.  
  1312.  This section refers you to other sections or chapters in this manual or to
  1313.  other manuals that may help you better understand and use the API function.
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  Access Permissions Category
  1321.  
  1322.  Access Permissions API functions examine or modify user or group access
  1323.  permissions for specified resources. Access Permissions API functions
  1324.  require that the user account subsystem (UAS) be started. On most computers
  1325.  the UAS is started when the Workstation service is started, provided a valid
  1326.  user accounts database file exists. On computers using the high-performance
  1327.  file system 386 (HPFS386) with local security enabled, the UAS is started
  1328.  automatically as part of the boot process.
  1329.  
  1330.  The Access Permissions category functions, datatypes, structures, and
  1331.  constants are defined in the NETCONS.H, NETERR.H, and ACCESS.H header files.
  1332.  A source program can access these definitions by defining the constants
  1333.  INCL_NETERRORS and INCL_NETACCESS, and including the master header file,
  1334.  LAN.H. For more information, see the "Example" section, later in this
  1335.  category.
  1336.  
  1337.  These are the Access Permissions API functions:
  1338.  
  1339.  
  1340.    ■   NetAccessAdd
  1341.  
  1342.    ■   NetAccessCheck
  1343.  
  1344.    ■   NetAccessDel
  1345.  
  1346.    ■   NetAccessEnum
  1347.  
  1348.    ■   NetAccessGetInfo
  1349.  
  1350.    ■   NetAccessGetUserPerms
  1351.  
  1352.    ■   NetAccessSetInfo
  1353.  
  1354.  
  1355.  
  1356.  Description
  1357.  
  1358.  An access control list (ACL) contains the name of a resource, an audit
  1359.  attribute field, and a list of access control entries. An access control
  1360.  entry (ACE) is a username or groupname and its corresponding access
  1361.  permissions.
  1362.  
  1363.  The audit attribute field defines what type of events will be audited for
  1364.  that resource. It is possible to audit various types of events, depending on
  1365.  whether the resource is a file or a directory. It is possible to audit
  1366.  events such as opening, writing, and deleting a file; creating or deleting a
  1367.  directory; and changing the ACL of the resource.
  1368.  
  1369.  There is no restriction on the number of ACLs for computers using HPFS386.
  1370.  Computers not using HPFS386 can have as many as 8192 ACLs defined. Each ACL
  1371.  can have as many as 64 ACEs.
  1372.  
  1373.  By default, non-admin class users have no access permissions. For a
  1374.  non-admin class user to access a resource on a remote server that has
  1375.  user-level security enabled or on a computer that has local security, there
  1376.  must be an ACL for the resource and there must be an ACE for the user. If
  1377.  local security is not enabled, non-admin class users can access all local
  1378.  resources.
  1379.  
  1380.  A user with admin privilege can access all resources, both local and remote,
  1381.  because LAN Manager does not check ACLs for this class of user.
  1382.  
  1383.  Access permission for a resource is determined according to the following
  1384.  rules:
  1385.  
  1386.  
  1387.    ■   File permissions override directory permissions. If a user is assigned
  1388.        specific permissions for a file, directory level permissions no longer
  1389.        apply to that file.
  1390.  
  1391.    ■   Individual permissions override group permissions. If a user is
  1392.        assigned specific individual permissions, group permissions no longer
  1393.        apply.
  1394.  
  1395.    ■   Group permissions are combined. If a user belongs to more than one
  1396.        group, the permissions are all the permissions for the groups to which
  1397.        the user belongs.
  1398.  
  1399.    ■   Access is checked for the guest user when there is no ACE for the user
  1400.        or for any groups to which the user belongs. If the guest account
  1401.        exists and has access to the resource, the user is granted that same
  1402.        level of access.
  1403.  
  1404.  
  1405.  Access permission is checked on three levels for file-system resources:
  1406.  first, the resource itself; then the parent of the resource; then the drive
  1407.  on which the resource is located. For example, in checking permission for
  1408.  the resource C:\XXX\YYY\ZZZ, the resource C:\XXX\YYY\ZZZ is searched for,
  1409.  then C:\XXX\YYY is searched for, and finally C: is searched for. Note that
  1410.  the last check is on the drive-level permissions, not the root directory of
  1411.  the drive.
  1412.  
  1413.  Access permission is also checked on three levels for logical resources:
  1414.  first, the resource itself; then the parent of the resource; then the root
  1415.  of the resource. For example, in checking permission for the resource
  1416.  \PIPE\XXX\YYY\ZZZ, the resource \PIPE\XXX\YYY\ZZZ is searched for, then
  1417.  \PIPE\XXX\YYY is searched for, and finally \PIPE is searched for.
  1418.  
  1419.  NetAccessAdd creates an ACL for a resource and sets username or groupname
  1420.  access permissions. NetAccessDel deletes the ACL for a resource.
  1421.  NetAccessGetInfo returns the ACL for a particular resource. NetAccessEnum
  1422.  returns information about all ACLs.
  1423.  
  1424.  Only users or applications with admin privilege or special permission for
  1425.  the resource can define or examine access permissions on a remote server or
  1426.  on a computer that has local security. Users have special permissions for a
  1427.  resource when they are granted ACCESS_PERM permission for that resource;
  1428.  this is also known as P permission.
  1429.  
  1430.  NetAccessCheck verifies whether a user has permission to perform a specified
  1431.  operation on a particular resource. If access permission is needed, you can
  1432.  use NetAccessSetInfo to change the ACL. NetAccessGetUserPerms returns a
  1433.  specified user's or group's permission for a specified resource.
  1434.  
  1435.  Note that the ACL does not specify permissions on a server that has
  1436.  share-level security. Each resource is verified on a share-by-share basis
  1437.  (each shared resource has its own password). After establishing a connection
  1438.  to a shared resource (by providing the appropriate password), users can
  1439.  access the resource any way they choose, as defined by the resource.
  1440.  
  1441.  All Access Permissions API functions executed on a remote server require
  1442.  that the server have user-level security. An attempt to execute an Access
  1443.  Permissions API function on a remote server that has share-level security
  1444.  returns the ERROR_NOT_SUPPORTED error code.
  1445.  
  1446.  
  1447.  Data Structures
  1448.  
  1449.  The sLevel parameter controls the level of information provided to or
  1450.  returned from the NetAccessAdd, NetAccessEnum, NetAccessGetInfo, and
  1451.  NetAccessSetInfo functions. NetAccessEnum and NetAccessGetInfo use either an
  1452.  access_info_0 or access_info_1 data structure. NetAccessAdd and
  1453.  NetAccessSetInfo use only an access_info_1 data structure.
  1454.  
  1455.  
  1456.  Access Permissions Information (level 0)
  1457.  
  1458.  The access_info_0 data structure has this format:
  1459.  
  1460.    struct access_info_0 {
  1461.        char far *  acc0_resource_name;
  1462.    };
  1463.  
  1464.  where
  1465.  
  1466.  acc0_resource_name
  1467.    Points to an ASCIIZ string that contains the name of a resource. The
  1468.    resource name cannot be a null string. Resources can be of the following
  1469.    types, and are specified using the associated name format:
  1470.  
  1471. ╓┌────────────────────────┌────────────────────────┌─────────────────────────╖
  1472.  Resource Type            Name Format              Comment
  1473.  ────────────────────────────────────────────────────────────────────────────
  1474.  Drive                    drive:                   No path is specified;
  1475.                                                    the drive must exist.
  1476.  
  1477.  Path                     \path                    No drive is specified;
  1478.                                                    the path need not exist.
  1479.  
  1480.  
  1481.  Directory                drive:\pathname          The path must exist.
  1482.  
  1483.  File                     drive:\pathname          The file must exist.
  1484.  
  1485.  UNC                      \\server\sharename\path  The path must exist.
  1486.  
  1487.  Pipe                     \pipe\pipename
  1488.  
  1489.  Printer queue            \print\queuename
  1490.  
  1491.  Communication-device     \comm\chardevqueue
  1492.  queue
  1493.  Resource Type            Name Format              Comment
  1494.  ────────────────────────────────────────────────────────────────────────────
  1495. queue
  1496.  
  1497.  ────────────────────────────────────────────────────────────────────────────
  1498.  
  1499.  
  1500.  
  1501.    Calls to Access Permissions functions can also use the universal naming
  1502.    convention (UNC) to access a device, computer, or resource over the
  1503.    network (for example, \\server\sharename\file.ext is a UNC name). If a UNC
  1504.    name is given, the function ignores any servername given in the pszServer
  1505.    parameter.
  1506.  
  1507.  
  1508.  Access Permissions Information (level 1)
  1509.  
  1510.  The access_info_1 data structure has this format:
  1511.  
  1512.    struct access_info_1 {
  1513.        char far *  acc1_resource_name;
  1514.        short       acc1_attr;
  1515.        short       acc1_count;
  1516.    };
  1517.  
  1518.  where
  1519.  
  1520.  acc1_resource_name
  1521.    Points to an ASCIIZ string that specifies the name of a particular
  1522.    resource. For more information, see the preceding section.
  1523.  
  1524.  acc1_attr
  1525.    Specifies the auditing attributes of acc1_resource_name. If acc1_attr is
  1526.    0, no auditing is required. If acc1_attr is 1, all access events should be
  1527.    audited. Other values indicate auditing of specific access events, as
  1528.    defined by the bits of acc1_attr, as follows:
  1529.  
  1530. ╓┌──────┌──────────────────────────────────────────────┌─────────────────────╖
  1531.  Bit    Files                                          Directories
  1532.  ────────────────────────────────────────────────────────────────────────────
  1533.  0      Audit all. When this bit is set, all access    Same.
  1534.         attempts are audited. No other bits in the
  1535.  Bit    Files                                          Directories
  1536.  ────────────────────────────────────────────────────────────────────────────
  1537.        attempts are audited. No other bits in the
  1538.         field can be set at the same time.
  1539.  
  1540.  1-2    Reserved; must be 0.                           Reserved; must be 0.
  1541.  
  1542.  3      Ignored.                                       Reserved.
  1543.  
  1544.  4      Successful opens.                              Reserved.
  1545.  
  1546.  5      Successful writes.                             Successful creates.
  1547.  
  1548.  6      Successful deletes/truncates.                  Successful deletes.
  1549.  
  1550.  7      Successful ACL changes.                        Same.
  1551.  
  1552.  8      Failed opens.                                  Reserved.
  1553.  
  1554.  9      Failed writes.                                 Failed creates.
  1555.  
  1556.  Bit    Files                                          Directories
  1557.  ────────────────────────────────────────────────────────────────────────────
  1558. 
  1559.  10     Failed deletes/truncates.                      Failed deletes.
  1560.  
  1561.  11     Failed ACL changes.                            Same.
  1562.  
  1563.  12-15  Reserved; must be 0.                           Reserved; must be 0.
  1564.  
  1565.  ────────────────────────────────────────────────────────────────────────────
  1566.  
  1567.  
  1568.  
  1569.    Other resources that can be accessed over the network, including printer
  1570.    queues, communication-device queues, and pipes, are audited the same way
  1571.    as files.
  1572.  
  1573.    When write auditing is enabled, the write audit record is generated the
  1574.    first time the record is opened with write permission.
  1575.  
  1576.    File size changes (including truncation) are audited under the control of
  1577.    the write audit bits, 5 and 9.
  1578.  
  1579.  acc1_count
  1580.    Specifies the number of access_list data structures that follow the
  1581.    access_info_1 data structure. As many as 64 access_list data structures
  1582.    can follow. The access_list structures define resource permissions for
  1583.    individual users or groups.
  1584.  
  1585.  
  1586.  Resource Permissions
  1587.  
  1588.  The access_list data structure has this format:
  1589.  
  1590.    struct access_list {
  1591.        char   acl_ugname[UNLEN+1];
  1592.        char   acl_ugname_pad_1;
  1593.        short  acl_access;
  1594.    };
  1595.  
  1596.  where
  1597.  
  1598.  acl_ugname
  1599.    Specifies an ASCIIZ string that contains a particular username or
  1600.    groupname. The constant UNLEN is defined in the NETCONS.H header file.
  1601.  
  1602.  acl_ugname_pad_1
  1603.    Aligns the next data structure element on a word boundary.
  1604.  
  1605.  acl_access
  1606.    Specifies the permissions for the username or groupname. The ACCESS.H
  1607.    header file defines these possible values:
  1608.  
  1609. ╓┌──────────────┌───────┌────────────────────────────────────────────────────╖
  1610.  Code           Value   Meaning
  1611.  ────────────────────────────────────────────────────────────────────────────
  1612.  ACCESS_READ    0x01    Permission to read data from a resource and, by
  1613.                         default, execute the resource.
  1614.  
  1615.  ACCESS_WRITE   0x02    Permission to write data to the resource.
  1616.  
  1617.  ACCESS_CREATE  0x04    Permission to create an instance of the resource
  1618.                         (for example, a file); data can be written to the
  1619.  Code           Value   Meaning
  1620.  ────────────────────────────────────────────────────────────────────────────
  1621.                        (for example, a file); data can be written to the
  1622.                         resource when creating it.
  1623.  
  1624.  ACCESS_EXEC    0x08    Permission to execute the resource.
  1625.  
  1626.  ACCESS_DELETE  0x10    Permission to delete the resource.
  1627.  
  1628.  ACCESS_ATRIB   0x20    Permission to modify the resource's attributes (for
  1629.                         example, the date and time a file was last
  1630.                         modified).
  1631.  
  1632.  ACCESS_PERM    0x40    Permission to modify the permissions (read, write,
  1633.                         create, execute, and delete) assigned to a resource
  1634.                         for a user or an application.
  1635.  
  1636.  ACCESS_ALL     0x7F    Permission to read, write, create, execute, or
  1637.                         delete a resource, or to modify attributes or
  1638.                         permissions.
  1639.  
  1640.  Code           Value   Meaning
  1641.  ────────────────────────────────────────────────────────────────────────────
  1642. 
  1643.  ACCESS_GROUP   0x8000  Permission for a particular group; this value
  1644.                         indicates that the entry is for a group.
  1645.  
  1646.  ────────────────────────────────────────────────────────────────────────────
  1647.  
  1648.  
  1649.  
  1650.  See Also
  1651.  
  1652.  For information about             See
  1653.  ────────────────────────────────────────────────────────────────────────────
  1654.  Connecting to resources           Use Category
  1655.  
  1656.  Sharing resources                 Share Category
  1657.  
  1658.  
  1659.  NetAccessAdd
  1660.  ────────────────────────────────────────────────────────────────────────────
  1661.  
  1662.  NetAccessAdd creates a new access control list (ACL) for a resource.
  1663.  
  1664.  
  1665.  Operating Systems Supported
  1666.  
  1667.  
  1668.    ■   MS OS/2 version 1.2, local and remote
  1669.  
  1670.    ■   MS OS/2 version 1.1, remote only
  1671.  
  1672.    ■   MS-DOS, remote only
  1673.  
  1674.  
  1675.  
  1676.  Privilege Level
  1677.  
  1678.  Admin privilege is required to successfully execute NetAccessAdd on a remote
  1679.  server or on a computer that has local security enabled.
  1680.  
  1681.  
  1682.  Syntax
  1683.  
  1684.    #define INCL_NETACCESS
  1685.    #define INCL_NETERRORS
  1686.    #include <lan.h>
  1687.  
  1688.    API_FUNCTION
  1689.    NetAccessAdd (const char far *  pszServer,
  1690.                  short             sLevel,
  1691.                  char far *        pbBuffer,
  1692.                  unsigned short    cbBuffer
  1693.                 );
  1694.  
  1695.  where
  1696.  
  1697.  pszServer
  1698.    Points to an ASCIIZ string that contains the name of the server on which
  1699.    to execute NetAccessAdd. A null pointer or null string specifies the local
  1700.    computer.
  1701.  
  1702.  sLevel
  1703.    Specifies the level of detail provided; must be 1.
  1704.  
  1705.  pbBuffer
  1706.    Points to the buffer that contains the data to be added. The buffer should
  1707.    contain an access_info_1 data structure that specifies the name of the
  1708.    resource for which to create an ACL, the resource's audit attributes, and
  1709.    a count of the number of access control entries that follow. The structure
  1710.    can be followed by access_list data structures that specify a username or
  1711.    groupname and associated access permissions for the resource.
  1712.  
  1713.  cbBuffer
  1714.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  1715.  
  1716.  Return Codes
  1717.  
  1718. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  1719.  Code                              Value   Meaning
  1720.  ────────────────────────────────────────────────────────────────────────────
  1721.  NERR_Success                      0       The function encountered no
  1722.                                            errors.
  1723.  
  1724.  Code                              Value   Meaning
  1725.  ────────────────────────────────────────────────────────────────────────────
  1726. 
  1727.  ERROR_ACCESS_DENIED               5       The user has insufficient
  1728.                                            privilege for this operation.
  1729.  
  1730.  ERROR_NOT_SUPPORTED               50      This network request is not
  1731.                                            supported.
  1732.  
  1733.  ERROR_BAD_NETPATH                 53      The network path was not found.
  1734.  
  1735.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  1736.  
  1737.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  1738.                                            invalid.
  1739.  
  1740.  ERROR_INVALID_LEVEL               124     The level for information
  1741.                                            retrieval or setting is invalid.
  1742.  
  1743.  NERR_RemoteOnly                   2106    This operation can be performed
  1744.                                            only on a server.
  1745.  Code                              Value   Meaning
  1746.  ────────────────────────────────────────────────────────────────────────────
  1747.                                           only on a server.
  1748.  
  1749.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  1750.  
  1751.  NERR_BadTransactConfig            2141    The server is not configured for
  1752.                                            this transaction: IPC$ is not
  1753.                                            shared.
  1754.  
  1755.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  1756.                                            user accounts database file,
  1757.                                            NET.ACC. This file should be in
  1758.                                            the ACCOUNTS subdirectory of the
  1759.                                            LANMAN directory.
  1760.  
  1761.  NERR_UserNotFound                 2221    The username was not found.
  1762.  
  1763.  NERR_ResourceNotFound             2222    The resource name was not found.
  1764.  
  1765.  NERR_ResourceExists               2225    The resource access record
  1766.  Code                              Value   Meaning
  1767.  ────────────────────────────────────────────────────────────────────────────
  1768. NERR_ResourceExists               2225    The resource access record
  1769.                                            already exists.
  1770.  
  1771.  NERR_ACFNotLoaded                 2227    The user accounts database is
  1772.                                            not active. This database must
  1773.                                            be active for the command to run.
  1774.  
  1775.  NERR_ACFNoRoom                    2228    The user accounts database is
  1776.                                            full.
  1777.  
  1778.  NERR_ACFTooManyLists              2230    Each resource can have no more
  1779.                                            than 64 access records defined.
  1780.  
  1781.  
  1782.  NERR_InvalidDatabase              2247    The user accounts database file,
  1783.                                            NET.ACC, is corrupted.
  1784.  
  1785.  NERR_InvalidComputer              2351    The specified computername is
  1786.                                            invalid.
  1787.  Code                              Value   Meaning
  1788.  ────────────────────────────────────────────────────────────────────────────
  1789.                                           invalid.
  1790.  
  1791.  NERR_CanNotGrowUASFile            2456    The user accounts database
  1792.                                            cannot be enlarged because the
  1793.                                            server's hard disk is full.
  1794.  
  1795.  ────────────────────────────────────────────────────────────────────────────
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  Remarks
  1801.  
  1802.  NetAccessAdd returns ERROR_NOT_SUPPORTED when executed remotely on a server
  1803.  that has share-level security.
  1804.  
  1805.  See Also
  1806.  
  1807.  For information about             See
  1808.  ────────────────────────────────────────────────────────────────────────────
  1809.  Add functions                     Chapter 1, "Overview of the LAN Manager
  1810.                                    API"
  1811.  
  1812.  Deleting an access control list   NetAccessDel
  1813.  
  1814.  Listing permissions and           NetAccessEnum
  1815.  resources
  1816.  
  1817.  Remote calls                      Chapter 1, "Overview of the LAN Manager
  1818.                                    API"
  1819.  
  1820.  
  1821.  NetAccessCheck
  1822.  ────────────────────────────────────────────────────────────────────────────
  1823.  
  1824.  NetAccessCheck verifies that a user has permission to perform a specified
  1825.  operation on a particular resource.
  1826.  
  1827.  
  1828.  Operating Systems Supported
  1829.  
  1830.  
  1831.    ■   MS OS/2 version 1.2, local only
  1832.  
  1833.    ■   MS OS/2 version 1.1 not supported
  1834.  
  1835.    ■   MS-DOS not supported
  1836.  
  1837.  
  1838.  
  1839.  Privilege Level
  1840.  
  1841.  Admin privilege is required to successfully execute NetAccessCheck on a
  1842.  computer that has local security enabled.
  1843.  
  1844.  
  1845.  Syntax
  1846.  
  1847.    #define INCL_NETACCESS
  1848.    #define INCL_NETERRORS
  1849.    #include <lan.h>
  1850.  
  1851.    API_FUNCTION
  1852.    NetAccessCheck (char far *            pszReserved,
  1853.                    char far *            pszUserName,
  1854.                    char far *            pszResource,
  1855.                    unsigned short        usOperation,
  1856.                    unsigned short far *  pusResult
  1857.                   );
  1858.  
  1859.  where
  1860.  
  1861.  pszReserved
  1862.    Reserved; must be set to NULL.
  1863.  
  1864.  pszUserName
  1865.    Points to an ASCIIZ string that contains a username. If pszUserName
  1866.    specifies a groupname, NetAccessCheck returns NERR_UserNotFound.
  1867.  
  1868.  pszResource
  1869.    Points to an ASCIIZ string that contains the name of the resource.
  1870.  
  1871.  usOperation
  1872.    Specifies the type of access operation requested. Any combination of the
  1873.    following operations can be requested, as defined in the ACCESS.H header
  1874.    file:
  1875.  
  1876. ╓┌──────────────┌──────┌─────────────────────────────────────────────────────╖
  1877.  Code           Value  Meaning
  1878.  ────────────────────────────────────────────────────────────────────────────
  1879.  ACCESS_READ    0x01   Permission to read data from a resource and, by
  1880.                        default, execute the resource.
  1881.  
  1882.  ACCESS_WRITE   0x02   Permission to write data to the resource.
  1883.  
  1884.  ACCESS_CREATE  0x04   Permission to create an instance of the resource
  1885.                        (for example, a file); data can be written to the
  1886.                        resource when creating it.
  1887.  
  1888.  ACCESS_EXEC    0x08   Permission to execute the resource.
  1889.  
  1890.  ACCESS_DELETE  0x10   Permission to delete the resource.
  1891.  
  1892.  Code           Value  Meaning
  1893.  ────────────────────────────────────────────────────────────────────────────
  1894. 
  1895.  ACCESS_ATRIB   0x20   Permission to modify the resource's attributes (for
  1896.                        example, the date and time a file was last modified).
  1897.  
  1898.  ACCESS_PERM    0x40   Permission to modify the permissions (read, write,
  1899.                        create, execute, and delete) assigned to a resource
  1900.                        for a user, group, or application.
  1901.  
  1902.  ACCESS_ALL     0x7F   Permission to read, write, create, execute, or
  1903.                        delete a resource, or to modify attributes or
  1904.                        permissions.
  1905.  
  1906.  ────────────────────────────────────────────────────────────────────────────
  1907.  
  1908.  
  1909.  
  1910.  pusResult
  1911.    Points to an unsigned short integer that specifies whether or not the
  1912.    operation is allowed. This parameter is valid only when NetAccessCheck
  1913.    returns NERR_Success. If the username has the requested permissions and
  1914.    the operation is allowed, pusResult is 0; otherwise, pusResult is set to
  1915.    ERROR_ACCESS_DENIED.
  1916.  
  1917.  Return Codes
  1918.  
  1919. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  1920.  Code                              Value   Meaning
  1921.  ────────────────────────────────────────────────────────────────────────────
  1922.  NERR_Success                      0       The function encountered no
  1923.                                            errors.
  1924.  
  1925.  ERROR_ACCESS_DENIED               5       The user has insufficient
  1926.                                            privilege for this operation.
  1927.  
  1928.  ERROR_NOT_SUPPORTED               50      This network request is not
  1929.                                            supported.
  1930.  
  1931.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  1932.                                            invalid.
  1933.  
  1934.  Code                              Value   Meaning
  1935.  ────────────────────────────────────────────────────────────────────────────
  1936. 
  1937.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  1938.                                            user accounts database file,
  1939.                                            NET.ACC. This file should be in
  1940.                                            the ACCOUNTS subdirectory of the
  1941.                                            LANMAN directory.
  1942.  
  1943.  NERR_UserNotFound                 2221    The username was not found, or a
  1944.                                            groupname was specified instead
  1945.                                            of a username.
  1946.  
  1947.  NERR_ACFNotLoaded                 2227    The user accounts database is
  1948.                                            not active. This database must
  1949.                                            be active for the command to run.
  1950.  
  1951.  NERR_InvalidDatabase              2247    The user accounts database file,
  1952.                                            NET.ACC, is corrupted.
  1953.  
  1954.  ────────────────────────────────────────────────────────────────────────────
  1955.  Code                              Value   Meaning
  1956.  ────────────────────────────────────────────────────────────────────────────
  1957. ────────────────────────────────────────────────────────────────────────────
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  Remarks
  1963.  
  1964.  If NetAccessCheck cannot find an entry for the resource/username combination
  1965.  on the specified server, it searches for an entry for the guest account, a
  1966.  special account set up for temporary users of the resource. In this case,
  1967.  the user has the same access permissions as the guest account. The guest
  1968.  account can be defined in the LANMAN.INI file, or it can be specified at
  1969.  server startup time. For more information about guest accounts, see your LAN
  1970.  Manager administrator's manual(s).
  1971.  
  1972.  See Also
  1973.  
  1974.  For information about             See
  1975.  ────────────────────────────────────────────────────────────────────────────
  1976.  Defining username or groupname    NetAccessAdd
  1977.  access permissions
  1978.  
  1979.  Listing all permissions and       NetAccessEnum
  1980.  resources
  1981.  
  1982.  
  1983.  NetAccessDel
  1984.  ────────────────────────────────────────────────────────────────────────────
  1985.  
  1986.  NetAccessDel deletes the access control list (ACL) for a particular
  1987.  resource.
  1988.  
  1989.  
  1990.  Operating Systems Supported
  1991.  
  1992.  
  1993.    ■   MS OS/2 version 1.2, local and remote
  1994.  
  1995.    ■   MS OS/2 version 1.1, remote only
  1996.  
  1997.    ■   MS-DOS, remote only
  1998.  
  1999.  
  2000.  
  2001.  Privilege Level
  2002.  
  2003.  Admin privilege or P permission for the resource is required to successfully
  2004.  execute NetAccessDel on a remote server or on a computer that has local
  2005.  security enabled.
  2006.  
  2007.  
  2008.  Syntax
  2009.  
  2010.    #define INCL_NETACCESS
  2011.    #define INCL_NETERRORS
  2012.    #include <lan.h>
  2013.  
  2014.    API_FUNCTION
  2015.    NetAccessDel (const char far *  pszServer,
  2016.                  char far *        pszResource
  2017.                 );
  2018.  
  2019.  where
  2020.  
  2021.  pszServer
  2022.    Points to an ASCIIZ string that contains the name of the server on which
  2023.    to execute NetAccessDel. A null pointer or null string specifies the local
  2024.    computer.
  2025.  
  2026.  pszResource
  2027.    Points to an ASCIIZ string that contains the name of the resource to
  2028.    delete.
  2029.  
  2030.  Return Codes
  2031.  
  2032. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  2033.  Code                              Value   Meaning
  2034.  ────────────────────────────────────────────────────────────────────────────
  2035.  NERR_Success                      0       The function encountered no
  2036.                                            errors.
  2037.  
  2038.  ERROR_ACCESS_DENIED               5       The user has insufficient
  2039.  Code                              Value   Meaning
  2040.  ────────────────────────────────────────────────────────────────────────────
  2041. ERROR_ACCESS_DENIED               5       The user has insufficient
  2042.                                            privilege for this operation.
  2043.  
  2044.  ERROR_NOT_SUPPORTED               50      This network request is not
  2045.                                            supported.
  2046.  
  2047.  ERROR_BAD_NETPATH                 53      The network path was not found.
  2048.  
  2049.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  2050.  
  2051.  NERR_RemoteOnly                   2106    This operation can be performed
  2052.                                            only on a server.
  2053.  
  2054.  NERR_BadTransactConfig            2141    The server is not configured for
  2055.                                            this transaction: IPC$ is not
  2056.                                            shared.
  2057.  
  2058.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  2059.                                            user accounts database file,
  2060.  Code                              Value   Meaning
  2061.  ────────────────────────────────────────────────────────────────────────────
  2062.                                           user accounts database file,
  2063.                                            NET.ACC. This file should be in
  2064.                                            the ACCOUNTS subdirectory of the
  2065.                                            LANMAN directory.
  2066.  
  2067.  NERR_ResourceNotFound             2222    The resource name was not found.
  2068.  
  2069.  NERR_ACFNotLoaded                 2227    The user accounts database is
  2070.                                            not active. This database must
  2071.                                            be active for the command to run.
  2072.  
  2073.  NERR_InvalidDatabase              2247    The user accounts database file,
  2074.                                            NET.ACC, is corrupted.
  2075.  
  2076.  NERR_InvalidComputer              2351    The specified computername is
  2077.                                            invalid.
  2078.  
  2079.  ────────────────────────────────────────────────────────────────────────────
  2080.  
  2081.  Code                              Value   Meaning
  2082.  ────────────────────────────────────────────────────────────────────────────
  2083. 
  2084.  
  2085.  
  2086.  
  2087.  Remarks
  2088.  
  2089.  NetAccessDel returns ERROR_NOT_SUPPORTED when executed remotely on a server
  2090.  that has share-level security.
  2091.  
  2092.  See Also
  2093.  
  2094.  For information about             See
  2095.  ────────────────────────────────────────────────────────────────────────────
  2096.  Defining username or groupname    NetAccessAdd
  2097.  access permissions
  2098.  
  2099.  Listing all permissions and       NetAccessEnum
  2100.  resources
  2101.  
  2102.  
  2103.  NetAccessEnum
  2104.  ────────────────────────────────────────────────────────────────────────────
  2105.  
  2106.  NetAccessEnum lists all access permissions records.
  2107.  
  2108.  It is recommended that you not use NetAccessEnum because it is unlikely to
  2109.  be supported in future releases of LAN Manager.
  2110.  
  2111.  
  2112.  Operating Systems Supported
  2113.  
  2114.  
  2115.    ■   MS OS/2 version 1.2, local and remote
  2116.  
  2117.    ■   MS OS/2 version 1.1, remote only
  2118.  
  2119.    ■   MS-DOS, remote only
  2120.  
  2121.  
  2122.  
  2123.  Privilege Level
  2124.  
  2125.  Admin privilege or P permission for the resource is required to successfully
  2126.  execute NetAccessEnum on a remote server or on a computer that has local
  2127.  security enabled.
  2128.  
  2129.  If NetAccessEnum is called by a non-admin class user, only those resources
  2130.  for which the user has P permission will be listed.
  2131.  
  2132.  
  2133.  Syntax
  2134.  
  2135.    #define INCL_NETACCESS
  2136.    #define INCL_NETERRORS
  2137.    #include <lan.h>
  2138.  
  2139.    API_FUNCTION
  2140.    NetAccessEnum (const char far *      pszServer,
  2141.                   char far *            pszBasePath,
  2142.                   short                 fsRecursive,
  2143.                   short                 sLevel,
  2144.                   char far *            pbBuffer,
  2145.                   unsigned short        cbBuffer,
  2146.                   unsigned short far *  pcEntriesRead,
  2147.                   unsigned short far *  pcTotalAvail
  2148.                  );
  2149.  
  2150.  where
  2151.  
  2152.  pszServer
  2153.    Points to an ASCIIZ string that contains the name of the server on which
  2154.    to execute NetAccessEnum. A null pointer or null string specifies the
  2155.    local computer.
  2156.  
  2157.  pszBasePath
  2158.    Points to an ASCIIZ string that contains a base pathname for the
  2159.    resources. A null pointer or null string means no base path is to be used.
  2160.    The path can be specified as a universal naming convention (UNC) pathname.
  2161.  
  2162.  fsRecursive
  2163.    Enables or disables recursive searching. If fsRecursive is 0,
  2164.    NetAccessEnum returns entries only for the resource named as the base path
  2165.    by pszBasePath and for the resources directly below that base path. If
  2166.    fsRecursive is nonzero, NetAccessEnum returns entries for all access
  2167.    control lists (ACLs) that have pszBasePath at the beginning of the
  2168.    resource name. The fsRecursive parameter interacts with pszBasePath in the
  2169.    following way:
  2170.  
  2171.  fsRecursive  pszBasePath = NULL             pszBasePath set
  2172.  ────────────────────────────────────────────────────────────────────────────
  2173.  0            Nondirectory and nonfile       The path itself and all
  2174.               resources are listed (\comm,   resources immediately below
  2175.               \pipe, \print).                the path are listed.
  2176.  
  2177.  1            All resources are listed.      The path itself and all
  2178.                                              resources anywhere below
  2179.                                              the path are listed.
  2180.  
  2181.  ────────────────────────────────────────────────────────────────────────────
  2182.  
  2183.  
  2184.  sLevel
  2185.    Specifies the level of detail (0 or 1) requested.
  2186.  
  2187.  pbBuffer
  2188.    Points to the buffer in which to store the returned data. On a successful
  2189.    return, the buffer contains a sequence of access_info_X data structures,
  2190.    where X is 0 or 1, depending on the level of detail requested. If called
  2191.    at level 1, each access_info_1  data structure is followed by as many
  2192.    access_list data structures as specified in the acc1_count element of that
  2193.    access_info_1 data structure.
  2194.  
  2195.  cbBuffer
  2196.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  2197.  
  2198.  pcEntriesRead
  2199.    Points to an unsigned short integer that specifies how many entries were
  2200.    returned. This count is valid only if NetAccessEnum returns NERR_Success
  2201.    or ERROR_MORE_DATA.
  2202.  
  2203.  pcTotalAvail
  2204.    Points to an unsigned short integer that specifies how many entries were
  2205.    available. This count is valid only if NetAccessEnum returns NERR_Success
  2206.    or ERROR_MORE_DATA.
  2207.  
  2208.  Return Codes
  2209.  
  2210. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  2211.  Code                              Value   Meaning
  2212.  ────────────────────────────────────────────────────────────────────────────
  2213.  NERR_Success                      0       The function encountered no
  2214.                                            errors.
  2215.  
  2216.  ERROR_ACCESS_DENIED               5       The user has insufficient
  2217.                                            privilege for this operation.
  2218.  
  2219.  ERROR_NOT_SUPPORTED               50      This network request is not
  2220.                                            supported.
  2221.  
  2222.  ERROR_BAD_NETPATH                 53      The network path was not found.
  2223.  
  2224.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  2225.  
  2226.  ERROR_INVALID_LEVEL               124     The level for information
  2227.                                            retrieval or setting is invalid.
  2228.  Code                              Value   Meaning
  2229.  ────────────────────────────────────────────────────────────────────────────
  2230.                                           retrieval or setting is invalid.
  2231.  
  2232.  ERROR_MORE_DATA                   234     Additional data is available.
  2233.  
  2234.  NERR_RemoteOnly                   2106    This operation can be performed
  2235.                                            only on a server.
  2236.  
  2237.  NERR_BadTransactConfig            2141    The server is not configured for
  2238.                                            this transaction: IPC$ is not
  2239.                                            shared.
  2240.  
  2241.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  2242.                                            user accounts database file,
  2243.                                            NET.ACC. This file should be in
  2244.                                            the ACCOUNTS subdirectory of the
  2245.                                            LANMAN directory.
  2246.  
  2247.  NERR_ResourceNotFound             2222    The resource name was not found.
  2248.  
  2249.  Code                              Value   Meaning
  2250.  ────────────────────────────────────────────────────────────────────────────
  2251. 
  2252.  NERR_ACFNotLoaded                 2227    The user accounts database is
  2253.                                            not active. This database must
  2254.                                            be active for the command to run.
  2255.  
  2256.  NERR_InvalidDatabase              2247    The user accounts database file,
  2257.                                            NET.ACC, is corrupted.
  2258.  
  2259.  NERR_InvalidComputer              2351    The specified computername is
  2260.                                            invalid.
  2261.  
  2262.  ────────────────────────────────────────────────────────────────────────────
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  Remarks
  2268.  
  2269.  The pszBasePath parameter limits the entries returned by NetAccessEnum. If
  2270.  pszBasePath points to a string that is not null, it serves as a prefix for
  2271.  the pathname. For example, if pszBasePath is C:\PROG, NetAccessEnum returns
  2272.  access permissions records for resources that begin with C:\PROG (such as
  2273.  C:\PROGRAM, C:\PROG\TEST.EXE, and C:\PROGDIR\SUBDIR\SUBTEST.EXE). The
  2274.  resource names are returned with the base path omitted from the front of the
  2275.  name, and the resource names are not returned in any particular order.
  2276.  
  2277.  The pcTotalAvail parameter points to an unsigned short integer that
  2278.  specifies how many entries were available for the given pszBasePath and
  2279.  fsRecursive parameters, not the total number of entries in the access file.
  2280.  NetAccessEnum can provide as many as 64K of data for any given base path.
  2281.  
  2282.  If more data is available than can fit in the buffer, NetAccessEnum returns
  2283.  the code ERROR_MORE_DATA. More data can be read by increasing the size of
  2284.  the buffer or by calling NetAccessEnum with the same size buffer but
  2285.  different base paths.
  2286.  
  2287.  With computers using the high-performance file system 386 (HPFS386), HPFS
  2288.  files have their associated ACL information stored on the disk with the
  2289.  file. This is unlike non-HPFS386 systems, where the ACL information is
  2290.  grouped in the resource database. If NetAccessEnum is used with the
  2291.  recursive switch set and no pszBasePath, a complete downward traversal of
  2292.  each HPFS drive is necessary. This can cause the call to be substantially
  2293.  slower on an HPFS386 system than on a non-HPFS386 system. It is recommended
  2294.  that a base path be provided when using NetAccessEnum with the recursive
  2295.  flag enabled, so that only the information needed is returned.
  2296.  
  2297.  NetAccessEnum returns ERROR_NOT_SUPPORTED when executed remotely on a server
  2298.  that has share-level security.
  2299.  
  2300.  See Also
  2301.  
  2302.  For information about             See
  2303.  ────────────────────────────────────────────────────────────────────────────
  2304.  Defining access permissions       NetAccessAdd
  2305.  
  2306.  Enum functions                    Chapter 1, "Overview of the LAN Manager
  2307.                                    API"
  2308.  
  2309.  Retrieving the access             NetAccessGetInfo
  2310.  permissions for a specific
  2311.  resource
  2312.  
  2313.  Verifying the access permissions  NetAccessCheck
  2314.  for a resource
  2315.  
  2316.  
  2317.  NetAccessGetInfo
  2318.  ────────────────────────────────────────────────────────────────────────────
  2319.  
  2320.  NetAccessGetInfo retrieves the access control list (ACL) for a specific
  2321.  resource.
  2322.  
  2323.  
  2324.  Operating Systems Supported
  2325.  
  2326.  
  2327.    ■   MS OS/2 version 1.2, local and remote
  2328.  
  2329.    ■   MS OS/2 version 1.1, remote only
  2330.  
  2331.    ■   MS-DOS, remote only
  2332.  
  2333.  
  2334.  
  2335.  Privilege Level
  2336.  
  2337.  Admin privilege or P permission for the resource is required to successfully
  2338.  execute NetAccessGetInfo on a remote server or on a computer that has local
  2339.  security enabled.
  2340.  
  2341.  
  2342.  Syntax
  2343.  
  2344.    #define INCL_NETACCESS
  2345.    #define INCL_NETERRORS
  2346.    #include <lan.h>
  2347.  
  2348.    API_FUNCTION
  2349.    NetAccessGetInfo (const char far *      pszServer,
  2350.                      char far *            pszResource,
  2351.                      short                 sLevel,
  2352.                      char far *            pbBuffer,
  2353.                      unsigned short        cbBuffer,
  2354.                      unsigned short far *  pcbTotalAvail
  2355.                     );
  2356.  
  2357.  where
  2358.  
  2359.  pszServer
  2360.    Points to an ASCIIZ string that contains the name of the server on which
  2361.    to execute NetAccessGetInfo. A null pointer or null string specifies the
  2362.    local computer.
  2363.  
  2364.  pszResource
  2365.    Points to an ASCIIZ string that contains the name of the resource.
  2366.  
  2367.  sLevel
  2368.    Specifies the level of detail (0 or 1) requested.
  2369.  
  2370.  pbBuffer
  2371.    Points to the buffer in which to store the returned data. On a successful
  2372.    return, the buffer contains an access_info_X data structure, where X is 0
  2373.    or 1, depending on the level of detail requested. If called at level 1,
  2374.    the access_info_1 data structure is followed by as many access_list data
  2375.    structures as specified in the acc1_count element of that access_info_1
  2376.    data structure.
  2377.  
  2378.  cbBuffer
  2379.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  2380.  
  2381.  pcbTotalAvail
  2382.    Points to an unsigned short integer that specifies how many bytes of
  2383.    information are available to be returned in the buffer. This count is
  2384.    valid only if NetAccessGetInfo returns NERR_Success, ERROR_MORE_DATA, or
  2385.    NERR_BufTooSmall.
  2386.  
  2387.  Return Codes
  2388.  
  2389. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  2390.  Code                              Value   Meaning
  2391.  ────────────────────────────────────────────────────────────────────────────
  2392.  NERR_Success                      0       The function encountered no
  2393.                                            errors.
  2394.  
  2395.  ERROR_ACCESS_DENIED               5       The user has insufficient
  2396.  Code                              Value   Meaning
  2397.  ────────────────────────────────────────────────────────────────────────────
  2398. ERROR_ACCESS_DENIED               5       The user has insufficient
  2399.                                            privilege for this operation.
  2400.  
  2401.  ERROR_NOT_SUPPORTED               50      This network request is not
  2402.                                            supported.
  2403.  
  2404.  ERROR_BAD_NETPATH                 53      The network path was not found.
  2405.  
  2406.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  2407.  
  2408.  ERROR_INVALID_LEVEL               124     The level for information
  2409.                                            retrieval or setting is invalid.
  2410.  
  2411.  ERROR_MORE_DATA                   234     Additional data is available.
  2412.  
  2413.  NERR_RemoteOnly                   2106    This operation can be performed
  2414.                                            only on a server.
  2415.  
  2416.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  2417.  Code                              Value   Meaning
  2418.  ────────────────────────────────────────────────────────────────────────────
  2419. NERR_BufTooSmall                  2123    The supplied buffer is too small.
  2420.  
  2421.  NERR_BadTransactConfig            2141    The server is not configured for
  2422.                                            this transaction: IPC$ is not
  2423.                                            shared.
  2424.  
  2425.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  2426.                                            user accounts database file,
  2427.                                            NET.ACC. This file should be in
  2428.                                            the ACCOUNTS subdirectory of the
  2429.                                            LANMAN directory.
  2430.  
  2431.  NERR_ResourceNotFound             2222    The resource name was not found.
  2432.  
  2433.  NERR_ACFNotLoaded                 2227    The user accounts database is
  2434.                                            not active. This database must
  2435.                                            be active for the command to run.
  2436.  
  2437.  NERR_InvalidDatabase              2247    The user accounts database file,
  2438.  Code                              Value   Meaning
  2439.  ────────────────────────────────────────────────────────────────────────────
  2440. NERR_InvalidDatabase              2247    The user accounts database file,
  2441.                                            NET.ACC, is corrupted.
  2442.  
  2443.  NERR_InvalidComputer              2351    The specified computername is
  2444.                                            invalid.
  2445.  
  2446.  ────────────────────────────────────────────────────────────────────────────
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  Remarks
  2452.  
  2453.  One way to determine the size of the data buffer required is to first call
  2454.  NetAccessGetInfo with cbBuffer set to 0. NetAccessGetInfo then returns in
  2455.  pcbTotalAvail the buffer size required (in bytes).
  2456.  
  2457.  NetAccessGetInfo returns ERROR_NOT_SUPPORTED when executed remotely on a
  2458.  server that has share-level security.
  2459.  
  2460.  See Also
  2461.  
  2462.  For information about             See
  2463.  ────────────────────────────────────────────────────────────────────────────
  2464.  GetInfo functions                 Chapter 1, "Overview of the LAN Manager
  2465.                                    API"
  2466.  
  2467.  Listing all resources and         NetAccessEnum
  2468.  permissions on a server
  2469.  
  2470.  Modifying the current             NetAccessSetInfo
  2471.  permissions for a resource
  2472.  
  2473.  
  2474.  NetAccessGetUserPerms
  2475.  ────────────────────────────────────────────────────────────────────────────
  2476.  
  2477.  NetAccessGetUserPerms returns a specified user's or group's access
  2478.  permissions for a particular resource.
  2479.  
  2480.  
  2481.  Operating Systems Supported
  2482.  
  2483.  
  2484.    ■   MS OS/2 version 1.2, local and remote
  2485.  
  2486.    ■   MS OS/2 version 1.1, remote only
  2487.  
  2488.    ■   MS-DOS, remote only
  2489.  
  2490.  
  2491.  
  2492.  Privilege Level
  2493.  
  2494.  Admin privilege or P permission for the resource is required to successfully
  2495.  execute NetAccessGetUserPerms on a remote server or on a computer that has
  2496.  local security enabled, except when users request their own access
  2497.  permissions. In this case, no special privilege is required.
  2498.  
  2499.  
  2500.  Syntax
  2501.  
  2502.    #define INCL_NETACCESS
  2503.    #define INCL_NETERRORS
  2504.    #include <lan.h>
  2505.  
  2506.    API_FUNCTION
  2507.    NetAccessGetUserPerms (char far  *           pszServer,
  2508.                           char far  *           pszUgName,
  2509.                           char far  *           pszResource,
  2510.                           unsigned short far *  pusPerms
  2511.                          );
  2512.  
  2513.  where
  2514.  
  2515.  pszServer
  2516.    Points to an ASCIIZ string that contains the name of the server on which
  2517.    to execute NetAccessGetUserPerms. A null pointer or null string specifies
  2518.    the local computer.
  2519.  
  2520.  pszUgName
  2521.    Points to an ASCIIZ string that contains the name of the user or group to
  2522.    query.
  2523.  
  2524.  pszResource
  2525.    Points to an ASCIIZ string that contains the name of the resource.
  2526.  
  2527.  pusPerms
  2528.    Points to a field in which the permission bit field is returned.
  2529.  
  2530.  Return Codes
  2531.  
  2532. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  2533.  Code                              Value   Meaning
  2534.  ────────────────────────────────────────────────────────────────────────────
  2535.  NERR_Success                      0       The function encountered no
  2536.                                            errors.
  2537.  
  2538.  ERROR_ACCESS_DENIED               5       The user has insufficient
  2539.                                            privilege for this operation.
  2540.  
  2541.  ERROR_NOT_SUPPORTED               50      This network request is not
  2542.                                            supported.
  2543.  Code                              Value   Meaning
  2544.  ────────────────────────────────────────────────────────────────────────────
  2545.                                           supported.
  2546.  
  2547.  ERROR_BAD_NETPATH                 53      The network path was not found.
  2548.  
  2549.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  2550.  
  2551.  NERR_RemoteOnly                   2106    This operation can be performed
  2552.                                            only on a server.
  2553.  
  2554.  NERR_BadTransactConfig            2141    The server is not configured for
  2555.                                            this transaction: IPC$ is not
  2556.                                            shared.
  2557.  
  2558.  NERR_InvalidAPI                   2142    The requested API is not
  2559.                                            supported on the remote server.
  2560.  
  2561.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  2562.                                            user accounts database file,
  2563.                                            NET.ACC. This file should be in
  2564.  Code                              Value   Meaning
  2565.  ────────────────────────────────────────────────────────────────────────────
  2566.                                           NET.ACC. This file should be in
  2567.                                            the ACCOUNTS subdirectory of the
  2568.                                            LANMAN directory.
  2569.  
  2570.  NERR_UserNotFound                 2221    The username was not found.
  2571.  
  2572.  NERR_ResourceNotFound             2222    The resource name was not found.
  2573.  
  2574.  NERR_ACFNotLoaded                 2227    The user accounts database is
  2575.                                            not active. This database must
  2576.                                            be active for the command to run.
  2577.  
  2578.  NERR_InvalidDatabase              2247    The user accounts database file,
  2579.                                            NET.ACC, is corrupted.
  2580.  
  2581.  NERR_InvalidComputer              2351    The specified computername is
  2582.                                            invalid.
  2583.  
  2584.  ────────────────────────────────────────────────────────────────────────────
  2585.  Code                              Value   Meaning
  2586.  ────────────────────────────────────────────────────────────────────────────
  2587. ────────────────────────────────────────────────────────────────────────────
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  Remarks
  2593.  
  2594.  The permissions returned are based on the user's entry in the access control
  2595.  list. If the user does not have an entry, the permissions for any groups to
  2596.  which the user belongs are returned.
  2597.  
  2598.  NetAccessGetUserPerms returns ERROR_NOT_SUPPORTED when executed remotely on
  2599.  a server that has share-level security.
  2600.  
  2601.  
  2602.  NetAccessSetInfo
  2603.  ────────────────────────────────────────────────────────────────────────────
  2604.  
  2605.  NetAccessSetInfo changes the access control list (ACL) for a resource.
  2606.  
  2607.  
  2608.  Operating Systems Supported
  2609.  
  2610.  
  2611.    ■   MS OS/2 version 1.2, local and remote
  2612.  
  2613.    ■   MS OS/2 version 1.1, remote only
  2614.  
  2615.    ■   MS-DOS, remote only
  2616.  
  2617.  
  2618.  
  2619.  Privilege Level
  2620.  
  2621.  Admin privilege or P permission for the resource is required to successfully
  2622.  execute NetAccessSetInfo on a remote server or on a computer that has local
  2623.  security enabled.
  2624.  
  2625.  
  2626.  Syntax
  2627.  
  2628.    #define INCL_NETACCESS
  2629.    #define INCL_NETERRORS
  2630.    #include <lan.h>
  2631.  
  2632.    API_FUNCTION
  2633.    NetAccessSetInfo (const char far *  pszServer,
  2634.                      char far *        pszResource,
  2635.                      short             sLevel,
  2636.                      char far *        pbBuffer,
  2637.                      unsigned short    cbBuffer,
  2638.                      short             sParmNum
  2639.                     );
  2640.  
  2641.  where
  2642.  
  2643.  pszServer
  2644.    Points to an ASCIIZ string that contains the name of the server on which
  2645.    to execute NetAccessSetInfo. A null pointer or null string specifies the
  2646.    local computer.
  2647.  
  2648.  pszResource
  2649.    Points to an ASCIIZ string that contains the name of the resource.
  2650.  
  2651.  sLevel
  2652.    Specifies the level of detail provided; must be 1.
  2653.  
  2654.  pbBuffer
  2655.    Points to the data to be set.
  2656.  
  2657.  cbBuffer
  2658.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  2659.  
  2660.  sParmNum
  2661.    Specifies whether to reset the entire ACL or to change only the attribute
  2662.    element. If sParmNum is PARMNUM_ALL, pbBuffer must point to an
  2663.    access_info_1 data structure that can be followed by access_list data
  2664.    structures. The entire set of access control entries (ACEs) in the ACL is
  2665.    then replaced by this new data. The only other valid value for sParmNum is
  2666.    ACCESS_ATTR_PARMNUM, which indicates that the acc1_attr element of the
  2667.    access_info_1 data structure is to be set (acc1_attr is the only element
  2668.    of the structure that can be set individually). When sParmNum is
  2669.    ACCESS_ATTR_PARMNUM, pbBuffer must point to a valid value for acc1_attr,
  2670.    and the ACL remains unaltered.
  2671.  
  2672.  Return Codes
  2673.  
  2674. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  2675.  Code                              Value   Meaning
  2676.  ────────────────────────────────────────────────────────────────────────────
  2677.  NERR_Success                      0       The function encountered no
  2678.                                            errors.
  2679.  
  2680.  ERROR_ACCESS_DENIED               5       The user has insufficient
  2681.                                            privilege for this operation.
  2682.  
  2683.  ERROR_NOT_SUPPORTED               50      This network request is not
  2684.                                            supported.
  2685.  
  2686.  ERROR_BAD_NETPATH                 53      The network path was not found.
  2687.  
  2688.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  2689.  
  2690.  Code                              Value   Meaning
  2691.  ────────────────────────────────────────────────────────────────────────────
  2692. 
  2693.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  2694.                                            invalid.
  2695.  
  2696.  ERROR_INVALID_LEVEL               124     The level for information
  2697.                                            retrieval or setting is invalid.
  2698.  
  2699.  NERR_RemoteOnly                   2106    This operation can be performed
  2700.                                            only on a server.
  2701.  
  2702.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  2703.  
  2704.  NERR_BadTransactConfig            2141    The server is not configured for
  2705.                                            this transaction: IPC$ is not
  2706.                                            shared.
  2707.  
  2708.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  2709.                                            user accounts database file,
  2710.                                            NET.ACC. This file should be in
  2711.  Code                              Value   Meaning
  2712.  ────────────────────────────────────────────────────────────────────────────
  2713.                                           NET.ACC. This file should be in
  2714.                                            the ACCOUNTS subdirectory of the
  2715.                                            LANMAN directory.
  2716.  
  2717.  NERR_UserNotFound                 2221    The username was not found.
  2718.  
  2719.  NERR_ResourceNotFound             2222    The resource name was not found.
  2720.  
  2721.  
  2722.  NERR_ACFNotLoaded                 2227    The user accounts database is
  2723.                                            not active. This database must
  2724.                                            be active for the command to run.
  2725.  
  2726.  NERR_ACFNoRoom                    2228    The user accounts database is
  2727.                                            full.
  2728.  
  2729.  NERR_ACFTooManyLists              2230    Each resource can have no more
  2730.                                            than 64 access records defined.
  2731.  
  2732.  Code                              Value   Meaning
  2733.  ────────────────────────────────────────────────────────────────────────────
  2734. 
  2735.  NERR_InvalidDatabase              2247    The user accounts database file,
  2736.                                            NET.ACC, is corrupted.
  2737.  
  2738.  NERR_InvalidComputer              2351    The specified computername is
  2739.                                            invalid.
  2740.  
  2741.  NERR_CanNotGrowUASFile            2456    The user accounts database
  2742.                                            cannot be enlarged because the
  2743.                                            server's hard disk is full.
  2744.  
  2745.  ────────────────────────────────────────────────────────────────────────────
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  Remarks
  2751.  
  2752.  NetAccessSetInfo returns ERROR_NOT_SUPPORTED when executed remotely on a
  2753.  server that has share-level security.
  2754.  
  2755.  See Also
  2756.  
  2757.  For information about             See
  2758.  ────────────────────────────────────────────────────────────────────────────
  2759.  Listing permissions and           NetAccessEnum
  2760.  resources
  2761.  
  2762.  Remote calls                      Chapter 1, "Overview of the LAN Manager
  2763.                                    API"
  2764.  
  2765.  Retrieving the access             NetAccessGetInfo
  2766.  permissions for a specific
  2767.  resource
  2768.  
  2769.  SetInfo functions                 Chapter 1, "Overview of the LAN Manager
  2770.                                    API"
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  Access Permissions Category Example
  2777.  
  2778.    /*
  2779.       NETACC.C -- a sample program demonstrating NetAccess API functions.
  2780.  
  2781.       This program requires that you have admin privilege if a servername
  2782.       parameter is supplied.
  2783.  
  2784.          usage:  netacc [-s \\server] [-u username] [-r resource] [-b
  2785.    basepath]
  2786.  
  2787.          where  \\server = Name of the server. A servername must be
  2788.                            preceded by two backslashes (\\).
  2789.                 username = Name of the user.
  2790.                 resource = Name of the resource.
  2791.                 basepath = Enumerate resources with this base path.
  2792.  
  2793.       API                  Used to...
  2794.       ================     ================================================
  2795.       NetAccessEnum        Display a list of access permissions
  2796.       NetAccessCheck       Check a user's write access to the resource
  2797.       NetAccessGetInfo     Check that an ACL exists for the resource
  2798.       NetAccessAdd         Add an ACL for the resource if one does not
  2799.    exist
  2800.       NetAccessSetInfo     Give all users read/write access to the resource
  2801.       NetAccessDel         Delete the ACL for the resource
  2802.  
  2803.       This code sample is provided for demonstration purposes only.
  2804.       Microsoft makes no warranty, either express or implied,
  2805.       as to its usability in any given situation.
  2806.    */
  2807.  
  2808.    #define     INCL_BASE
  2809.    #include    <os2.h>        // MS OS/2 base header files
  2810.  
  2811.    #define     INCL_NETACCESS
  2812.    #define     INCL_NETERRORS
  2813.    #include    <lan.h>        // LAN Manager header files
  2814.  
  2815.    #include    <stdio.h>      // C run-time header files
  2816.    #include    <stdlib.h>
  2817.    #include    <string.h>
  2818.  
  2819.    #include    "samples.h"    // Internal routine header file
  2820.  
  2821.    #define DEFAULT_USER       "ADMIN"
  2822.    #define DEFAULT_RESOURCE   "\\pipe\\restrict"
  2823.    #define BIG_BUFFER         32768
  2824.  
  2825.    void Usage (char * pszProgram);
  2826.  
  2827.    void main(int argc, char *argv[])
  2828.    {
  2829.       API_RET_TYPE uReturnCode;              // API return code
  2830.       char * pszServer = NULL;               // Servername
  2831.       char * pszUserName = DEFAULT_USER;     // Username
  2832.       char * pszResource = DEFAULT_RESOURCE; // Resource to check
  2833.       char * pszBasePath = NULL;             // No default base path
  2834.       char * pbBuffer;                       // Pointer to data buffer
  2835.       struct access_info_1 *pAclBuf;         // Pointer to ACL info
  2836.       struct access_list   *pAceInfo;        // Pointer to ACE info
  2837.       int            iArgv;                  // Index for arguments
  2838.       short          iACE;                   // Index for ACEs
  2839.       unsigned short iACL;                   // Index for ACLs
  2840.       unsigned short cAclRead;               // Count of ACLs read
  2841.       unsigned short cAclTotal;              // Count of ACLs available
  2842.       unsigned short cbAvail;                // Count of bytes available
  2843.       unsigned short cbBuffer;               // Size of buffer, in bytes
  2844.       unsigned short usResult;               // Result of access check
  2845.       unsigned short fAttrib;                // Auditing attribute flag
  2846.       char cGroup;
  2847.       BOOL fResourceFound = FALSE;
  2848.  
  2849.       for (iArgv = 1; iArgv < argc; iArgv++)
  2850.       {
  2851.          if ((*argv[iArgv] == '-') || (*argv[iArgv] == '/'))
  2852.          {
  2853.             switch (tolower(*(argv[iArgv]+1)))    // Process switches
  2854.             {
  2855.                case 's':                          // -s servername
  2856.                   pszServer = argv[++iArgv];
  2857.                   break;
  2858.                case 'u':                          // -u username
  2859.                   pszUserName = argv[++iArgv];
  2860.                   break;
  2861.                case 'r':                          // -r resource
  2862.                   pszResource = argv[++iArgv];
  2863.                   break;
  2864.                case 'b':                          // -b base path
  2865.                   pszBasePath = argv[++iArgv];
  2866.                   break;
  2867.  
  2868.    case 'h':
  2869.                default:
  2870.                   Usage(argv[0]);
  2871.             }
  2872.          }
  2873.          else
  2874.             Usage(argv[0]);
  2875.       }
  2876.  
  2877.    //========================================================================
  2878.    // NetAccessEnum
  2879.    //
  2880.    // This API displays the list of resource access permissions.
  2881.    // Note: Details other than resource name are available only at info
  2882.    // level 1. If all resources are wanted, then no base pathname should
  2883.    // be supplied. Recursive searching is enabled.
  2884.    //========================================================================
  2885.  
  2886.       cbBuffer = BIG_BUFFER;                 // Can be up to 64K
  2887.  
  2888.       /*
  2889.        * You can determine the number of entries by calling NetAccessEnum
  2890.        * with pbBuffer=NULL and cbBuffer=0. The size of the buffer needed
  2891.        * to enumerate the users is, however, larger than
  2892.        * cAclTotal * sizeof(struct access_info_1) because of the
  2893.        * variable-length data (referenced by pointers in the structure).
  2894.        * It is easiest to use a big buffer.
  2895.        */
  2896.  
  2897.       pbBuffer = SafeMalloc(cbBuffer);       // Start of memory block
  2898.  
  2899.       uReturnCode = NetAccessEnum(
  2900.                         pszServer,           // Servername
  2901.                         pszBasePath,         // Base path to search from
  2902.                         1,                   // Nonzero, recursive search
  2903.                         1,                   // Information level
  2904.                         pbBuffer,            // Data returned here
  2905.                         cbBuffer,            // Size of buffer, in bytes
  2906.                         &cAclRead,           // Count of ACLs read
  2907.                         &cAclTotal);         // Count of ACLs available
  2908.  
  2909.  
  2910.       printf("NetAccessEnum returned %u\n", uReturnCode);
  2911.  
  2912.       if (uReturnCode == NERR_Success)
  2913.       {
  2914.          pAclBuf = (struct access_info_1 *) pbBuffer;
  2915.          for (iACL = 0; iACL < cAclRead; iACL++)
  2916.          {
  2917.             printf("   resource = %Fs\n", pAclBuf->acc1_resource_name);
  2918.             pAceInfo = (struct access_list *)(pAclBuf + 1);
  2919.             for (iACE = 0; iACE < pAclBuf->acc1_count; iACE++)
  2920.             {
  2921.                                              // Print a * before groupnames
  2922.                cGroup = ' ';
  2923.                if (pAceInfo->acl_access & ACCESS_GROUP)
  2924.                {                             // Strip group access bit
  2925.                   pAceInfo->acl_access &= ACCESS_ALL;
  2926.                   cGroup = '*';
  2927.                }
  2928.                printf("\t%c%s:%x \n", cGroup, pAceInfo->acl_ugname,
  2929.                            pAceInfo->acl_access);
  2930.                pAceInfo++;
  2931.             }
  2932.             pAclBuf = (struct access_info_1 *)pAceInfo;
  2933.          }
  2934.          printf("%hu out of %hu entries returned\n", cAclRead, cAclTotal);
  2935.       }
  2936.  
  2937.    //========================================================================
  2938.    // NetAccessCheck
  2939.    //
  2940.    // This API checks that a user has permission to write to a resource.
  2941.    // Unlike other Access Category API functions, NetAccessCheck input
  2942.    can
  2943.    // specify only a username; it cannot specify a groupname.
  2944.    // Note: NetAccessCheck cannot be executed remotely.
  2945.    //========================================================================
  2946.  
  2947.  
  2948.       uReturnCode = NetAccessCheck(
  2949.                         NULL,                // Reserved field
  2950.                         pszUserName,         // Check for user
  2951.                         pszResource,         // Resource to check
  2952.                         ACCESS_WRITE,        // Check for write permission
  2953.                         &usResult);
  2954.  
  2955.       /*
  2956.        * The result field is valid only if the API returns NERR_Success.
  2957.        * If there is no ACL for the resource, its parent directory, or
  2958.        * the drive label, the API sets the result field to NERR_Success
  2959.        * for an admin-class user and ERROR_ACCESS_DENIED for any other
  2960.        * type of user.
  2961.        */
  2962.  
  2963.  
  2964.       printf("\nNetAccessCheck for write permission returned %u\n",
  2965.                     uReturnCode);
  2966.       printf("   User name = %s,  Resource = %s\n",
  2967.                     pszUserName, pszResource);
  2968.  
  2969.       if (uReturnCode == NERR_Success)
  2970.       {
  2971.          printf("   Result field returned = %hu\n", usResult);
  2972.       }
  2973.  
  2974.    //========================================================================
  2975.    // NetAccessGetInfo
  2976.    //
  2977.    // Call NetAccessGetInfo at level 0 to see if the resource exists.
  2978.    //========================================================================
  2979.  
  2980.       uReturnCode = NetAccessGetInfo(
  2981.                         pszServer,           // Servername
  2982.                         pszResource,         // Pointer to resource name
  2983.                         0,                   // Only want to know if
  2984.    it exists
  2985.                         pbBuffer,            // Data returned here
  2986.                         cbBuffer,            // Size of buffer, in bytes
  2987.                         &cbAvail);           // Count of bytes available
  2988.  
  2989.       printf("\nNetAccessGetInfo of %s returned %u\n",
  2990.                      pszResource, uReturnCode);
  2991.  
  2992.       switch (uReturnCode)
  2993.       {
  2994.          case NERR_Success:
  2995.             printf("    Resource %s exists\n\n", pszResource);
  2996.             fResourceFound = TRUE;
  2997.             break;
  2998.          case NERR_ResourceNotFound:
  2999.             printf("    Resource %s does not exist\n\n", pszResource);
  3000.             break;
  3001.       }
  3002.  
  3003.    //========================================================================
  3004.    // NetAccessAdd
  3005.    //
  3006.    // This API adds an ACL for the resource (if one does not exist)
  3007.    // and sets the attribute flag so all access attempts are audited.
  3008.    //========================================================================
  3009.  
  3010.       if (!fResourceFound)
  3011.       {                                      // Set up access permission
  3012.    info
  3013.          pAclBuf = (struct access_info_1 *) pbBuffer;
  3014.  
  3015.          pAclBuf->acc1_resource_name = (char far *) pszResource;
  3016.          pAclBuf->acc1_attr = 1;             // Audit all access attempts
  3017.          pAclBuf->acc1_count = 0;            // Set no user/group info
  3018.  
  3019.          uReturnCode = NetAccessAdd(
  3020.                            pszServer,            // Servername
  3021.                            1,                    // Info level; must
  3022.    be 1
  3023.                            (char far *)pAclBuf,  // Data to be set
  3024.                            cbBuffer);            // Size of buffer, in
  3025.    bytes
  3026.  
  3027.          printf("NetAccessAdd of %s returned %u\n\n",
  3028.                         pszResource, uReturnCode);
  3029.       }
  3030.  
  3031.    //========================================================================
  3032.    // NetAccessSetInfo
  3033.    //
  3034.    // This API changes the access record for the resource so that
  3035.    // any user who has user permission has read permission only. This
  3036.  
  3037.    // can be overwritten by setting special access permissions for
  3038.    // individual usernames.
  3039.    //========================================================================
  3040.  
  3041.       /*
  3042.        * There are two ways to call NetAccessSetInfo.
  3043.        * If sParmNum == PARMNUM_ALL, you must pass it a whole structure.
  3044.        * Otherwise, you can set sParmNum to the element of the structure
  3045.  
  3046.        * you want to change. Both ways are shown here.
  3047.        */
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.                                              // Set up access permission
  3056.    info
  3057.       pAclBuf = (struct access_info_1 *) pbBuffer;
  3058.       pAclBuf->acc1_resource_name = (char far *) pszResource;
  3059.       pAclBuf->acc1_attr = 1;                // Audit all access attempts
  3060.       pAclBuf->acc1_count = 1;
  3061.                                              // Set up access_list structure
  3062.       pAceInfo = (struct access_list *)(pAclBuf+1),
  3063.       strcpy(pAceInfo->acl_ugname, "USERS");
  3064.       pAceInfo->acl_access = ACCESS_READ;
  3065.  
  3066.       uReturnCode = NetAccessSetInfo(
  3067.                         pszServer,           // Servername
  3068.                         pszResource,         // Pointer to resource name
  3069.                         1,                   // Info level; must be 1
  3070.                         (char far *)pAclBuf, // Data to be set
  3071.                         cbBuffer,            // Size of buffer, in bytes
  3072.                         PARMNUM_ALL);        // Supply full set of info
  3073.  
  3074.       printf("NetAccessSetInfo with full buffer returned %u\n", uReturnCode);
  3075.  
  3076.       /*
  3077.        * Sets sParmNum to ACCESS_ATTR_PARMNUM to change the acc1_attr
  3078.    element
  3079.        * of the access_info_1 structure. To specify no audit logging,
  3080.    set
  3081.        * acc1_attr to 0.
  3082.        */
  3083.  
  3084.       fAttrib = 0;
  3085.  
  3086.       uReturnCode = NetAccessSetInfo(
  3087.                         pszServer,             // Servername
  3088.                         pszResource,           // Pointer to resource
  3089.    name
  3090.                         1,                     // Info level
  3091.                         (char far *)&fAttrib,  // Turn off all auditing
  3092.                         sizeof(short),         // Size of buffer, in
  3093.    bytes
  3094.                         ACCESS_ATTR_PARMNUM);  // Give audit attribute
  3095.    only
  3096.  
  3097.       printf("NetAccessSetInfo with audit bit only returned %u\n\n",
  3098.                        uReturnCode);
  3099.  
  3100.    //========================================================================
  3101.    // NetAccessDel
  3102.    //
  3103.    // This API deletes the access record for the resource.
  3104.    //========================================================================
  3105.  
  3106.       uReturnCode = NetAccessDel(
  3107.                         pszServer,           // Servername
  3108.                         pszResource);        // Pointer to resource name
  3109.  
  3110.       printf("NetAccessDel of %s returned %u\n", pszResource, uReturnCode);
  3111.  
  3112.       free(pbBuffer);
  3113.       exit(0);
  3114.    }
  3115.  
  3116.    void Usage (char * pszProgram)
  3117.    {
  3118.       fprintf(stderr, "Usage: %s [-s \\\\server] [-u username]"\
  3119.                       " [-r resource] [-b basepath]\n", pszProgram);
  3120.       exit(1);
  3121.    }
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  Alert Category
  3130.  
  3131.  Alert API functions notify network service programs and applications of
  3132.  network events. They require that the Workstation service be started.
  3133.  
  3134.  The Alert category functions, datatypes, structures, and constants are
  3135.  defined in the NETCONS.H, NETERR.H, and ALERT.H header files. A source
  3136.  program can access these definitions by defining the constants
  3137.  INCL_NETERRORS and INCL_NETALERT, and including the master header file,
  3138.  LAN.H. For more information, see the "Example" section, later in this
  3139.  category.
  3140.  
  3141.  These are the Alert API functions:
  3142.  
  3143.  
  3144.    ■   NetAlertRaise
  3145.  
  3146.    ■   NetAlertStart
  3147.  
  3148.    ■   NetAlertStop
  3149.  
  3150.  
  3151.  
  3152.  Description
  3153.  
  3154.  An event is a particular instance of a process or state of hardware as
  3155.  defined by an application. The Alert API functions allow applications to
  3156.  indicate when predefined events occur.
  3157.  
  3158.  The ALERT.H header file defines the following types of events for alerts
  3159.  sent by the LAN Manager services:
  3160.  
  3161. ╓┌─────────────────────┌──────────────┌──────────────────────────────────────╖
  3162.  Code                  ASCIIZ String  Meaning
  3163.  ────────────────────────────────────────────────────────────────────────────
  3164.  ALERT_ADMIN_EVENT     ADMIN          Notify an administrator.
  3165.  
  3166.  ALERT_ERRORLOG_EVENT  ERRORLOG       An entry is added to the error log.
  3167.  
  3168.  ALERT_MESSAGE_EVENT   MESSAGE        A user or application received a
  3169.                                       message.
  3170.  
  3171.  ALERT_PRINT_EVENT     PRINTING       A print job completed or a print
  3172.                                       error occurred.
  3173.  Code                  ASCIIZ String  Meaning
  3174.  ────────────────────────────────────────────────────────────────────────────
  3175.                                      error occurred.
  3176.  
  3177.  ALERT_USER_EVENT      USER           An application or resource was used.
  3178.  
  3179.  ────────────────────────────────────────────────────────────────────────────
  3180.  
  3181.  
  3182.  
  3183.  Other types of alerts can be defined as needed by applications. For example,
  3184.  you could define the new alert type ALERT_CHANGE_EVENT as the ASCIIZ string
  3185.  CHANGE. A monitor program could check for ALERT_CHANGE_EVENT alerts by
  3186.  calling NetAlertStart with the new alert. If an application that modified a
  3187.  resource then called NetAlertRaise with the ALERT_CHANGE_EVENT alert, the
  3188.  monitor program would be notified.
  3189.  
  3190.  An application can receive alert messages through one of two delivery
  3191.  mechanisms: a mailslot (registered as \mailslot\mailslotname) or a system
  3192.  semaphore (registered as \sem\semaphorename).
  3193.  
  3194.  If an application requires detailed information about an event, it should
  3195.  use a mailslot. The mailslot can receive data; the semaphore can only
  3196.  indicate the occurrence of an event.
  3197.  
  3198.  The number of alerts a system can handle is determined by the numalerts
  3199.  entry in the [workstation] section of the LANMAN.INI file. To change this
  3200.  number, alter the numalerts entry and stop and restart the workstation.
  3201.  
  3202.  NetAlertStart indicates that an application is checking for events of a
  3203.  particular type to occur, and indicates whether the application is
  3204.  monitoring a mailslot or waiting for a semaphore to be cleared. An
  3205.  application can register to monitor several alert types by calling
  3206.  NetAlertStart multiple times.
  3207.  
  3208.  NetAlertRaise is used to indicate that an event has occurred. Any
  3209.  applications checking for the event then receive the data sent by the alert
  3210.  being raised, or they have their semaphore cleared. The LAN Manager Alerter
  3211.  service is an example of an application that has registered to receive LAN
  3212.  Manager alerts.
  3213.  
  3214.  To discontinue checking for alerts of a particular type, call NetAlertStop
  3215.  with the appropriate alert type specified.
  3216.  
  3217.  If an application calls NetAlertStart to start checking for an alert, and
  3218.  then exits without ever calling NetAlertStop, the entry remains in the table
  3219.  of alerts until the Workstation service stops; the alert table may fill up.
  3220.  To avoid this, applications should always call NetAlertStop when they are
  3221.  done checking for the alert.
  3222.  
  3223.  
  3224.  Data Structures
  3225.  
  3226.  An application registered as a mailslot client receives information about
  3227.  each type of alert for which it is registered. This information consists of
  3228.  a fixed-length header followed by variable-length information specific to
  3229.  the type of alert. The LAN Manager alert data structures are defined in the
  3230.  ALERT.H header file.
  3231.  
  3232.  
  3233.  Header Structure
  3234.  
  3235.  The fixed-length header contains the standard alert data structure. The
  3236.  std_alert data structure has the following format:
  3237.  
  3238.    struct std_alert {
  3239.        long  alrt_timestamp;
  3240.        char  alrt_eventname[EVLEN+1];
  3241.        char  alrt_pad1;
  3242.        char  alrt_servicename[SNLEN+1];
  3243.    };
  3244.  
  3245.  where
  3246.  
  3247.  alrt_timestamp
  3248.    Specifies the time and date when the alert event was raised. This value is
  3249.    stored as the number of seconds elapsed since 00:00:00, January 1, 1970.
  3250.  
  3251.  alrt_eventname
  3252.    Contains an ASCIIZ string that specifies the type of alert. The constant
  3253.    EVLEN is defined in the NETCONS.H header file.
  3254.  
  3255.  alrt_pad1
  3256.    Aligns the next data structure element on a word boundary.
  3257.  
  3258.  alrt_servicename
  3259.    Contains an ASCIIZ string that specifies which application raised the
  3260.    alert. The constant SNLEN is defined in the NETCONS.H header file.
  3261.  
  3262.  
  3263.  Alert Structures
  3264.  
  3265.  The ALERT.H header file contains data structures for predefined alert
  3266.  classes. These structures define only the fixed-length part of the
  3267.  information, not the ASCIIZ strings that follow some of the structures.
  3268.  These alert data structures are described in the following sections.
  3269.  
  3270.  ALERT_ADMIN_EVENT Alert - The admin_other_info data structure has this
  3271.  format:
  3272.  
  3273.    struct admin_other_info {
  3274.        short  alrtad_errcode;
  3275.        short  alrtad_numstrings;
  3276.    };
  3277.  
  3278.    /* Followed by consecutive ASCIIZ strings; the count
  3279.        is in the alrtad_numstrings element. */
  3280.  
  3281.    char  mergestrings[];
  3282.  
  3283.  where
  3284.  
  3285.  alrtad_errcode
  3286.    Specifies the error code for the new message in the message log.
  3287.  
  3288.  alrtad_numstrings
  3289.    Specifies the number (0-9) of consecutive ASCIIZ strings contained in
  3290.    mergestrings.
  3291.  
  3292.  mergestrings
  3293.    Contains a series of consecutive ASCIIZ strings that make up the error
  3294.    message indicated by alrtad_errcode.
  3295.  
  3296.  ALERT_ERRORLOG_EVENT Alert - The errlog_other_info data structure has this
  3297.  format:
  3298.  
  3299.    struct errlog_other_info {
  3300.        short  alrter_errcode;
  3301.        long   alrter_offset;
  3302.    };
  3303.  
  3304.  where
  3305.  
  3306.  alrter_errcode
  3307.    Specifies the error code that was written to the error log.
  3308.  
  3309.  alrter_offset
  3310.    Specifies the offset for the new entry in the error log.
  3311.  
  3312.  ALERT_MESSAGE_EVENT Alert - This alert does not define a data structure; the
  3313.  text from the received message is in this format:
  3314.  
  3315.    char msg_text[];
  3316.  
  3317.  where
  3318.  
  3319.  msg_text
  3320.    Specifies an ASCIIZ string that contains message text.
  3321.  
  3322.  ALERT_PRINT_EVENT Alert - The print_other_info data structure has this
  3323.  format:
  3324.  
  3325.    struct print_other_info {
  3326.        short  alrtpr_jobid;
  3327.        short  alrtpr_status;
  3328.        long   alrtpr_submitted;
  3329.        long   alrtpr_size;
  3330.    };
  3331.    /* Followed by consecutive ASCIIZ strings. */
  3332.  
  3333.    char  computername[];
  3334.    char  username[];
  3335.    char  queuename[];
  3336.    char  destname[];
  3337.    char  status_string[];
  3338.  
  3339.  where
  3340.  
  3341.  alrtpr_jobid
  3342.    Specifies the print job's identification number.
  3343.  
  3344.  alrtpr_status
  3345.    Specifies the status of the print job.
  3346.  
  3347.  alrtpr_submitted
  3348.    Specifies the time when the print job was submitted. This value is stored
  3349.    as the number of seconds elapsed since 00:00:00, January 1, 1970.
  3350.  
  3351.  alrtpr_size
  3352.    Specifies the size (in bytes) of the print job.
  3353.  
  3354.  computername
  3355.    Contains an ASCIIZ string that specifies which workstation or server
  3356.    submitted the print job.
  3357.  
  3358.  username
  3359.    Contains an ASCIIZ string that specifies which user requested the
  3360.    printing.
  3361.  
  3362.  queuename
  3363.    Contains an ASCIIZ string that specifies which queue handled the print
  3364.    job.
  3365.  
  3366.  destname
  3367.    Contains an ASCIIZ string that specifies which printer handled the job.
  3368.  
  3369.  status_string
  3370.    Specifies information the print processor returns. This string corresponds
  3371.    to the pszStatus component of the PRJINFO data structure for the print
  3372.    job. For more information, see the Print Job category API functions.
  3373.  
  3374.  ALERT_USER_EVENT Alert - The user_other_info data structure has this format:
  3375.  
  3376.  
  3377.    struct user_other_info {
  3378.        short  alrtus_errcode;
  3379.        short  alrtus_numstrings;
  3380.    };
  3381.    /*
  3382.     * Followed by a number of consecutive ASCIIZ strings;
  3383.     * the count is in the alrtus_numstrings element. */
  3384.     */
  3385.    char  mergestrings[];
  3386.  
  3387.    /* Further followed by two more consecutive ASCIIZ strings. */
  3388.    char  username[];
  3389.    char  computername[];
  3390.  
  3391.  where
  3392.  
  3393.  alrtus_errcode
  3394.    Specifies the error code for the new message in the message log.
  3395.  
  3396.  alrtus_numstrings
  3397.    Specifies the number (0-9) of consecutive ASCIIZ strings contained in
  3398.    mergestrings.
  3399.  
  3400.  mergestrings
  3401.    Specifies a series of consecutive ASCIIZ strings that make up the error
  3402.    message specified by alrtus_errcode.
  3403.  
  3404.  username
  3405.    Specifies the name of the user or application affected by the alert.
  3406.  
  3407.  computername
  3408.    Specifies the name of the computer that the user or application is
  3409.    accessing.
  3410.  
  3411.  
  3412.  ALERT.H Header File Macros
  3413.  
  3414.  The ALERT.H header file contains the following macros that simplify access
  3415.  to the variable-length elements in the alert data structure:
  3416.  
  3417.  Macro                            Description
  3418.  ────────────────────────────────────────────────────────────────────────────
  3419.  ALERT_OTHER_INFO(ptr)            Given a pointer to the start of the
  3420.  ALERT_OTHER_INFO_F(ptr)          std_alert
  3421.                                   data structure (designated by ptr), the
  3422.                                   ALERT_OTHER_INFO macro returns a pointer
  3423.                                   to the variable-length part of the alert
  3424.                                   message
  3425.                                   (the information specific to the alert
  3426.                                   class).
  3427.                                   Use ALERT_OTHER_INFO_F when a far pointer
  3428.  
  3429.                                   is required.
  3430.  
  3431.  ALERT_VAR_DATA(ptr)              Given a pointer to the address of the
  3432.  ALERT_VAR_DATA_F(ptr)            alert
  3433.                                   data structure (for example, a pointer to
  3434.                                   an admin_other_info data structure,
  3435.                                   designated
  3436.                                   by ptr), ALERT_VAR_DATA returns a pointer
  3437.  
  3438.                                   to the first variable-length ASCIIZ
  3439.                                   string.
  3440.                                   Use ALERT_VAR_DATA_F when a far pointer
  3441.                                   is required.
  3442.  
  3443.  ────────────────────────────────────────────────────────────────────────────
  3444.  
  3445.  
  3446.  See Also
  3447.  
  3448.  For information about             See
  3449.  ────────────────────────────────────────────────────────────────────────────
  3450.  Creating mailslots                Mailslot Category
  3451.  
  3452.  Error log                         Error Logging Category
  3453.  
  3454.  Message API functions             Message Category
  3455.  
  3456.  Printer API functions             Print Destination Category, Print Job
  3457.                                    Category, and Printer Queue Category
  3458.  
  3459.  
  3460.  NetAlertRaise
  3461.  ────────────────────────────────────────────────────────────────────────────
  3462.  
  3463.  NetAlertRaise notifies all registered clients that a particular event
  3464.  occurred.
  3465.  
  3466.  
  3467.  Operating Systems Supported
  3468.  
  3469.  
  3470.    ■   MS OS/2 version 1.2, local only
  3471.  
  3472.    ■   MS OS/2 version 1.1, local only
  3473.  
  3474.    ■   MS-DOS not supported
  3475.  
  3476.  
  3477.  
  3478.  Privilege Level
  3479.  
  3480.  No special privilege level is required to successfully execute
  3481.  NetAlertRaise.
  3482.  
  3483.  
  3484.  Syntax
  3485.  
  3486.    #define INCL_NETALERT
  3487.    #define INCL_NETERRORS
  3488.    #include <lan.h>
  3489.  
  3490.    API_FUNCTION
  3491.    NetAlertRaise (const char far *  pszEvent,
  3492.                   const char far *  pbBuffer,
  3493.                   unsigned short    cbBuffer,
  3494.                   unsigned long     ulTimeout
  3495.                  );
  3496.  
  3497.  where
  3498.  
  3499.  pszEvent
  3500.    Points to an ASCIIZ string that specifies which type of alert to raise.
  3501.  
  3502.  pbBuffer
  3503.    Points to the data to be sent to the clients listening for this alert. The
  3504.    data should consist of the std_alert data structure followed by any
  3505.    additional alert data.
  3506.  
  3507.  cbBuffer
  3508.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  3509.  
  3510.  ulTimeout
  3511.    Specifies how many milliseconds to wait for alert information to be
  3512.    written to the mailslot. The ALERT.H header file defines these three time
  3513.    intervals:
  3514.  
  3515.  Code              Value   Time Interval
  3516.  ────────────────────────────────────────────────────────────────────────────
  3517.  ALERT_SHORT_WAIT  100L    0.1 second
  3518.  ALERT_MED_WAIT    1000L   1 second
  3519.  ALERT_LONG_WAIT   10000L  10 seconds
  3520.  ────────────────────────────────────────────────────────────────────────────
  3521.  
  3522.  Return Codes
  3523.  
  3524. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  3525.  Code                              Value   Meaning
  3526.  ────────────────────────────────────────────────────────────────────────────
  3527.  NERR_Success                      0       The function encountered no
  3528.                                            errors.
  3529.  
  3530.  Code                              Value   Meaning
  3531.  ────────────────────────────────────────────────────────────────────────────
  3532. 
  3533.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  3534.                                            invalid.
  3535.  
  3536.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  3537.                                            is not installed.
  3538.  
  3539.  NERR_WkstaNotStarted              2138    The Workstation service is not
  3540.                                            started.
  3541.  
  3542.  NERR_NoSuchAlert                  2432    An invalid or nonexistent
  3543.                                            alertname was raised.
  3544.  
  3545.  ────────────────────────────────────────────────────────────────────────────
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  Remarks
  3551.  
  3552.  NetAlertRaise clears the client's semaphore or sends messages to mailslots.
  3553.  
  3554.  
  3555.  For mailslot clients, NetAlertRaise writes information from pbBuffer to the
  3556.  client's mailslot. For semaphore clients, NetAlertRaise clears and
  3557.  automatically resets the semaphore.
  3558.  
  3559.  The alert types defined in ALERT.H are raised by LAN Manager services.
  3560.  Applications using the Alert category functions should define their own
  3561.  alert types and associated data structures. One exception is the use of the
  3562.  ALERT_ADMIN_EVENT code to generate messages.
  3563.  
  3564.  An application can use the ALERT_ADMIN_EVENT alert type together with the
  3565.  Alerter service to generate messages. If the alert is raised with the
  3566.  alrtad_errcode element of the admin_other_info data structure set to -1, the
  3567.  alert is received by the Alerter service. The message text in mergestrings
  3568.  is then sent as a message to all names listed in the alertnames entry of the
  3569.  local LANMAN.INI file. For a demonstration of this, see the "Example"
  3570.  section at the end of this category.
  3571.  
  3572.  See Also
  3573.  
  3574.  For information about             See
  3575.  ────────────────────────────────────────────────────────────────────────────
  3576.  Mailslots                         DosMakeMailslot and DosReadMailslot in
  3577.                                    MSOS/2 programming manual(s)
  3578.  
  3579.  Registering a client for an       NetAlertStart
  3580.  alert
  3581.  
  3582.  Semaphores                        DosCreateSem, DosMuxSemWait, and
  3583.                                    DosSemSet in MSOS/2 programming manual(s)
  3584.  
  3585.  Terminating alert monitoring      NetAlertStop
  3586.  
  3587.  
  3588.  NetAlertStart
  3589.  ────────────────────────────────────────────────────────────────────────────
  3590.  
  3591.  NetAlertStart registers a client so that it will be notified of a particular
  3592.  type of alert.
  3593.  
  3594.  
  3595.  Operating Systems Supported
  3596.  
  3597.  
  3598.    ■   MS OS/2 version 1.2, local only
  3599.  
  3600.    ■   MS OS/2 version 1.1, local only
  3601.  
  3602.    ■   MS-DOS not supported
  3603.  
  3604.  
  3605.  
  3606.  Privilege Level
  3607.  
  3608.  No special privilege level is required to successfully execute
  3609.  NetAlertStart.
  3610.  
  3611.  
  3612.  Syntax
  3613.  
  3614.    #define INCL_NETALERT
  3615.    #define INCL_NETERRORS
  3616.    #include <lan.h>
  3617.  
  3618.    API_FUNCTION
  3619.    NetAlertStart (const char far *  pszEvent,
  3620.                   const char far *  pszRecipient,
  3621.                   unsigned short    cbMaxData
  3622.                  );
  3623.  
  3624.  where
  3625.  
  3626.  pszEvent
  3627.    Points to an ASCIIZ string that specifies the alert type for which the
  3628.    client will be notified.
  3629.  
  3630.  pszRecipient
  3631.    Points to an ASCIIZ string that specifies the mailslot or semaphore client
  3632.    to receive the alerts. This must be a local mailslot or system semaphore.
  3633.  
  3634.  cbMaxData
  3635.    Specifies the maximum number of bytes of information the mailslot client
  3636.    can receive for alerts of this type.
  3637.  
  3638.  Return Codes
  3639.  
  3640. ╓┌─────────────────────┌───────┌─────────────────────────────────────────────╖
  3641.  Code                  Value   Meaning
  3642.  ────────────────────────────────────────────────────────────────────────────
  3643.  NERR_Success          0       The function encountered no errors.
  3644.  
  3645.  NERR_NetNotStarted    2102    The LAN Manager NETWKSTA driver is not
  3646.                                installed.
  3647.  
  3648.  NERR_WkstaNotStarted  2138    The Workstation service is not started.
  3649.  
  3650.  NERR_BadEventName     2143    The event name is invalid.
  3651.  
  3652.  NERR_AlertExists      2430    A program requested to be notified by the
  3653.                                alerter of an event for which it is already
  3654.                                receiving notifications.
  3655.  
  3656.  Code                  Value   Meaning
  3657.  ────────────────────────────────────────────────────────────────────────────
  3658. 
  3659.  NERR_TooManyAlerts    2431    The number of alert notifications requested
  3660.                                exceeded the number specified by the
  3661.                                numalerts entry in the LANMAN.INI file.
  3662.  
  3663.  NERR_BadRecipient     2433    The alert recipient is invalid.
  3664.  
  3665.  ────────────────────────────────────────────────────────────────────────────
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  Remarks
  3671.  
  3672.  Applications can define their own alerts, specifying the alert name when
  3673.  they call NetAlertStart and NetAlertRaise. Be sure to choose a name that
  3674.  does not duplicate an alert name already used by another application.
  3675.  
  3676.  If pszRecipient is a mailslot, a NetAlertRaise call for the specified alert
  3677.  sends data to the mailslot. The process monitoring the alert must call the
  3678.  DosMakeMailslot function to create the mailslot, then call NetAlertStart to
  3679.  register to receive the alert, and then call DosReadMailslot to read the
  3680.  data raised by the alert.
  3681.  
  3682.  If pszRecipient is a semaphore, a NetAlertRaise call for the specified alert
  3683.  clears the system semaphore. The process monitoring the alert must first
  3684.  create the semaphore by calling DosCreateSem with the fNoExclusive flag set
  3685.  to CSEM_PUBLIC, then call DosSemSet to set the semaphore, then call
  3686.  NetAlertStart to register to receive the alert, and then call DosMuxSemWait
  3687.  to wait for the semaphore to be cleared. NetAlertRaise clears and
  3688.  automatically resets the semaphore.
  3689.  
  3690.  The pszRecipient parameter must be a local mailslot or system semaphore. Any
  3691.  other name results in NERR_BadRecipient.
  3692.  
  3693.  See Also
  3694.  
  3695.  For information about             See
  3696.  ────────────────────────────────────────────────────────────────────────────
  3697.  Discontinuing receiving alerts    NetAlertStop
  3698.  of a particular type
  3699.  
  3700.  Mailslots                         DosMakeMailslot and DosReadMailslot in
  3701.                                    MSOS/2 programming manual(s)
  3702.  
  3703.  Raising an alert                  NetAlertRaise
  3704.  
  3705.  Semaphores                        DosCreateSem, DosMuxSemWait, and
  3706.                                    DosSemSet in MSOS/2 programming manual(s)
  3707.  
  3708.  
  3709.  NetAlertStop
  3710.  ────────────────────────────────────────────────────────────────────────────
  3711.  
  3712.  NetAlertStop stops a client from receiving the specified type of alert.
  3713.  
  3714.  
  3715.  Operating Systems Supported
  3716.  
  3717.  
  3718.    ■   MS OS/2 version 1.2, local only
  3719.  
  3720.    ■   MS OS/2 version 1.1, local only
  3721.  
  3722.    ■   MS-DOS not supported
  3723.  
  3724.  
  3725.  
  3726.  Privilege Level
  3727.  
  3728.  No special privilege level is required to successfully execute NetAlertStop.
  3729.  
  3730.  
  3731.  
  3732.  Syntax
  3733.  
  3734.    #define INCL_NETALERT
  3735.    #define INCL_NETERRORS
  3736.    #include <lan.h>
  3737.  
  3738.    API_FUNCTION
  3739.    NetAlertStop (const char far *  pszEvent,
  3740.                  const char far *  pszRecipient
  3741.                 );
  3742.  
  3743.  where
  3744.  
  3745.  pszEvent
  3746.    Points to an ASCIIZ string that specifies the type of alert from which to
  3747.    exclude the registered client.
  3748.  
  3749.  pszRecipient
  3750.    Points to an ASCIIZ string that specifies the mailslot or semaphore where
  3751.    the alert was received.
  3752.  
  3753.  Return Codes
  3754.  
  3755.  Code                  Value   Meaning
  3756.  ────────────────────────────────────────────────────────────────────────────
  3757.  NERR_Success          0       The function encountered no errors.
  3758.  
  3759.  NERR_NetNotStarted    2102    The LAN Manager NETWKSTA driver is not
  3760.                                installed.
  3761.  
  3762.  NERR_WkstaNotStarted  2138    The Workstation service is not started.
  3763.  
  3764.  NERR_NoSuchAlert      2432    An invalid or nonexistent alertname was
  3765.                                raised.
  3766.  
  3767.  ────────────────────────────────────────────────────────────────────────────
  3768.  
  3769.  
  3770.  
  3771.  Remarks
  3772.  
  3773.  If either pszEvent or pszRecipient does not exist, NetAlertStop returns
  3774.  NERR_NoSuchAlert.
  3775.  
  3776.  
  3777.  
  3778.  
  3779.  
  3780.  Alert Category Example
  3781.  
  3782.    /*
  3783.       NETALRT.C -- a sample program demonstrating the interaction between
  3784.                     the Alerter service and NetAlertRaise.
  3785.  
  3786.       This program requires that the Alerter service be started.
  3787.       It relies on that service to monitor the admin alert events.
  3788.       To receive the alert and display it in a popup, the Messenger
  3789.       and Netpopup services must be running and one of the current
  3790.       message alias names must be listed in the alertnames entry of
  3791.       the LANMAN.INI file on the computer that raises the alert.
  3792.  
  3793.          usage:  netalrt [-m message1 [message2 [message3...]]]
  3794.  
  3795.          where  message1 = First message to appear in the popup
  3796.                 message2 = Second message to appear in the popup
  3797.                 message3 = Third message to appear in the popup
  3798.                 etc.
  3799.  
  3800.       API               Used to...
  3801.       =============     =================================================
  3802.       NetAlertRaise     Raise an admin-class alert that will appear as
  3803.    a
  3804.                         popup on machines with the Messenger and Netpopup
  3805.                         services running.
  3806.  
  3807.       This code sample is provided for demonstration purposes only.
  3808.       Microsoft makes no warranty, either express or implied,
  3809.       as to its usability in any given situation.
  3810.    */
  3811.  
  3812.    #define     INCL_NETALERT
  3813.    #define     INCL_NETERRORS
  3814.    #include    <lan.h>        // LAN Manager header files
  3815.  
  3816.    #include    <stdio.h>      // C run-time header files
  3817.    #include    <stdlib.h>
  3818.    #include    <string.h>
  3819.    #include    <time.h>
  3820.  
  3821.    #include    "samples.h"    // Internal routine header file
  3822.  
  3823.    #define DEFAULT_MESSAGE    "Hi there!"
  3824.    #define ALERT_BUFFER       512
  3825.    #define PROGRAM_NAME       "NETALRT"
  3826.  
  3827.  
  3828.    void Usage (char * pszProgram);
  3829.  
  3830.    void main(int argc, char *argv[])
  3831.    {
  3832.       API_RET_TYPE uReturnCode;               // API return code
  3833.       char * pbBuffer;                        // Pointer to data buffer
  3834.       char * psMergeString;                   // Pointer to alert strings
  3835.       int    iCount;                          // Index counter
  3836.       unsigned short cbBuffer = ALERT_BUFFER; // Buffer size
  3837.                                               // Alert data header info
  3838.       struct std_alert *pAlertInfo = (struct std_alert *) pbBuffer;
  3839.       struct admin_other_info * pAdminInfo;   // Admin alert data
  3840.  
  3841.       // Allocate a data buffer large enough to store the messages.
  3842.       pbBuffer = SafeMalloc(cbBuffer);
  3843.  
  3844.       // Set up the alert data structure.
  3845.       pAlertInfo = (struct std_alert *) pbBuffer;
  3846.       strcpy(pAlertInfo->alrt_eventname, ALERT_ADMIN_EVENT);
  3847.       strcpy(pAlertInfo->alrt_servicename, PROGRAM_NAME);
  3848.  
  3849.       pAdminInfo = (struct admin_other_info *)ALERT_OTHER_INFO(pAlertInfo);
  3850.       pAdminInfo->alrtad_errcode = -1;
  3851.       pAdminInfo->alrtad_numstrings = 0;
  3852.       psMergeString = ALERT_VAR_DATA(pAdminInfo);
  3853.  
  3854.       for (iCount = 1; iCount < argc; iCount++)
  3855.       {
  3856.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  3857.          {
  3858.             switch (tolower(*(argv[iCount]+1))) // Process switches
  3859.             {
  3860.                case 'm':                        // -m Message
  3861.                   for ( ; iCount < argc-1; )    // Merge all message
  3862.    strings
  3863.                   {
  3864.                      iCount++;
  3865.                      strcpy(psMergeString, argv[iCount]);
  3866.                      psMergeString = psMergeString+1+strlen(argv[iCount]);
  3867.                      pAdminInfo->alrtad_numstrings++;
  3868.                   }
  3869.                   break;
  3870.                case 'h':
  3871.                default:
  3872.                   Usage(argv[0]);
  3873.             }
  3874.          }
  3875.  
  3876.  
  3877.          else
  3878.             Usage(argv[0]);
  3879.       }
  3880.       // Display at least one string.
  3881.       if (pAdminInfo->alrtad_numstrings == 0)
  3882.       {
  3883.          strcpy(psMergeString, DEFAULT_MESSAGE);
  3884.          (pAdminInfo->alrtad_numstrings)++;
  3885.       }
  3886.  
  3887.    //========================================================================
  3888.    //  NetAlertRaise
  3889.    //
  3890.    //  This API sends an admin alert. If alrtad_errcode is -1, the Alerter
  3891.    //  service receives the alert and sends the alert message to all
  3892.    //  message aliases listed in the alertnames entry of the LANMAN.INI
  3893.    //  file. These messages are then displayed in a popup if the receiving
  3894.  
  3895.    //  computer is running the Messenger and Netpopup services.
  3896.    //========================================================================
  3897.  
  3898.       time(&(pAlertInfo->alrt_timestamp));
  3899.  
  3900.       uReturnCode = NetAlertRaise(ALERT_ADMIN_EVENT,  // Admin alert
  3901.                           (char far *)pbBuffer,       // Alert information
  3902.                           cbBuffer,                   // Buffer size
  3903.                           ALERT_MED_WAIT);            // Time-out value
  3904.  
  3905.       printf("NetAlertRaise returned %u\n", uReturnCode);
  3906.       free (pbBuffer);
  3907.    }
  3908.  
  3909.    void Usage (char * pszProgram)
  3910.    {
  3911.       fprintf(stderr, "Usage: %s [-m message1 [message2 [message3...]]]\n",
  3912.                  pszProgram);
  3913.       exit(1);
  3914.    }
  3915.  
  3916.  
  3917.  
  3918.  
  3919.  
  3920.  Auditing Category
  3921.  
  3922.  Auditing API functions control the audit log. All Audit API functions
  3923.  require that the NETWKSTA device driver be installed. NetAuditRead requires
  3924.  that the Workstation service be started. NetAuditWrite requires that the
  3925.  Server service be started.
  3926.  
  3927.  The Audit category functions, datatypes, structures, and constants are
  3928.  defined in the NETCONS.H, NETERR.H, ACCESS.H, and AUDIT.H header files. A
  3929.  source  program can access these definitions by defining the constants
  3930.  INCL_NETERRORS and INCL_NETAUDIT, and including the master header file,
  3931.  LAN.H. For more information about these definitions, see the "Example"
  3932.  section, later in this category.
  3933.  
  3934.  These are the Auditing API functions:
  3935.  
  3936.  
  3937.    ■   NetAuditClear
  3938.  
  3939.    ■   NetAuditRead
  3940.  
  3941.    ■   NetAuditWrite
  3942.  
  3943.  
  3944.  
  3945.  Description
  3946.  
  3947.  Auditing API functions monitor operations on the specified server. If
  3948.  auditing is enabled, each monitored operation generates an audit entry. For
  3949.  example, when a user establishes a connection to the server, a single audit
  3950.  entry is generated.
  3951.  
  3952.  Audit entries are stored in a binary file called an audit trail or audit
  3953.  log. The default audit trail file is NET.AUD in the LAN Manager LOGS
  3954.  directory. All Auditing API functions perform their operations on this file.
  3955.  
  3956.  
  3957.  LAN Manager defines many types of audit entries. You can find these audit
  3958.  entries listed in the table in the "Fixed-Length Header" section, later in
  3959.  this category.
  3960.  
  3961.  NetAuditRead reads the audit log. NetAuditClear clears the audit log.
  3962.  NetAuditWrite creates additional audit entries and writes them to the audit
  3963.  log.
  3964.  
  3965.  To set a maximum size for the audit log, you can use one of these methods:
  3966.  
  3967.  
  3968.    ■   Use the net config command with the /maxauditlog option. For more
  3969.        information, see  your LAN Manager administrator's manual(s).
  3970.  
  3971.    ■   Set the maxauditlog entry in the [server] section of the LANMAN.INI
  3972.        file. For more information, see your LAN Manager administrator's
  3973.        manual(s).
  3974.  
  3975.    ■   Call NetServerSetInfo with sParmNum set to SV_MAXAUDITSZ_PARMNUM.
  3976.  
  3977.  
  3978.  
  3979.  Data Structures
  3980.  
  3981.  All audit entries include a fixed-length header used in conjunction with
  3982.  variable-length data specific to the entry type. Because of the variable
  3983.  lengths and structures of the ae_data element of the audit entry (it is
  3984.  possible for ae_data to be zero bytes), only the fixed header is defined in
  3985.  the audit_entry data structure.
  3986.  
  3987.  The variable-length portion of the audit entry can contain an offset to a
  3988.  variable-length ASCIIZ string. The offset values are unsigned short
  3989.  integers. To determine the value of the pointer to this string, add the
  3990.  offset value to the address of the ae_data data structure.
  3991.  
  3992.  The following example illustrates this procedure. Assume that pAE points to
  3993.  a buffer that contains a complete audit entry and that the ae_type element
  3994.  of the audit_entry data structure contains the value AE_CONNSTOP, which
  3995.  specifies the predefined ae_connstop data structure. To point the variable
  3996.  pszComputerName to the ASCIIZ string that contains the name of the client
  3997.  whose connection was stopped, an application would perform the following
  3998.  algorithm:
  3999.  
  4000.    struct audit_entry * pAE;      /* Fixed part of audit entry
  4001.    */
  4002.    struct ae_connstop * pAEvar;   /* Variable-length structure */
  4003.    char * pszComputerName;        /* Pointer to variable-length string
  4004.    */
  4005.  
  4006.    /* Calculate the offset to the variable-length structure. */
  4007.    pAEvar = (struct ae_connstop *) ((char *) pAE + pAE->ae_data_offset);
  4008.  
  4009.    /* Calculate the offset to the computername. */
  4010.    pszComputerName = (char *) pAEvar + pAEvar->ae_cp_compname;
  4011.  
  4012.  
  4013.  Fixed-Length Header
  4014.  
  4015.  The audit_entry data structure has this format:
  4016.  
  4017.    struct  audit_entry {
  4018.        unsigned short  ae_len;
  4019.        unsigned short  ae_reserved;
  4020.        unsigned long   ae_time;
  4021.        unsigned short  ae_type;
  4022.        unsigned short  ae_data_offset;  /* Offset from beginning
  4023.                                            address of audit_entry */
  4024.    };
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.  
  4031.  
  4032.    /* Variable-length data specific to type of audit entry */
  4033.  
  4034.    char            ae_data[];
  4035.  
  4036.    /* Terminating length indicator */
  4037.  
  4038.    unsigned short  ae_len2;
  4039.  
  4040.  where
  4041.  
  4042.  ae_len and ae_len2
  4043.    Specify the length of the audit entry. Both have the same value. The
  4044.    ae_len element is included at the beginning and at the end of the audit
  4045.    entry to enable both backward and forward scanning of the log. To
  4046.    calculate the entry size, add the size of the audit_entry data structure
  4047.    to the size of the variable-length data, ae_data, and the size of an
  4048.    unsigned short integer, as follows:
  4049.  
  4050.    totalsize = sizeof (struct audit_entry) +     sizeof (ae_data) + sizeof
  4051.    (unsigned short);
  4052.  
  4053.  ae_reserved
  4054.    Reserved; must be 0.
  4055.  
  4056.  ae_time
  4057.    Specifies when the audit entry was generated. The value is stored as the
  4058.    number of seconds elapsed since 00:00:00, January 1, 1970.
  4059.  
  4060.  ae_type
  4061.    Specifies the type of audit entry. Type values from 0x0000 through 0x07FF
  4062.    are reserved. OEMs and other applications programmers can reserve values
  4063.    from 0x0800 through 0xFFFF. The AUDIT.H header file defines the following
  4064.    types of audit entries:
  4065.  
  4066. ╓┌────────────────┌──────┌───────────────────────────────────────────────────╖
  4067.  Code             Value  Meaning
  4068.  ────────────────────────────────────────────────────────────────────────────
  4069.  AE_SRVSTATUS     0      Status of server changed.
  4070.  
  4071.  AE_SESSLOGON     1      Session was logged on.
  4072.  
  4073.  AE_SESSLOGOFF    2      Session was logged off.
  4074.  
  4075.  AE_SESSPWERR     3      Password error occurred.
  4076.  Code             Value  Meaning
  4077.  ────────────────────────────────────────────────────────────────────────────
  4078. AE_SESSPWERR     3      Password error occurred.
  4079.  
  4080.  AE_CONNSTART     4      Connection was started.
  4081.  
  4082.  AE_CONNSTOP      5      Connection was stopped.
  4083.  
  4084.  AE_CONNREJ       6      Connection was rejected.
  4085.  
  4086.  AE_RESACCESS     7      Access was granted.
  4087.  
  4088.  AE_RESACCESSREJ  8      Access was rejected.
  4089.  
  4090.  AE_CLOSEFILE     9      File, device, or pipe was closed.
  4091.  
  4092.  ─                10     Undefined.
  4093.  
  4094.  AE_SERVICESTAT   11     Service status code or text changed.
  4095.  
  4096.  AE_ACLMOD        12     Access control list (ACL) was modified.
  4097.  Code             Value  Meaning
  4098.  ────────────────────────────────────────────────────────────────────────────
  4099. AE_ACLMOD        12     Access control list (ACL) was modified.
  4100.  
  4101.  AE_UASMOD        13     User accounts subsystem (UAS) database was
  4102.                          modified.
  4103.  
  4104.  AE_NETLOGON      14     User logged on to network.
  4105.  
  4106.  AE_NETLOGOFF     15     User logged off from network.
  4107.  
  4108.  AE_NETLOGDENIED  16     Not supported in LAN Manager 2.0.
  4109.  
  4110.  AE_ACCLIMITEXCD  17     Account limit was exceeded.
  4111.  
  4112.  AE_RESACCESS2    18     Access was granted.
  4113.  
  4114.  AE_ACLMODFAIL    19     ACL modification failed.
  4115.  
  4116.  ────────────────────────────────────────────────────────────────────────────
  4117.  
  4118.  Code             Value  Meaning
  4119.  ────────────────────────────────────────────────────────────────────────────
  4120. 
  4121.  
  4122.  
  4123.  ae_data_offset
  4124.    Specifies the byte offset from the beginning of the audit entry to the
  4125.    beginning of the variable-length portion (ae_data) of the audit entry. To
  4126.    calculate the beginning of ae_data, add the value of ae_data_offset to the
  4127.    starting address of the fixed-length portion of the entry.
  4128.  
  4129.  ae_data
  4130.    Specifies the variable-length portion of the audit entry; it differs
  4131.    depending on the type of entry specified by ae_type. The information
  4132.    begins at ae_data_offset bytes from the top of the audit entry. For
  4133.    information about the structure of each entry type defined by LAN Manager,
  4134.    see the following section.
  4135.  
  4136.  
  4137.  Variable-Length Data
  4138.  
  4139.  The following data structures, specific to the audit entry type, are defined
  4140.  in the AUDIT.H header file. The structures follow the audit_entry header,
  4141.  but they are not necessarily contiguous.
  4142.  
  4143.  Server Status Changed  - The ae_srvstatus data structure is associated with
  4144.  an audit entry of type AE_SRVSTATUS. The ae_srvstatus data structure has
  4145.  this format:
  4146.  
  4147.    struct ae_srvstatus {
  4148.        unsigned short  ae_ss_status;
  4149.    };
  4150.  
  4151.  where
  4152.  
  4153.  ae_ss_status
  4154.    Specifies a server's status. The AUDIT.H header file defines these
  4155.    possible values:
  4156.  
  4157.  Code          Value  Meaning
  4158.  ────────────────────────────────────────────────────────────────────────────
  4159.  AE_SRVSTART   0      Server software started.
  4160.  AE_SRVPAUSED  1      Server software paused.
  4161.  AE_SRVCONT    2      Server software restarted.
  4162.  AE_SRVSTOP    3      Server software stopped.
  4163.  ────────────────────────────────────────────────────────────────────────────
  4164.  
  4165.  Session Begun - The ae_sesslogon data structure is associated with an audit
  4166.  entry of type AE_SESSLOGON. The ae_sesslogon data structure has this format:
  4167.  
  4168.  
  4169.    struct ae_sesslogon {
  4170.        unsigned short  ae_so_compname;
  4171.        unsigned short  ae_so_username;
  4172.        unsigned short  ae_so_privilege;
  4173.    };
  4174.  
  4175.  where
  4176.  
  4177.  ae_so_compname
  4178.    Specifies the offset (from the beginning of the ae_sesslogon data
  4179.    structure) to an ASCIIZ string that specifies the name of the workstation
  4180.    that established the session.
  4181.  
  4182.  ae_so_username
  4183.    Specifies the offset (from the beginning of the ae_sesslogon data
  4184.    structure) to an ASCIIZ string that specifies the name of the user who
  4185.    initiated the session. If ae_so_username is 0, the username and
  4186.    workstation name are assumed to be the same.
  4187.  
  4188.  ae_so_privilege
  4189.    Specifies the privilege level assigned to ae_so_username. The AUDIT.H
  4190.    header file defines these possible values:
  4191.  
  4192.  Code      Value  Meaning
  4193.  ────────────────────────────────────────────────────────────────────────────
  4194.  AE_GUEST  0      Guest privilege.
  4195.  AE_USER   1      User privilege.
  4196.  AE_ADMIN  2      Admin privilege.
  4197.  ────────────────────────────────────────────────────────────────────────────
  4198.  
  4199.  Session Ended - The ae_sesslogoff data structure is associated with an audit
  4200.  entry of type AE_SESSLOGOFF. The ae_sesslogoff data structure has this
  4201.  format:
  4202.  
  4203.    struct ae_sesslogoff {
  4204.        unsigned short  ae_sf_compname;
  4205.        unsigned short  ae_sf_username;
  4206.        unsigned short  ae_sf_reason;
  4207.    };
  4208.  
  4209.  where
  4210.  
  4211.  ae_sf_compname
  4212.    Specifies the offset (from the beginning of the ae_sesslogoff data
  4213.    structure) to an ASCIIZ string that specifies the name of the workstation
  4214.    that established the session.
  4215.  
  4216.  ae_sf_username
  4217.    Specifies the offset (from the beginning of the ae_sesslogoff data
  4218.    structure) to an ASCIIZ string that specifies the name of the user who
  4219.    initiated the session. If ae_sf_username is 0, the username and
  4220.    workstation name are assumed to be the same.
  4221.  
  4222.  ae_sf_reason
  4223.    Specifies the reason the session was disconnected. The AUDIT.H header file
  4224.    defines these possible values:
  4225.  
  4226. ╓┌───────────────┌──────┌────────────────────────────────────────────────────╖
  4227.  Code            Value  Meaning
  4228.  ────────────────────────────────────────────────────────────────────────────
  4229.  AE_NORMAL       0      Normal disconnection or username limit.
  4230.  
  4231.  AE_ERROR        1      Error, session disconnect, or bad password.
  4232.  
  4233.  AE_AUTODIS      2      Autodisconnect (time-out), sharename removed, or
  4234.                         administrative permissions required.
  4235.  
  4236.  AE_ADMINDIS     3      Administrative disconnection (forced).
  4237.  
  4238.  AE_ACCRESTRICT  4      Forced off by account system due to account
  4239.                         restriction such as logon hours.
  4240.  
  4241.  ────────────────────────────────────────────────────────────────────────────
  4242.  
  4243.  
  4244.  
  4245.  Password Error - The ae_sesspwerr data structure is associated with an audit
  4246.  entry of type AE_SESSPWERR. The ae_sesspwerr data structure has this format:
  4247.  
  4248.  
  4249.    struct ae_sesspwerr {
  4250.        unsigned short  ae_sp_compname;
  4251.        unsigned short  ae_sp_username;
  4252.    };
  4253.  
  4254.  where
  4255.  
  4256.  ae_sp_compname
  4257.    Specifies the offset (from the beginning of the ae_sesspwerr data
  4258.    structure) to an ASCIIZ string that specifies the name of the workstation
  4259.    that established the session.
  4260.  
  4261.  ae_sp_username
  4262.    Specifies the offset (from the beginning of the ae_sesspwerr data
  4263.    structure) to an ASCIIZ string that specifies the name of the user who
  4264.    initiated the session. If ae_sp_username is 0, the username and
  4265.    workstation name are assumed to be the same.
  4266.  
  4267.  Connection Started - The ae_connstart data structure is associated with an
  4268.  audit entry of type AE_CONNSTART. The ae_connstart data structure has this
  4269.  format:
  4270.  
  4271.    struct ae_connstart {
  4272.        unsigned short  ae_ct_compname;
  4273.        unsigned short  ae_ct_username;
  4274.        unsigned short  ae_ct_netname;
  4275.        unsigned short  ae_ct_connid;
  4276.    };
  4277.  
  4278.  where
  4279.  
  4280.  ae_ct_compname
  4281.    Specifies the offset (from the beginning of the ae_connstart data
  4282.    structure) to an ASCIIZ string that specifies the name of the workstation
  4283.    that established the session.
  4284.  
  4285.  ae_ct_username
  4286.    Specifies the offset (from the beginning of the ae_connstart data
  4287.    structure) to an ASCIIZ string that specifies the name of the user who
  4288.    initiated the session. If ae_ct_username is 0, the username and
  4289.    workstation name are assumed to be the same.
  4290.  
  4291.  ae_ct_netname
  4292.    Specifies the offset (from the beginning of the ae_connstart data
  4293.    structure) to an ASCIIZ string that specifies the sharename of the
  4294.    connected resource.
  4295.  
  4296.  ae_ct_connid
  4297.    Specifies the connection identification number.
  4298.  
  4299.  Connection Stopped - The ae_connstop data structure is associated with an
  4300.  audit entry of type AE_CONNSTOP. The ae_connstop data structure has this
  4301.  format:
  4302.  
  4303.    struct ae_connstop {
  4304.        unsigned short  ae_cp_compname;
  4305.        unsigned short  ae_cp_username;
  4306.        unsigned short  ae_cp_netname;
  4307.        unsigned short  ae_cp_connid;
  4308.        unsigned short  ae_cp_reason;
  4309.    };
  4310.  
  4311.  where
  4312.  
  4313.  ae_cp_compname
  4314.    Specifies the offset (from the beginning of the ae_connstop data
  4315.    structure) to an ASCIIZ string that specifies the name of the workstation
  4316.    that established the session.
  4317.  
  4318.  ae_cp_username
  4319.    Specifies the offset (from the beginning of the ae_connstop data
  4320.    structure) to an ASCIIZ string that specifies the name of the user who
  4321.    initiated the session. If ae_cp_username is 0, the username and
  4322.    workstation name are assumed to be the same.
  4323.  
  4324.  ae_cp_netname
  4325.    Specifies the offset (from the beginning of the ae_connstop data
  4326.    structure) to an ASCIIZ string that specifies the sharename of the
  4327.    connected resource.
  4328.  
  4329.  ae_cp_connid
  4330.    Specifies the connection identification number.
  4331.  
  4332.  ae_cp_reason
  4333.    Specifies the reason the session was disconnected. The AUDIT.H header file
  4334.    defines these possible values:
  4335.  
  4336.  Code        Value  Meaning
  4337.  ────────────────────────────────────────────────────────────────────────────
  4338.  AE_NORMAL   0      Normal disconnection occurred or the username limit was
  4339.                     exceeded.
  4340.  
  4341.  AE_SESSDIS  1      An error, session disconnection, or bad password
  4342.                     occurred.
  4343.  
  4344.  AE_UNSHARE  2      Autodisconnection (time-out) occurred, the sharename
  4345.                     was removed, or administrative permissions were lacking.
  4346.  
  4347.  ────────────────────────────────────────────────────────────────────────────
  4348.  
  4349.  
  4350.  Connection Rejected - The ae_connrej data structure is associated with an
  4351.  audit entry of type AE_CONNREJ. The ae_connrej data structure has this
  4352.  format:
  4353.  
  4354.    struct ae_connrej {
  4355.        unsigned short  ae_cr_compname;
  4356.        unsigned short  ae_cr_username;
  4357.        unsigned short  ae_cr_netname;
  4358.        unsigned short  ae_cr_reason;
  4359.    };
  4360.  
  4361.  where
  4362.  
  4363.  ae_cr_compname
  4364.    Specifies the offset (from the beginning of the ae_connrej data structure)
  4365.    to an ASCIIZ string that specifies the name of the workstation that
  4366.    established the session.
  4367.  
  4368.  ae_cr_username
  4369.    Specifies the offset (from the beginning of the ae_connrej data structure)
  4370.    to an ASCIIZ string that specifies the name of the user who initiated the
  4371.    session. If ae_cr_username is 0, the username and workstation name are
  4372.    assumed to be the same.
  4373.  
  4374.  ae_cr_netname
  4375.    Specifies the offset (from the beginning of the ae_connrej data structure)
  4376.    to an ASCIIZ string that specifies the sharename of the desired resource.
  4377.  
  4378.  ae_cr_reason
  4379.    Specifies the reason the session was disconnected. The AUDIT.H header file
  4380.    defines these possible values:
  4381.  
  4382.  Code              Value  Meaning
  4383.  ────────────────────────────────────────────────────────────────────────────
  4384.  AE_USERLIMIT      0      Normal disconnection occurred or the username
  4385.                           limit was exceeded.
  4386.  
  4387.  AE_BADPW          1      An error, session disconnection, or bad password
  4388.                           occurred.
  4389.  
  4390.  AE_ADMINPRIVREQD  2      Autodisconnection (time-out) occurred, the
  4391.                           sharename was removed, or administrative
  4392.                           permissions were lacking.
  4393.  
  4394.  AE_NOACCESSPERM   3      No access permissions exist for the shared
  4395.                           resource.
  4396.  
  4397.  ────────────────────────────────────────────────────────────────────────────
  4398.  
  4399.  
  4400.  Access Granted (level 1) - The ae_resaccess data structure is associated
  4401.  with an audit entry of type AE_RESACCESS. The ae_resaccess data structure
  4402.  has this format:
  4403.  
  4404.    struct ae_resaccess {
  4405.        unsigned short  ae_ra_compname;
  4406.        unsigned short  ae_ra_username;
  4407.        unsigned short  ae_ra_resname;
  4408.        unsigned short  ae_ra_operation;
  4409.        unsigned short  ae_ra_returncode;
  4410.        unsigned short  ae_ra_restype;
  4411.        unsigned short  ae_ra_fileid;
  4412.    };
  4413.  
  4414.  where
  4415.  
  4416.  ae_ra_compname
  4417.    Specifies the offset (from the beginning of the ae_resaccess data
  4418.    structure) to an ASCIIZ string that specifies the name of the workstation
  4419.    that established the session.
  4420.  
  4421.  ae_ra_username
  4422.    Specifies the offset (from the beginning of the ae_resaccess data
  4423.    structure) to an ASCIIZ string that specifies the name of the user who
  4424.    initiated the session. If ae_ra_username is 0, the username and
  4425.    workstation name are assumed to be the same.
  4426.  
  4427.  ae_ra_resname
  4428.    Specifies the offset (from the beginning of the ae_resaccess data
  4429.    structure) to an ASCIIZ string that specifies the name of the resource
  4430.    accessed.
  4431.  
  4432.  ae_ra_operation
  4433.    Specifies which operation was performed. The ACCESS.H header file defines
  4434.    these possible values:
  4435.  
  4436. ╓┌──────────────┌─────────┌──────────────────────────────────────────────────╖
  4437.  Code           Bit Mask  Meaning
  4438.  ────────────────────────────────────────────────────────────────────────────
  4439.  ACCESS_READ    0x01      Data was read or executed from a resource.
  4440.  
  4441.  ACCESS_WRITE   0x02      Data was written to a resource.
  4442.  
  4443.  ACCESS_CREATE  0x04      An instance of the resource (for example, a file)
  4444.                           was created; data may have been written to the
  4445.                           resource when creating it.
  4446.  
  4447.  ACCESS_EXEC    0x08      A resource was executed.
  4448.  
  4449.  ACCESS_DELETE  0x10      A resource was deleted.
  4450.  
  4451.  ACCESS_ATRIB   0x20      Resource attributes were modified.
  4452.  
  4453.  ACCESS_PERM    0x40      Resource permissions (read, write, create,
  4454.  Code           Bit Mask  Meaning
  4455.  ────────────────────────────────────────────────────────────────────────────
  4456. ACCESS_PERM    0x40      Resource permissions (read, write, create,
  4457.                           execute, and delete) for a user were modified, or
  4458.                           an application was modified.
  4459.  
  4460.  ────────────────────────────────────────────────────────────────────────────
  4461.  
  4462.  
  4463.  
  4464.  ae_ra_returncode
  4465.    Specifies the return code from the particular operation. If
  4466.    ae_ra_returncode is 0, the operation was successful.
  4467.  
  4468.  ae_ra_restype
  4469.    Specifies the server message block (SMB) request function code.
  4470.  
  4471.  ae_ra_fileid
  4472.    Specifies the identification number of the file.
  4473.  
  4474.  Access Granted (level 2) - The ae_resaccess2 data structure is associated
  4475.  with an audit entry of type AE_RESACCESS2. The ae_resaccess2 data structure
  4476.  has this format:
  4477.  
  4478.    struct ae_resaccess2 {
  4479.        unsigned short  ae_ra2_compname;
  4480.        unsigned short  ae_ra2_username;
  4481.        unsigned short  ae_ra2_resname;
  4482.        unsigned short  ae_ra2_operation;
  4483.        unsigned short  ae_ra2_returncode;
  4484.        unsigned short  ae_ra2_restype;
  4485.        unsigned long   ae_ra2_fileid;
  4486.    };
  4487.  
  4488.  where
  4489.  
  4490.  ae_ra2_compname through ae_ra2_restype
  4491.    Are the same as the corresponding elements of the ae_resaccess data
  4492.    structure. For more information, see the "Access Granted (level 1)"
  4493.    section.
  4494.  
  4495.  ae_ra2_fileid
  4496.    Specifies the identification number of the file. It is given as an
  4497.    unsigned long value, rather than as an unsigned short value as in the
  4498.    ae_resaccess structure.
  4499.  
  4500.  Access Denied - The ae_resaccessrej data structure is associated with an
  4501.  audit entry of type AE_RESACCESSREJ. The ae_resaccessrej data structure has
  4502.  this format:
  4503.  
  4504.    struct ae_resaccessrej {
  4505.        unsigned short  ae_rr_compname;
  4506.        unsigned short  ae_rr_username;
  4507.        unsigned short  ae_rr_resname;
  4508.        unsigned short  ae_rr_operation;
  4509.    };
  4510.  
  4511.  where
  4512.  
  4513.  ae_rr_compname
  4514.    Specifies the offset (from the beginning of the ae_resaccessrej data
  4515.    structure) to an ASCIIZ string that specifies the name of the workstation
  4516.    that established the session.
  4517.  
  4518.  ae_rr_username
  4519.    Specifies the offset (from the beginning of the ae_resaccessrej data
  4520.    structure) to an ASCIIZ string that specifies the name of the user who
  4521.    initiated the session. If ae_rr_username is 0, the username and
  4522.    workstation name are assumed to be the same.
  4523.  
  4524.  ae_rr_resname
  4525.    Specifies the offset (from the beginning of the ae_resaccessrej data
  4526.    structure) to an ASCIIZ string that specifies the name of the resource to
  4527.    which access was denied.
  4528.  
  4529.  ae_rr_operation
  4530.    Specifies the operation requested. The possible values are the same as
  4531.    those for the ae_ra_operation element of the ae_resaccess data structure
  4532.    and the ae_ra2_operation element of the ae_resaccess2 data structure. For
  4533.    more information, see the previous two sections, "Access Granted (level
  4534.    1)" and "Access Granted (level 2)."
  4535.  
  4536.  File Closed - The ae_closefile data structure is associated with an audit
  4537.  entry of type AE_CLOSEFILE. The ae_closefile data structure has this format:
  4538.  
  4539.  
  4540.    struct ae_closefile {
  4541.        unsigned short  ae_cf_compname;
  4542.        unsigned short  ae_cf_username;
  4543.        unsigned short  ae_cf_resname;
  4544.        unsigned short  ae_cf_fileid;
  4545.        unsigned long   ae_cf_duration
  4546.        unsigned short  ae_cf_reason;
  4547.    };
  4548.  
  4549.  where
  4550.  
  4551.  ae_cf_compname
  4552.    Specifies the offset (from the beginning of the ae_closefile data
  4553.    structure) to an ASCIIZ string that specifies the name of the workstation
  4554.    that established the session.
  4555.  
  4556.  ae_cf_username
  4557.    Specifies the offset (from the beginning of the ae_closefile data
  4558.    structure) to an ASCIIZ string that specifies the name of the user who
  4559.    initiated the session. If ae_cf_username is 0, the username and
  4560.    workstation name are assumed to be the same.
  4561.  
  4562.  ae_cf_resname
  4563.    Specifies the offset (from the beginning of the ae_closefile data
  4564.    structure) to an ASCIIZ string that specifies the name of the resource
  4565.    that owns the accessed files.
  4566.  
  4567.  ae_cf_fileid
  4568.    Specifies the identification number of the file.
  4569.  
  4570.  ae_cf_duration
  4571.    Specifies how many seconds the resource was used.
  4572.  
  4573.  ae_cf_reason
  4574.    Specifies the reason the session was disconnected. The AUDIT.H header file
  4575.    defines these possible values:
  4576.  
  4577.  Code             Value  Meaning
  4578.  ────────────────────────────────────────────────────────────────────────────
  4579.  AE_NORMAL_CLOSE  0      Normal client disconnection.
  4580.  AE_SES_CLOSE     1      Session disconnection.
  4581.  AE_ADMIN_CLOSE   2      Administrative disconnection.
  4582.  ────────────────────────────────────────────────────────────────────────────
  4583.  
  4584.  Service Status Code or Text Changed  - The ae_servicestat data structure is
  4585.  associated with an audit entry of type AE_SERVICESTAT. The ae_servicestat
  4586.  data structure has this format:
  4587.  
  4588.    struct ae_servicestat {
  4589.        unsigned short  ae_ss_compname;
  4590.        unsigned short  ae_ss_username;
  4591.        unsigned short  ae_ss_svcname;
  4592.        unsigned short  ae_ss_status;
  4593.        unsigned long   ae_ss_code;
  4594.        unsigned short  ae_ss_text;
  4595.        unsigned short  ae_ss_returnval;
  4596.    };
  4597.  
  4598.  where
  4599.  
  4600.  ae_ss_compname
  4601.    Specifies the offset (from the beginning of the ae_servicestat data
  4602.    structure) to an ASCIIZ string that specifies the name of the workstation
  4603.    that established the session.
  4604.  
  4605.  ae_ss_username
  4606.    Specifies the offset (from the beginning of the ae_servicestat data
  4607.    structure) to an ASCIIZ string that specifies the name of the user who
  4608.    initiated the session. If ae_ss_username is 0, the username and
  4609.    workstation name are assumed to be the same.
  4610.  
  4611.  ae_ss_svcname
  4612.    Specifies the offset (from the beginning of the ae_servicestat data
  4613.    structure) to an ASCIIZ string that specifies the name of a service.
  4614.  
  4615.  ae_ss_status
  4616.    Specifies the service status to set.
  4617.  
  4618.  ae_ss_code
  4619.    Specifies the service code to set.
  4620.  
  4621.  ae_ss_text
  4622.    Specifies the offset to the text to set.
  4623.  
  4624.  ae_ss_returnval
  4625.    Specifies the return value.
  4626.  
  4627.  Access Control List (ACL) Modification  - The ae_aclmod data structure is
  4628.  associated with audit entries of type AE_ACLMOD and AE_ACLMODFAIL. The
  4629.  ae_aclmod data structure has this format:
  4630.  
  4631.    struct ae_aclmod {
  4632.        unsigned short  ae_am_compname;
  4633.        unsigned short  ae_am_username;
  4634.        unsigned short  ae_am_resname;
  4635.        unsigned short  ae_am_action;
  4636.        unsigned short  ae_am_datalen;
  4637.    };
  4638.  
  4639.  where
  4640.  
  4641.  ae_am_compname
  4642.    Specifies the offset (from the beginning of the ae_aclmod data structure)
  4643.    to an ASCIIZ string that specifies the name of the workstation that
  4644.    established the session.
  4645.  
  4646.  ae_am_username
  4647.    Specifies the offset (from the beginning of the ae_aclmod data structure)
  4648.    to an ASCIIZ string that specifies the name of the user who initiated the
  4649.    session. If ae_am_username is 0, the username and workstation name are
  4650.    assumed to be the same.
  4651.  
  4652.  ae_am_resname
  4653.    Specifies the offset (from the beginning of the ae_aclmod data structure)
  4654.    to an ASCIIZ string that specifies the name of the resource whose ACL was
  4655.    modified.
  4656.  
  4657.  ae_am_action
  4658.    Specifies the action performed on the ACL record. It is one of the
  4659.    following values:
  4660.  
  4661.  Value                   Meaning
  4662.  ────────────────────────────────────────────────────────────────────────────
  4663.  0                       Modification.
  4664.  1                       Deletion.
  4665.  2                       Addition.
  4666.  ────────────────────────────────────────────────────────────────────────────
  4667.  
  4668.  ae_am_datalen
  4669.    Specifies the length of data that follows the fixed data structure. This
  4670.    is always 0 in records generated by Microsoft LAN Manager 2.0.
  4671.  
  4672.  User Accounts Subsystem (UAS) Modification  - The ae_uasmod data structure
  4673.  is associated with an audit entry of type AE_UASMOD. The ae_uasmod data
  4674.  structure has this format:
  4675.  
  4676.    struct ae_uasmod {
  4677.        unsigned short  ae_um_compname;
  4678.        unsigned short  ae_um_username;
  4679.        unsigned short  ae_um_resname;
  4680.        unsigned short  ae_um_rectype;
  4681.        unsigned short  ae_um_action;
  4682.        unsigned short  ae_um_datalen;
  4683.    };
  4684.  
  4685.  where
  4686.  
  4687.  ae_um_compname
  4688.    Specifies the offset (from the beginning of the ae_uasmod data structure)
  4689.    to an ASCIIZ string that specifies the name of the workstation that
  4690.    established the session.
  4691.  
  4692.  ae_um_username
  4693.    Specifies the offset (from the beginning of the ae_uasmod data structure)
  4694.    to an ASCIIZ string that specifies the name of the user who initiated the
  4695.    session. If ae_um_username is 0, the username and workstation name are
  4696.    assumed to be the same.
  4697.  
  4698.  ae_um_resname
  4699.    Specifies the offset (from the beginning of the ae_uasmod data structure)
  4700.    to an ASCIIZ string that specifies the name of the resource whose entry
  4701.    was modified.
  4702.  
  4703.  ae_um_rectype
  4704.    Specifies the type of UAS record. It is one of the following values:
  4705.  
  4706.  Value                   Meaning
  4707.  ────────────────────────────────────────────────────────────────────────────
  4708.  0                       User record.
  4709.  1                       Group record.
  4710.  2                       UAS modals.
  4711.  ────────────────────────────────────────────────────────────────────────────
  4712.  
  4713.  ae_um_action
  4714.    Specifies the action performed on the UAS record. It is one of the
  4715.    following values:
  4716.  
  4717.  Value                   Meaning
  4718.  ────────────────────────────────────────────────────────────────────────────
  4719.  0                       Modification.
  4720.  1                       Deletion.
  4721.  2                       Addition.
  4722.  ────────────────────────────────────────────────────────────────────────────
  4723.  
  4724.  ae_um_datalen
  4725.    Specifies the length of the data that follows the fixed data structure.
  4726.    This is always 0 in records generated by Microsoft LAN Manager 2.0.
  4727.  
  4728.  Network Logon Record - The ae_netlogon data structure is associated with an
  4729.  audit entry of type AE_NETLOGON. The ae_netlogon data structure has this
  4730.  format:
  4731.  
  4732.    struct ae_netlogon {
  4733.        unsigned short  ae_no_compname;
  4734.        unsigned short  ae_no_username;
  4735.        unsigned short  ae_no_privilege;
  4736.        unsigned short  ae_no_authflags;
  4737.    };
  4738.  
  4739.  where
  4740.  
  4741.  ae_no_compname
  4742.    Specifies the offset (from the beginning of the ae_netlogon data
  4743.    structure) to an ASCIIZ string that specifies the name of the workstation
  4744.    that established the session.
  4745.  
  4746.  ae_no_username
  4747.    Specifies the offset (from the beginning of the ae_netlogon data
  4748.    structure) to an ASCIIZ string that specifies the name of the user who
  4749.    initiated the session. If ae_no_username is 0, the username and
  4750.    workstation name are assumed to be the same.
  4751.  
  4752.  ae_no_privilege
  4753.    Specifies the privilege level of the user logging on. The AUDIT.H header
  4754.    file defines these possible values:
  4755.  
  4756.  Code      Value  Meaning
  4757.  ────────────────────────────────────────────────────────────────────────────
  4758.  AE_GUEST  0      Guest privilege.
  4759.  AE_USER   1      User privilege.
  4760.  AE_ADMIN  2      Administrative privilege.
  4761.  ────────────────────────────────────────────────────────────────────────────
  4762.  
  4763.  ae_no_authflags
  4764.    Reserved; must be 0.
  4765.  
  4766.  Network Logoff Record - The ae_netlogoff data structure is associated with
  4767.  an audit entry of type AE_NETLOGOFF. The ae_netlogoff data structure has
  4768.  this format:
  4769.  
  4770.    struct ae_netlogoff {
  4771.        unsigned short  ae_nf_compname;
  4772.        unsigned short  ae_nf_username;
  4773.        unsigned short  ae_nf_reserved1;
  4774.        unsigned short  ae_nf_reserved2;
  4775.    };
  4776.  
  4777.  where
  4778.  
  4779.  ae_nf_compname
  4780.    Specifies the offset (from the beginning of the ae_netlogoff data
  4781.    structure) to an ASCIIZ string that specifies the name of the workstation
  4782.    that established the session.
  4783.  
  4784.  ae_nf_username
  4785.    Specifies the offset (from the beginning of the ae_netlogoff data
  4786.    structure) to an ASCIIZ string that specifies the name of the user who
  4787.    initiated the session. If ae_nf_username is 0, the username and
  4788.    workstation name are assumed to be the same.
  4789.  
  4790.  ae_nf_reserved1
  4791.    Reserved; must be 0.
  4792.  
  4793.  ae_nf_reserved2
  4794.    Reserved; must be 0.
  4795.  
  4796.  Account Limit Exceeded  - The ae_acclim data structure is associated with an
  4797.  audit entry of type AE_ACCLIMITEXCD. The ae_acclim data structure has this
  4798.  format:
  4799.  
  4800.    struct ae_acclim {
  4801.        unsigned short  ae_al_compname;
  4802.        unsigned short  ae_al_username;
  4803.        unsigned short  ae_al_resname;
  4804.        unsigned short  ae_al_limit;
  4805.    };
  4806.  
  4807.  where
  4808.  
  4809.  ae_al_compname
  4810.    Specifies the offset (from the beginning of the ae_acclim data structure)
  4811.    to an ASCIIZ string that specifies the name of the workstation that
  4812.    established the session.
  4813.  
  4814.  ae_al_username
  4815.    Specifies the offset (from the beginning of the ae_acclim data structure)
  4816.    to an ASCIIZ string that specifies the name of the user who initiated the
  4817.    session. If ae_al_username is 0, the username and workstation name are
  4818.    assumed to be the same.
  4819.  
  4820.  ae_al_resname
  4821.    Specifies the offset to the resource name; must be 0. This field is not
  4822.    used in LAN Manager 2.0.
  4823.  
  4824.  ae_al_limit
  4825.    Specifies the limit that was exceeded. The AUDIT.H header file defines
  4826.    these possible values:
  4827.  
  4828.  Code               Value  Meaning
  4829.  ────────────────────────────────────────────────────────────────────────────
  4830.  AE_LIM_UNKNOWN     0      Unknown or unavailable.
  4831.  AE_LIM_LOGONHOURS  1      Logon hours.
  4832.  ────────────────────────────────────────────────────────────────────────────
  4833.  
  4834.  See Also
  4835.  
  4836.  For information about             See
  4837.  ────────────────────────────────────────────────────────────────────────────
  4838.  LAN Manager network commands      LAN Manager administrator's manual(s)
  4839.  
  4840.  LANMAN.INI file                   LAN Manager administrator's manual(s)
  4841.  
  4842.  Permission levels                 Access Permissions Category and User
  4843.                                    Category
  4844.  
  4845.  
  4846.  NetAuditClear
  4847.  ────────────────────────────────────────────────────────────────────────────
  4848.  
  4849.  NetAuditClear clears the audit log on a server and, optionally, saves the
  4850.  entries in a backup file. When executed locally, NetAuditClear requires that
  4851.  the NETWKSTA device driver be installed, but does not require that the
  4852.  Workstation service be started. When a servername parameter is supplied,
  4853.  NetAuditClear requires that the local Workstation service be started.
  4854.  
  4855.  
  4856.  Operating Systems Supported
  4857.  
  4858.  
  4859.    ■   MS OS/2 version 1.2, local and remote
  4860.  
  4861.    ■   MS OS/2 version 1.1, remote only
  4862.  
  4863.    ■   MS-DOS, remote only
  4864.  
  4865.  
  4866.  
  4867.  Privilege Level
  4868.  
  4869.  Admin privilege is required to successfully execute NetAuditClear on a
  4870.  remote server or on a computer that has local security enabled.
  4871.  
  4872.  
  4873.  Syntax
  4874.  
  4875.    #define INCL_NETAUDIT
  4876.    #define INCL_NETERRORS
  4877.    #include <lan.h>
  4878.  
  4879.    API_FUNCTION
  4880.    NetAuditClear (const char far *  pszServer,
  4881.                   const char far *  pszBackupFile,
  4882.                   char far *        pszReserved
  4883.                  );
  4884.  
  4885.  where
  4886.  
  4887.  pszServer
  4888.    Points to an ASCIIZ string that contains the name of the server on which
  4889.    to execute NetAuditClear. A null pointer or null string specifies the
  4890.    local computer.
  4891.  
  4892.  pszBackupFile
  4893.    Points to an ASCIIZ string that contains a name for the optional backup
  4894.    file. The calling application must have create and write permissions for
  4895.    the path specified by pszBackupFile, and the path must already exist. If
  4896.    the pathname is relative, it is assumed to be relative to the LAN Manager
  4897.    LOGS directory. A null pointer specifies not to back up the audit log.
  4898.  
  4899.  pszReserved
  4900.    Reserved; must be a null pointer.
  4901.  
  4902.  Return Codes
  4903.  
  4904. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  4905.  Code                              Value   Meaning
  4906.  ────────────────────────────────────────────────────────────────────────────
  4907.  NERR_Success                      0       The function encountered no
  4908.                                            errors.
  4909.  
  4910.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  4911.  
  4912.  ERROR_ACCESS_DENIED               5       The user has insufficient
  4913.                                            privilege for this operation.
  4914.  
  4915.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  4916.  Code                              Value   Meaning
  4917.  ────────────────────────────────────────────────────────────────────────────
  4918. ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  4919.  
  4920.  ERROR_BAD_NETPATH                 53      The network path was not found.
  4921.  
  4922.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  4923.  
  4924.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  4925.                                            invalid.
  4926.  
  4927.  ERROR_INVALID_NAME                123     The character or file system
  4928.                                            name is invalid.
  4929.  
  4930.  ERROR_FILENAME_EXCED_RANGE        206     The filename specified is
  4931.                                            invalid for the file system.
  4932.                                            This code is returned when
  4933.                                            checking a FAT disk partition
  4934.                                            only. It cannot be returned for
  4935.                                            an HPFS partition.
  4936.  
  4937.  Code                              Value   Meaning
  4938.  ────────────────────────────────────────────────────────────────────────────
  4939. 
  4940.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  4941.                                            is not installed.
  4942.  
  4943.  NERR_RemoteOnly                   2106    This operation can be performed
  4944.                                            only on a server.
  4945.  
  4946.  NERR_WkstaNotStarted              2138    The Workstation service is not
  4947.                                            started.
  4948.  
  4949.  NERR_BadTransactConfig            2141    The server is not configured for
  4950.                                            this transaction: IPC$ is not
  4951.                                            shared.
  4952.  
  4953.  NERR_InvalidComputer              2351    The specified computername is
  4954.                                            invalid.
  4955.  
  4956.  ────────────────────────────────────────────────────────────────────────────
  4957.  
  4958.  Code                              Value   Meaning
  4959.  ────────────────────────────────────────────────────────────────────────────
  4960. 
  4961.  
  4962.  
  4963.  See Also
  4964.  
  4965.  For information about             See
  4966.  ────────────────────────────────────────────────────────────────────────────
  4967.  Getting the status of audit log   NetServerGetInfo
  4968.  capacity
  4969.  
  4970.  Reading an entry from the audit   NetAuditRead
  4971.  log
  4972.  
  4973.  Writing an entry to the audit     NetAuditWrite
  4974.  log
  4975.  
  4976.  
  4977.  NetAuditRead
  4978.  ────────────────────────────────────────────────────────────────────────────
  4979.  
  4980.  NetAuditRead reads from the audit log on a server. It requires that the
  4981.  Workstation service be started.
  4982.  
  4983.  
  4984.  Operating Systems Supported
  4985.  
  4986.  
  4987.    ■   MS OS/2 version 1.2, local and remote
  4988.  
  4989.    ■   MS OS/2 version 1.1, remote only
  4990.  
  4991.    ■   MS-DOS, remote only
  4992.  
  4993.  
  4994.  
  4995.  Privilege Level
  4996.  
  4997.  Admin privilege or accounts, comm, print, or server operator privilege is
  4998.  required to successfully execute NetAuditRead on a remote server or on a
  4999.  computer that has local security enabled.
  5000.  
  5001.  
  5002.  Syntax
  5003.  
  5004.    #define INCL_NETAUDIT
  5005.    #define INCL_NETERRORS
  5006.    #include <lan.h>
  5007.  
  5008.    API_FUNCTION
  5009.    NetAuditRead (const char far *      pszServer,
  5010.                  const char far *      pszReserved1
  5011.                  HLOG far *            phAuditLog,
  5012.                  unsigned long         ulOffset,
  5013.                  unsigned short far *  pusReserved2,
  5014.                  unsigned long         ulReserved3,
  5015.                  unsigned long         flOffset,
  5016.                  char far *            pbBuffer,
  5017.                  unsigned short        cbBuffer,
  5018.                  unsigned short far *  pcbReturned,
  5019.                  unsigned short far *  pcbTotalAvail
  5020.                 );
  5021.  
  5022.  where
  5023.  
  5024.  pszServer
  5025.    Points to an ASCIIZ string that contains the name of the server on which
  5026.    to execute NetAuditRead. A null pointer or null string specifies the local
  5027.    computer.
  5028.  
  5029.  pszReserved1
  5030.    Reserved; must be a null pointer.
  5031.  
  5032.  phAuditLog
  5033.    Points to the handle for the audit log. An application calling
  5034.    NetAuditRead for the first time must initialize the audit log handle as
  5035.    follows:
  5036.  
  5037.  Bits                             Value
  5038.  ────────────────────────────────────────────────────────────────────────────
  5039.  127 (MSB) - 64                   0
  5040.  63 - 0 (LSB)                     1
  5041.  ────────────────────────────────────────────────────────────────────────────
  5042.  
  5043.    The most significant bit (MSB) is the leftmost bit; the least significant
  5044.    bit (LSB) is the rightmost bit. After the first call, each call to
  5045.    NetAuditRead must be given the value for the handle returned by the
  5046.    previous call.
  5047.  
  5048.  ulOffset
  5049.    Specifies the record offset at which to begin reading. This parameter is
  5050.    ignored unless bit 1 in the flOffset parameter is set. If flOffset bit 1
  5051.    is set, ulOffset is taken as an offset based on the record number (not
  5052.    bytes) at which the returned data should begin. Note that the record
  5053.    offset parameter is zero-based from both directions, depending upon the
  5054.    direction of the read. If reading backward, record 0 is the last record in
  5055.    the log. If reading forward, record 0 is the first record in the log.
  5056.  
  5057.  pusReserved2
  5058.    Reserved; must be a null pointer.
  5059.  
  5060.  ulReserved3
  5061.    Reserved; must be 0.
  5062.  
  5063.  flOffset
  5064.    Specifies the open flags, as follows:
  5065.  
  5066.  Bit(s)                            Meaning
  5067.  ────────────────────────────────────────────────────────────────────────────
  5068.  0                                 If 0, the log is read forward. If 1, the
  5069.                                    log is read backward and records are
  5070.                                    returned in the buffer in reverse
  5071.                                    chronological order (newest records
  5072.                                    first).
  5073.  
  5074.  1                                 If 0, reading proceeds sequentially. If
  5075.                                    1, reading proceeds from the nth record
  5076.                                    from the start of the log, where n is
  5077.                                    the offset parameter.
  5078.  
  5079.  2-31                              Reserved; must be 0.
  5080.  
  5081.  ────────────────────────────────────────────────────────────────────────────
  5082.  
  5083.  
  5084.  pbBuffer
  5085.    Points to the buffer for returned data. After a successful read operation,
  5086.    this buffer contains a sequence of audit entries with the accompanying
  5087.    variable-length data structures.
  5088.  
  5089.  cbBuffer
  5090.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  5091.  
  5092.  pcbReturned
  5093.    Points to an unsigned short integer in which a count of the number of
  5094.    bytes read into the buffer is returned.
  5095.  
  5096.  pcbTotalAvail
  5097.    Points to an unsigned short integer in which a count of the number of
  5098.    bytes available is returned.
  5099.  
  5100.  Return Codes
  5101.  
  5102. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  5103.  Code                              Value   Meaning
  5104.  ────────────────────────────────────────────────────────────────────────────
  5105.  Code                              Value   Meaning
  5106.  ────────────────────────────────────────────────────────────────────────────
  5107.  NERR_Success                      0       The function encountered no
  5108.                                            errors.
  5109.  
  5110.  ERROR_ACCESS_DENIED               5       The user has insufficient
  5111.                                            privilege for this operation.
  5112.  
  5113.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  5114.  
  5115.  ERROR_BAD_NETPATH                 53      The network path was not found.
  5116.  
  5117.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  5118.  
  5119.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  5120.                                            invalid.
  5121.  
  5122.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  5123.                                            is not installed.
  5124.  
  5125.  NERR_RemoteOnly                   2106    This operation can be performed
  5126.  Code                              Value   Meaning
  5127.  ────────────────────────────────────────────────────────────────────────────
  5128. NERR_RemoteOnly                   2106    This operation can be performed
  5129.                                            only on a server.
  5130.  
  5131.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  5132.  
  5133.  NERR_WkstaNotStarted              2138    The Workstation service is not
  5134.                                            started.
  5135.  
  5136.  NERR_BadTransactConfig            2141    The server is not configured for
  5137.                                            this transaction: IPC$ is not
  5138.                                            shared.
  5139.  
  5140.  NERR_InvalidAPI                   2142    The requested API is not
  5141.                                            supported on the remote server.
  5142.  
  5143.  NERR_InvalidComputer              2351    The specified computername is
  5144.                                            invalid.
  5145.  
  5146.  NERR_LogFileChanged               2378    The log file has changed since
  5147.  Code                              Value   Meaning
  5148.  ────────────────────────────────────────────────────────────────────────────
  5149. NERR_LogFileChanged               2378    The log file has changed since
  5150.                                            it was last read.
  5151.  
  5152.  NERR_LogFileCorrupt               2379    The log file is corrupt.
  5153.  
  5154.  NERR_InvalidLogSeek               2440    The log file does not contain
  5155.                                            the requested record number.
  5156.  
  5157.  ────────────────────────────────────────────────────────────────────────────
  5158.  
  5159.  
  5160.  
  5161.  
  5162.  Remarks
  5163.  
  5164.  To read the contents of an audit log, an application calls NetAuditRead
  5165.  repeatedly until it returns information (via the pcbTotalAvail parameter)
  5166.  that indicates there is no more data to be read. Each call to NetAuditRead
  5167.  returns a handle that must be provided to any subsequent call to
  5168.  NetAuditRead. This handle changes with each subsequent call; it is not a
  5169.  system file handle and should never be treated as such.
  5170.  
  5171.  Note that the audit log can contain much more than 64K of data. If
  5172.  pcbTotalAvail is returned with a value of 0xFFFF, there can be 0xFFFF or
  5173.  more bytes of data available. The application should continue to read the
  5174.  log until 0 is returned in pcbTotalAvail.
  5175.  
  5176.  NetAuditRead passes data back in the buffer in whole records. The
  5177.  application never receives a partial record in the buffer. Use the value
  5178.  pointed to by pcbReturned to determine the end of valid data in the buffer.
  5179.  
  5180.  
  5181.  The audit log is written with the newest records appended to the end of the
  5182.  log. The flOffset parameter determines whether to read the log in forward or
  5183.  in reverse order.
  5184.  
  5185.  If the audit log is read partially, and then the log is cleared or a new
  5186.  record is written, subsequent reading with the handle returned from the
  5187.  first call to NetAuditRead returns an error. An application that finds the
  5188.  audit log changed between calls can reread the changed log by reissuing the
  5189.  call with the audit handle initialized as if it were making the call for the
  5190.  first time.
  5191.  
  5192.  Attempting to read the log while another application is writing an entry to
  5193.  the log results in NetAuditRead returning ERROR_SHARING_VIOLATION.
  5194.  
  5195.  See Also
  5196.  
  5197.  For information about             See
  5198.  ────────────────────────────────────────────────────────────────────────────
  5199.  Clearing an audit log             NetAuditClear
  5200.  
  5201.  Writing an entry to the audit     NetAuditWrite
  5202.  log
  5203.  
  5204.  
  5205.  NetAuditWrite
  5206.  ────────────────────────────────────────────────────────────────────────────
  5207.  
  5208.  NetAuditWrite writes an audit entry to the local audit log. For audit
  5209.  entries to be written to the log, the Server service must be started with
  5210.  auditing enabled.
  5211.  
  5212.  
  5213.  Operating Systems Supported
  5214.  
  5215.  
  5216.    ■   MS OS/2 version 1.2, local only
  5217.  
  5218.    ■   MS OS/2 version 1.1 not supported
  5219.  
  5220.    ■   MS-DOS not supported
  5221.  
  5222.  
  5223.  
  5224.  Privilege Level
  5225.  
  5226.  No special privilege level is required to successfully execute
  5227.  NetAuditWrite.
  5228.  
  5229.  
  5230.  Syntax
  5231.  
  5232.    #define INCL_NETAUDIT
  5233.    #define INCL_NETERRORS
  5234.    #include <lan.h>
  5235.  
  5236.    API_FUNCTION
  5237.    NetAuditWrite (unsigned short    usType,
  5238.                   const char far *  pbBuffer,
  5239.                   unsigned short    cbBuffer,
  5240.                   char far *        pszReserved1,
  5241.                   char far *        pszReserved2
  5242.                  );
  5243.  
  5244.  where
  5245.  
  5246.  usType
  5247.    Specifies the type of entry to write to the audit log.
  5248.  
  5249.  pbBuffer
  5250.    Points to a buffer that contains the data structure associated with the
  5251.    specified audit entry.
  5252.  
  5253.  cbBuffer
  5254.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  5255.  
  5256.  pszReserved1
  5257.    Reserved; must be a null pointer.
  5258.  
  5259.  pszReserved2
  5260.    Reserved; must be a null pointer.
  5261.  
  5262.  Return Codes
  5263.  
  5264. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  5265.  Code                              Value   Meaning
  5266.  ────────────────────────────────────────────────────────────────────────────
  5267.  NERR_Success                      0       The function encountered no
  5268.                                            errors.
  5269.  
  5270.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  5271.  
  5272.  ERROR_ACCESS_DENIED               5       The user has insufficient
  5273.  Code                              Value   Meaning
  5274.  ────────────────────────────────────────────────────────────────────────────
  5275. ERROR_ACCESS_DENIED               5       The user has insufficient
  5276.                                            privilege for this operation.
  5277.  
  5278.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  5279.  
  5280.  ERROR_NOT_SUPPORTED               50      This network request is not
  5281.                                            supported.
  5282.  
  5283.  ERROR_BAD_NETPATH                 53      The network path was not found.
  5284.  
  5285.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  5286.  
  5287.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  5288.                                            invalid.
  5289.  
  5290.  ERROR_NET_WRITE_FAULT             88      A network data fault occurred.
  5291.  
  5292.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  5293.                                            is not installed.
  5294.  Code                              Value   Meaning
  5295.  ────────────────────────────────────────────────────────────────────────────
  5296.                                           is not installed.
  5297.  
  5298.  NERR_ServerNotStarted             2114    The Server service is not
  5299.                                            started.
  5300.  
  5301.  NERR_WkstaNotStarted              2138    The Workstation service is not
  5302.                                            started.
  5303.  
  5304.  NERR_LogOverflow                  2377    The log file is too big.
  5305.  
  5306.  ────────────────────────────────────────────────────────────────────────────
  5307.  
  5308.  
  5309.  
  5310.  
  5311.  Remarks
  5312.  
  5313.  NetAuditWrite issues an admin alert by calling NetAlertRaise when the audit
  5314.  log reaches 80% capacity and again when the log reaches 100% capacity. At
  5315.  100% audit log capacity, NetAuditWrite fails and returns NERR_LogOverflow.
  5316.  Applications should periodically clear the audit log of outdated information
  5317.  to avoid the log reaching 100% capacity.
  5318.  
  5319.  Events of a particular type cannot be written to the audit log unless
  5320.  auditing for that type of event is enabled. If auditing for the event type
  5321.  is not enabled, NetAuditWrite still returns NERR_Success, but no entries are
  5322.  written.
  5323.  
  5324.  You can use one of these methods to enable auditing:
  5325.  
  5326.  
  5327.    ■   Set the auditing entry in the [server] section of the LANMAN.INI file
  5328.        to yes or to a list of event types to be audited.
  5329.  
  5330.    ■   Use the net start server command with the /auditing option.
  5331.  
  5332.  
  5333.  For more information, see the your LAN Manager administrator's manual(s).
  5334.  
  5335.  See Also
  5336.  
  5337.  For information about             See
  5338.  ────────────────────────────────────────────────────────────────────────────
  5339.  Alerts                            Alert Category
  5340.  
  5341.  Clearing the audit log            NetAuditClear
  5342.  
  5343.  Getting the status of audit log   NetServerGetInfo
  5344.  capacity
  5345.  
  5346.  Reading the audit log             NetAuditRead
  5347.  
  5348.  Setting the maximum size of the   NetServerSetInfo
  5349.  audit log
  5350.  
  5351.  
  5352.  
  5353.  
  5354.  
  5355.  Auditing Category Example
  5356.  
  5357.    /*
  5358.       NETAUD.C -- a sample program demonstrating NetAudit API functions.
  5359.  
  5360.       This program requires that you have admin privilege on the specified
  5361.       server.
  5362.  
  5363.          usage:  netaud [-s \\server] [-b backup]
  5364.  
  5365.          where  \\server = Name of the server. A servername must be preceded
  5366.  
  5367.                            by two backslashes (\\).
  5368.                 backup   = Name of the backup file.
  5369.  
  5370.       API               Used to...
  5371.       =============     ===========================================
  5372.       NetAuditRead      Read the audit log and display its contents
  5373.       NetAuditClear     Copy the audit log and then clear it
  5374.       NetAuditWrite     Write entries into the audit log
  5375.  
  5376.       This code sample is provided for demonstration purposes only.
  5377.       Microsoft makes no warranty, either express or implied,
  5378.       as to its usability in any given situation.
  5379.    */
  5380.  
  5381.    #define     INCL_NETERRORS
  5382.    #define     INCL_NETAUDIT
  5383.    #include    <lan.h>        // LAN Manager header files
  5384.  
  5385.    #include    <stdio.h>      // C run-time header files
  5386.    #include    <stdlib.h>
  5387.    #include    <malloc.h>
  5388.    #include    <time.h>
  5389.  
  5390.    #define DEFAULT_BACKUP     "AUDIT.BCK"
  5391.    #define BIG_BUFFER         32768
  5392.  
  5393.    void Usage (char * pszProgram);
  5394.  
  5395.    void main(int argc, char *argv[])
  5396.    {
  5397.       char *         pszServer = "";         // Servername
  5398.       char *         pszBackup = DEFAULT_BACKUP;  // Backup audit log
  5399.  
  5400.       int            iCount;                 // Index counter
  5401.       HLOG           hLogHandle;             // Audit log handle
  5402.       time_t         tTime;                  // Time of entry
  5403.       unsigned short cbBuffer;               // Size of buffer, in bytes
  5404.       unsigned short cbRead;                 // Count of bytes read
  5405.       unsigned short cbAvail;                // Count of bytes available
  5406.       API_RET_TYPE   uReturnCode;            // API return code
  5407.       struct audit_entry far * fpBuffer;     // Pointer to the data buffer
  5408.       struct audit_entry far * fpEntry;      // Single entry in the audit
  5409.    log
  5410.       struct ae_servicestat far * fpService; // Service status structure
  5411.  
  5412.       for (iCount = 1; iCount < argc; iCount++)
  5413.       {
  5414.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  5415.          {
  5416.             switch (tolower(*(argv[iCount]+1))) // Process switches
  5417.             {
  5418.                case 's':                        // -s servername
  5419.                   pszServer = argv[++iCount];
  5420.                   break;
  5421.                case 'b':                        // -b backup file
  5422.                   pszBackup = argv[++iCount];
  5423.                   break;
  5424.                case 'h':
  5425.                default:
  5426.                   Usage(argv[0]);
  5427.             }
  5428.          }
  5429.          else
  5430.             Usage(argv[0]);
  5431.       }
  5432.  
  5433.    //========================================================================
  5434.    //  NetAuditRead
  5435.    //
  5436.    //  This API reads and displays the audit log for the specified server.
  5437.    //  If the entry is for Service Status Code or Text Changed, print
  5438.    //  the service and computername.
  5439.    //========================================================================
  5440.  
  5441.       /*
  5442.        * Allocate a large buffer space to handle large audit logs.
  5443.        * The largest buffer allowed is 64K. If the audit log is
  5444.        * larger than the buffer specified, the API returns as many
  5445.        * full records as it can and the NERR_Success return code.
  5446.        * Subsequent reading starts from the end of the last record
  5447.        * read. To read the whole log, reading must continue until 0
  5448.        * is returned for the bytes available counter.
  5449.        */
  5450.  
  5451.    cbBuffer = BIG_BUFFER;                 // Can be up to 64K
  5452.  
  5453.       /*
  5454.        * Set the log handle for reading from the start of the audit log.
  5455.        * This handle is modified by the API; any subsequent reading
  5456.        * of unread data should use the returned handle.
  5457.        */
  5458.  
  5459.       hLogHandle.time = 0L;
  5460.       hLogHandle.last_flags = 0L;
  5461.       hLogHandle.offset = 0xFFFFFFFF;
  5462.       hLogHandle.last_flags = 0xFFFFFFFF;
  5463.  
  5464.       fpBuffer = _fmalloc(cbBuffer);         // Allocate memory for buffer
  5465.  
  5466.       if (fpBuffer == NULL)
  5467.       {
  5468.          fprintf(stderr, "Malloc failed -- out of memory.\n");
  5469.          exit(1);
  5470.       }
  5471.       uReturnCode = NetAuditRead(
  5472.                         pszServer,               // Servername
  5473.                         NULL,                    // Reserved; must be
  5474.    NULL
  5475.                         (HLOG far *)&hLogHandle, // Audit log handle
  5476.                         0L,                      // Start at record 0
  5477.                         NULL,                    // Reserved; must be
  5478.    NULL
  5479.                         0L,                      // Reserved; must be
  5480.    0
  5481.                         0L,                      // Read the log forward
  5482.                         (char far *)fpBuffer,    // Data returned here
  5483.                         cbBuffer,                // Size of buffer, in
  5484.    bytes
  5485.                         &cbRead,                 // Count of bytes read
  5486.                         &cbAvail);               // Count of available
  5487.    bytes
  5488.  
  5489.       printf("NetAuditRead returned %u\n", uReturnCode);
  5490.  
  5491.       if (uReturnCode == NERR_Success)
  5492.       {
  5493.          for ( fpEntry = fpBuffer;
  5494.                fpEntry < (struct audit_entry far *)
  5495.                                ((char far *)fpBuffer + cbRead); )
  5496.          {
  5497.             tTime = (time_t) fpEntry->ae_time;
  5498.  
  5499.             printf("   Type %d, at %s", fpEntry->ae_type,
  5500.                            asctime( gmtime ((const time_t *) &tTime)
  5501.    ) );
  5502.  
  5503.    /*
  5504.              * If the entry is for Service Status Code or Text Changed,
  5505.              * print the service and computername. This demonstrates
  5506.    how
  5507.              * to extract information using the offsets to the log.
  5508.              */
  5509.  
  5510.             if (fpEntry->ae_type == AE_SERVICESTAT)
  5511.             {
  5512.                fpService = (struct ae_servicestat far *)
  5513.                         ((char far *)fpEntry + fpEntry->ae_data_offset);
  5514.                printf("\tComputer = %Fs\n",
  5515.                         (char far *)fpService+fpService->ae_ss_compname);
  5516.  
  5517.                printf("\tService  = %Fs\n",
  5518.                         (char far *)fpService+fpService->ae_ss_svcname);
  5519.  
  5520.             }
  5521.             fpEntry = (struct audit_entry far *)
  5522.                         ((char far *)fpEntry + fpEntry->ae_len);
  5523.          }
  5524.  
  5525.          printf("\nBytes Read = 0x%X\n", cbRead);
  5526.  
  5527.          // To read the whole log, keep reading until cbAvail is 0.
  5528.  
  5529.          if (cbAvail)
  5530.             printf("Data still unread.\n\n");
  5531.          else
  5532.             printf("All data read.\n\n");
  5533.       }
  5534.  
  5535.    //========================================================================
  5536.    //  NetAuditClear
  5537.    //
  5538.    //  This API clears the audit log for the specified server. A backup
  5539.  
  5540.    //  will be kept in the file specified by pszBackup. If a null pointer
  5541.  
  5542.    //  is supplied, no backup is kept.
  5543.    //========================================================================
  5544.  
  5545.       uReturnCode = NetAuditClear(
  5546.                         pszServer,           // Servername
  5547.                         pszBackup,           // Name of backup file
  5548.                         NULL);               // Reserved; must be NULL
  5549.  
  5550.       printf("NetAuditClear returned %u\n", uReturnCode);
  5551.       printf("   backup file = %s \n", pszBackup);
  5552.  
  5553.    //========================================================================
  5554.    //  NetAuditWrite
  5555.    //
  5556.    //  This API writes back the entries read by the NetAuditRead call.
  5557.    //  Each entry read consisted of a fixed-length header, a variable-
  5558.    //  length data section, and a terminating size indicator. Only
  5559.    //  the variable-length data area is supplied in the NetAuditWrite
  5560.    //  buffer. Note: For any entries to be written to the audit log,
  5561.    the
  5562.    //  Server service must be started with auditing enabled.
  5563.    //========================================================================
  5564.  
  5565.       for ( fpEntry = fpBuffer;
  5566.             fpEntry < (struct audit_entry far *)
  5567.                             ((char far *)fpBuffer + cbRead); )
  5568.       {
  5569.          uReturnCode = NetAuditWrite(
  5570.                            fpEntry->ae_type,      // Entry type
  5571.                                                   // Buffer address
  5572.                            (char far *)fpEntry + fpEntry->ae_data_offset,
  5573.                                                   // Buffer length
  5574.                            fpEntry->ae_len - fpEntry->ae_data_offset
  5575.  
  5576.                               - sizeof(unsigned short),
  5577.                            NULL,                  // Reserved; must be
  5578.    NULL
  5579.                            NULL);                 // Reserved; must be
  5580.    NULL
  5581.  
  5582.          if (uReturnCode != NERR_Success)
  5583.          {
  5584.             printf("NetAuditWrite returned %u", uReturnCode);
  5585.             break;
  5586.          };
  5587.  
  5588.          fpEntry = (struct audit_entry far *)
  5589.                             ((char far *)fpEntry + fpEntry->ae_len);
  5590.       }
  5591.  
  5592.       _ffree(fpBuffer);
  5593.       exit(0);
  5594.    }
  5595.  
  5596.    void Usage (char * pszProgram)
  5597.    {
  5598.       fprintf(stderr, "Usage: %s [-s \\\\server] [-b backup]\n", pszProgram);
  5599.       exit(1);
  5600.    }
  5601.  
  5602.  
  5603.  
  5604.  
  5605.  
  5606.  
  5607.  
  5608.  
  5609.  
  5610.  Character Device Category
  5611.  
  5612.  Character Device API functions control shared communication devices and
  5613.  their asso- ciated queues. They require that the Workstation service be
  5614.  started and that the Server service be started on the specified server.
  5615.  
  5616.  The Character Device category functions, datatypes, structures, and
  5617.  constants are defined in the NETCONS.H, NETERR.H, and CHARDEV.H header
  5618.  files. A source program can access these definitions by defining the
  5619.  constants INCL_NETERRORS and INCL_NETCHARDEV, and including the master
  5620.  header file, LAN.H. For more information about these definitions, see the
  5621.  "Example" section, later in this category.
  5622.  
  5623.  These are the Character Device API functions:
  5624.  
  5625.  
  5626.    ■   NetCharDevControl
  5627.  
  5628.    ■   NetCharDevEnum
  5629.  
  5630.    ■   NetCharDevGetInfo
  5631.  
  5632.    ■   NetCharDevQEnum
  5633.  
  5634.    ■   NetCharDevQGetInfo
  5635.  
  5636.    ■   NetCharDevQPurge
  5637.  
  5638.    ■   NetCharDevQPurgeSelf
  5639.  
  5640.    ■   NetCharDevQSetInfo
  5641.  
  5642.  
  5643.  
  5644.  Description
  5645.  
  5646.  A modem, FAX machine, or serial printer may require that an application
  5647.  submit commands or change protocols dynamically. Such devices, which require
  5648.  direct and interactive communication, are called communication devices.
  5649.  
  5650.  A LAN Manager server can share one or more communication devices of the same
  5651.  type from a communication-device queue. A communication-device queue stores
  5652.  communication-device requests and sends the requests, one at a time, to a
  5653.  communication device. Multiple applications can use a server's communication
  5654.  devices by establishing connections to the communication-device queue. The
  5655.  server gives each application exclusive access to a device until the
  5656.  application is done using the device. The server allocates available devices
  5657.  based on the priority assigned to the queue.
  5658.  
  5659.  Three things must occur before an application can communicate with a
  5660.  communication device: the server must have a communication device connected
  5661.  to one of its available parallel or serial ports; the server must share a
  5662.  communication-device queue; and the requesting application must establish a
  5663.  connection to the shared communication-device queue.
  5664.  
  5665.  When the application is done using the communication device, it should close
  5666.  the device. Closing the device returns control of the device to the
  5667.  communication-device queue, making it available to another application.
  5668.  
  5669.  NetCharDevGetInfo returns information about a particular communication
  5670.  device. NetCharDevQGetInfo returns the status of a communication-device
  5671.  queue or the position in the waiting list of an application's request.
  5672.  
  5673.  NetCharDevEnum returns the status of all communication devices. All queues
  5674.  can be checked by calling NetCharDevQEnum.
  5675.  
  5676.  Applications can call NetCharDevQPurgeSelf to eliminate all requests
  5677.  submitted to a particular communication-device queue by the specified
  5678.  computer. NetCharDevQPurge removes all pending requests to a particular
  5679.  communication-device queue, but it does not affect a process that has a
  5680.  device open.
  5681.  
  5682.  NetCharDevControl can be used to close the communication device when other
  5683.  methods fail. An application usually closes the communication device by
  5684.  calling the DosClose function. If DosClose fails, a user with admin
  5685.  privilege or comm operator privilege can use NetCharDevControl to close the
  5686.  device.
  5687.  
  5688.  The following scenario illustrates how communication devices and queues
  5689.  work. Three communication devices are connected to a server's serial ports:
  5690.  
  5691.  
  5692.  Port                    Device
  5693.  ────────────────────────────────────────────────────────────────────────────
  5694.  COM1:                   Modem.
  5695.  COM2:                   Modem.
  5696.  COM3:                   FAX machine.
  5697.  ────────────────────────────────────────────────────────────────────────────
  5698.  
  5699.  Note that communication-device queues are not created the same way printer
  5700.  queues are created. A communication-device queue exists from the time the
  5701.  sharename is created by NetShareAdd until it is deleted by NetShareDel. In
  5702.  contrast, a printer queue exists from the time the queue is created by
  5703.  DosPrintQAdd until it is removed by DosPrintQDel, whether or not the printer
  5704.  queue is shared.
  5705.  
  5706.  After communication devices are connected to the ports, the application
  5707.  creates three communication-device queues by calling NetShareAdd three
  5708.  times:
  5709.  
  5710.  Queuename  Priority  Devicename
  5711.  ────────────────────────────────────────────────────────────────────────────
  5712.  FAXQ       5         COM3
  5713.  MODEMQ     5         COM1, COM2
  5714.  VIPMODEM   1         COM2
  5715.  ────────────────────────────────────────────────────────────────────────────
  5716.  
  5717.  Note that the COM2: port is allocated to two different queues, MODEMQ and
  5718.  VIPMODEM.
  5719.  
  5720.  The application assigns a priority to the communication-device queue by
  5721.  calling NetCharDevQSetInfo. The priority can range from 1 (highest) through
  5722.  9 (lowest). LAN Manager processes requests to queues that have high priority
  5723.  before granting requests to queues that have lower priorities. The VIPMODEM
  5724.  queue is given the highest priority, 1.
  5725.  
  5726.  The application then establishes an implicit or explicit connection to the
  5727.  shared communication-device queue. An implicit connection is established by
  5728.  calling DosOpen, which opens the device. An explicit connection is
  5729.  established by calling NetUseAdd to redirect a local or null devicename to
  5730.  the queue. An explicit connection does not open the device. For more
  5731.  information about redirecting a local devicename to a shared resource, see
  5732.  the Use category API functions.
  5733.  
  5734.  If there is more than one device in a communication-device queue, the queue
  5735.  returns the first available device. If no devices are available, the queue
  5736.  holds the request until a device becomes available. The requesting computer
  5737.  waits for the time specified by the charwait entry in the [workstation]
  5738.  section of its LANMAN.INI file. If the commu- nication device does not
  5739.  become available within that time, the DosOpen function returns the
  5740.  ERROR_BAD_NET_RESP error code.
  5741.  
  5742.  For example, if requests are made to both the MODEMQ and VIPMODEM queues
  5743.  while all communication devices are in use, and if COM2 becomes the next
  5744.  device available, COM2 is made available to the requesting application in
  5745.  the VIPMODEM queue because the VIPMODEM queue has higher priority than the
  5746.  MODEMQ queue.
  5747.  
  5748.  Once an available device is made available to the request, the application
  5749.  begins communicating with that device.
  5750.  
  5751.  When an application successfully opens a remote communication device, the
  5752.  values of the wkiX_chartime and wkiX_charcount elements of the wksta_info_X
  5753.  data structure (where X is the level of detail requested by the function)
  5754.  control how information flows over the network. Because of the following
  5755.  effects, use care when changing these values:
  5756.  
  5757.  
  5758.    ■   The wkiX_chartime and wkiX_charcount elements affect all applications
  5759.        running on the workstation.
  5760.  
  5761.    ■   Network performance can be degraded. Network efficiency, response
  5762.        time, and throughput can be adversely affected.
  5763.  
  5764.  
  5765.  For more information about the wksta_info_X data structure and wkiX_chartime
  5766.  and wkiX_charcount elements, see the Workstation category API functions and
  5767.  your LAN Manager administrator's manual(s).
  5768.  
  5769.  
  5770.  Data Structures
  5771.  
  5772.  The sLevel parameter controls the level of information provided to or
  5773.  returned from the data structures used by NetCharDevEnum, NetCharDevGetInfo,
  5774.  NetCharDevQEnum, NetCharDevQGetInfo, and NetCharDevQSetInfo.
  5775.  
  5776.  
  5777.  Communication Device Information (level 0)
  5778.  
  5779.  NetCharDevEnum and NetCharDevGetInfo use the chardev_info_0 data structure
  5780.  when the sLevel parameter is 0. The chardev_info_0 data structure has this
  5781.  format:
  5782.  
  5783.    struct chardev_info_0 {
  5784.        char  ch0_dev[DEVLEN+1];
  5785.    };
  5786.  
  5787.  where
  5788.  
  5789.  ch0_dev
  5790.    Contains an ASCIIZ string that specifies the devicename associated with
  5791.    the commu- nication device. The constant DEVLEN is defined in the
  5792.    NETCONS.H header file.
  5793.  
  5794.  
  5795.  Communication Device Information (level 1)
  5796.  
  5797.  NetCharDevEnum and NetCharDevGetInfo use the chardev_info_1 data structure
  5798.  when the sLevel parameter is 1. The chardev_info_1 data structure has this
  5799.  format:
  5800.  
  5801.    struct chardev_info_1 {
  5802.        char            ch1_dev[DEVLEN+1];
  5803.        char            ch1_pad1;
  5804.        unsigned short  ch1_status;
  5805.        char            ch1_username[UNLEN+1];
  5806.        char            ch1_pad2;
  5807.        unsigned long   ch1_time;
  5808.    };
  5809.  
  5810.  where
  5811.  
  5812.  ch1_dev
  5813.    Contains an ASCIIZ string that specifies the devicename associated with
  5814.    the communication device.
  5815.  
  5816.  ch1_pad1
  5817.    Aligns the next data structure element on a word boundary.
  5818.  
  5819.  ch1_status
  5820.    Specifies the status of the device, as follows:
  5821.  
  5822.  Bit(s)                            Meaning
  5823.  ────────────────────────────────────────────────────────────────────────────
  5824.  0                                 Reserved; must be 0.
  5825.  
  5826.  1                                 If 0, the device is idle; if 1, the
  5827.                                    device is open.
  5828.  
  5829.  2                                 If 0, the device encountered no errors;
  5830.                                    if 1, the device encountered
  5831.                                    an error.
  5832.  
  5833.  3-15                              Reserved; must be 0.
  5834.  
  5835.  ────────────────────────────────────────────────────────────────────────────
  5836.  
  5837.  
  5838.    The following bit masks are used with ch1_status. The CHARDEV.H header
  5839.    file defines these possible values:
  5840.  
  5841.  Code                 Bit Mask  Meaning
  5842.  ────────────────────────────────────────────────────────────────────────────
  5843.  CHARDEV_STAT_OPENED  0x02      The communication device is open.
  5844.  
  5845.  CHARDEV_STAT_ERROR   0x04      The communication device  encountered an
  5846.                                 error.
  5847.  
  5848.  ────────────────────────────────────────────────────────────────────────────
  5849.  
  5850.  
  5851.  ch1_username
  5852.    Contains an ASCIIZ string that specifies the name of the user currently
  5853.    using the device. The constant UNLEN is defined in the NETCONS.H header
  5854.    file.
  5855.  
  5856.  ch1_pad2
  5857.    Aligns the next data structure element on a word boundary.
  5858.  
  5859.  ch1_time
  5860.    Specifies how many seconds the current application has been connected to
  5861.    the communication device.
  5862.  
  5863.  
  5864.  Communication Device Queues Information (level 0)
  5865.  
  5866.  NetCharDevQEnum and NetCharDevQGetInfo use the chardevQ_info_0 data
  5867.  structure when the sLevel parameter is 0. The chardevQ_info_0 data structure
  5868.  has this format:
  5869.  
  5870.    struct chardevQ_info_0 {
  5871.        char  cq0_dev[NNLEN+1];
  5872.    };
  5873.  
  5874.  where
  5875.  
  5876.  cq0_dev
  5877.    Contains an ASCIIZ string that specifies the queuename. The constant NNLEN
  5878.    is defined in the NETCONS.H header file.
  5879.  
  5880.  
  5881.  Communication Device Queues Information (level 1)
  5882.  
  5883.  NetCharDevQEnum, NetCharDevQGetInfo, and NetCharDevQSetInfo use the
  5884.  chardevQ_info_1 data structure when the sLevel parameter is 1. The
  5885.  chardevQ_info_1 data structure has the following format:
  5886.  
  5887.    struct chardevQ_info_1 {
  5888.        char            cq1_dev[NNLEN+1];
  5889.        char            cq1_pad;
  5890.        unsigned short  cq1_priority;
  5891.        char far *      cq1_devs;
  5892.        unsigned short  cq1_numusers;
  5893.        unsigned short  cq1_numahead;
  5894.    };
  5895.  
  5896.  where
  5897.  
  5898.  cq1_dev
  5899.    Contains an ASCIIZ string that specifies the queuename. The constant NNLEN
  5900.    is defined in the NETCONS.H header file.
  5901.  
  5902.  cq1_pad
  5903.    Aligns the next data structure element on a word boundary.
  5904.  
  5905.  cq1_priority
  5906.    Specifies the queue priority. The value of cq1_priority can range from 1
  5907.    (highest priority) through 9 (lowest priority).
  5908.  
  5909.  cq1_devs
  5910.    Points to an ASCIIZ string that contains the devicenames assigned to the
  5911.    queue. The devicenames are separated by a space (for example, COM1 COM3).
  5912.  
  5913.  cq1_numusers
  5914.    Specifies the number of requests in the queue.
  5915.  
  5916.  cq1_numahead
  5917.    Specifies the number of requests ahead of a particular user in the queue.
  5918.    A value of CHARDEVQ_NO_REQUESTS means that the username pointed to by
  5919.    pszUserName in the call to NetCharDevQEnum has no requests in the queue.
  5920.  
  5921.  See Also
  5922.  
  5923.  For information about             See
  5924.  ────────────────────────────────────────────────────────────────────────────
  5925.  Creating a communication-device   Share Category
  5926.  queue
  5927.  
  5928.  Data structure architecture       Chapter 1, "Overview of the LAN Manager
  5929.                                    API"
  5930.  
  5931.  Setting LANMAN.INI parameters     LAN Manager administrator's manual(s)
  5932.  
  5933.  Using a communication device      Use Category
  5934.  
  5935.  
  5936.  NetCharDevControl
  5937.  ────────────────────────────────────────────────────────────────────────────
  5938.  
  5939.  NetCharDevControl changes the state of a communication device according to
  5940.  the specified operation code (opcode). The supplied opcode, CHARDEV_CLOSE,
  5941.  closes the communication device.
  5942.  
  5943.  
  5944.  Operating Systems Supported
  5945.  
  5946.  
  5947.    ■   MS OS/2 version 1.2, local and remote
  5948.  
  5949.    ■   MS OS/2 version 1.1, remote only
  5950.  
  5951.    ■   MS-DOS, remote only
  5952.  
  5953.  
  5954.  
  5955.  Privilege Level
  5956.  
  5957.  Admin privilege or comm operator privilege is required to successfully
  5958.  execute NetCharDevControl on a remote server or on a computer that has local
  5959.  security enabled.
  5960.  
  5961.  
  5962.  Syntax
  5963.  
  5964.    #define INCL_NETCHARDEV
  5965.    #define INCL_NETERRORS
  5966.    #include <lan.h>
  5967.  
  5968.    API_FUNCTION
  5969.    NetCharDevControl (const char far *  pszServer,
  5970.                       const char far *  pszDevName,
  5971.                       short             sOpCode
  5972.                      );
  5973.  
  5974.  where
  5975.  
  5976.  pszServer
  5977.    Points to an ASCIIZ string that contains the name of the server on which
  5978.    to execute NetCharDevControl. A null pointer or null string specifies the
  5979.    local computer.
  5980.  
  5981.  pszDevName
  5982.    Points to an ASCIIZ string that specifies the device to modify.
  5983.  
  5984.  sOpCode
  5985.    Specifies how to modify pszDevName. This value, defined in the CHARDEV.H
  5986.    header file, can be CHARDEV_CLOSE (0), which indicates to close the
  5987.    communication device and disconnect any current clients.
  5988.  
  5989.  Return Codes
  5990.  
  5991. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  5992.  Code                              Value   Meaning
  5993.  ────────────────────────────────────────────────────────────────────────────
  5994.  NERR_Success                      0       The function encountered no
  5995.                                            errors.
  5996.  
  5997.  ERROR_ACCESS_DENIED               5       The user has insufficient
  5998.                                            privilege for this operation.
  5999.  
  6000.  ERROR_BAD_NETPATH                 53      The network path was not found.
  6001.  
  6002.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  6003.  
  6004.  ERROR_SEM_TIMEOUT                 121     A time-out occurred from the
  6005.                                            Semaphore API functions.
  6006.  
  6007.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6008.  Code                              Value   Meaning
  6009.  ────────────────────────────────────────────────────────────────────────────
  6010. NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6011.                                            is not installed.
  6012.  
  6013.  NERR_RemoteOnly                   2106    This operation can be performed
  6014.                                            only on a server.
  6015.  
  6016.  NERR_ServerNotStarted             2114    The Server service is not
  6017.                                            started.
  6018.  
  6019.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  6020.  
  6021.  NERR_WkstaNotStarted              2138    The Workstation service is not
  6022.                                            started.
  6023.  
  6024.  NERR_BadTransactConfig            2141    The server is not configured for
  6025.                                            this transaction: IPC$ is not
  6026.                                            shared.
  6027.  
  6028.  NERR_DevInvalidOpCode             2331    The operation is invalid for
  6029.  Code                              Value   Meaning
  6030.  ────────────────────────────────────────────────────────────────────────────
  6031. NERR_DevInvalidOpCode             2331    The operation is invalid for
  6032.                                            this device.
  6033.  
  6034.  NERR_DevNotFound                  2332    This device cannot be shared.
  6035.  
  6036.  NERR_DevNotOpen                   2333    The device is not open.
  6037.  
  6038.  NERR_NoCommDevs                   2337    There are no shared
  6039.                                            communication devices.
  6040.  
  6041.  NERR_InvalidComputer              2351    The specified computername is
  6042.                                            invalid.
  6043.  
  6044.  ────────────────────────────────────────────────────────────────────────────
  6045.  
  6046.  
  6047.  
  6048.  
  6049.  Remarks
  6050.  
  6051.  A communication device is usually closed by a call to the DosClose function.
  6052.  If the process that opened the device cannot close it, NetCharDevControl can
  6053.  be called to force the device closed.
  6054.  
  6055.  See Also
  6056.  
  6057.  For information about             See
  6058.  ────────────────────────────────────────────────────────────────────────────
  6059.  Modifying a communication-device  NetCharDevQSetInfo
  6060.  queue
  6061.  
  6062.  Retrieving information about a    NetCharDevGetInfo
  6063.  communication device
  6064.  
  6065.  Retrieving information about a    NetCharDevQGetInfo
  6066.  communication-device queue
  6067.  
  6068.  
  6069.  NetCharDevEnum
  6070.  ────────────────────────────────────────────────────────────────────────────
  6071.  
  6072.  NetCharDevEnum provides information about all communication devices in
  6073.  shared communication-device queues on a server.
  6074.  
  6075.  
  6076.  Operating Systems Supported
  6077.  
  6078.  
  6079.    ■   MS OS/2 version 1.2, local and remote
  6080.  
  6081.    ■   MS OS/2 version 1.1, remote only
  6082.  
  6083.    ■   MS-DOS, remote only
  6084.  
  6085.  
  6086.  
  6087.  Privilege Level
  6088.  
  6089.  No special privilege is required to successfully execute NetCharDevEnum.
  6090.  
  6091.  
  6092.  Syntax
  6093.  
  6094.    #define INCL_NETCHARDEV
  6095.    #define INCL_NETERRORS
  6096.    #include <lan.h>
  6097.  
  6098.    API_FUNCTION
  6099.    NetCharDevEnum (const char far *      pszServer,
  6100.                    short                 sLevel,
  6101.                    char far *            pbBuffer,
  6102.                    unsigned short        cbBuffer,
  6103.                    unsigned short far *  pcEntriesRead,
  6104.                    unsigned short far *  pcTotalAvail
  6105.                   );
  6106.  
  6107.  where
  6108.  
  6109.  pszServer
  6110.    Points to an ASCIIZ string that contains the name of the server on which
  6111.    to execute NetCharDevEnum. A null pointer or null string specifies the
  6112.    local computer.
  6113.  
  6114.  sLevel
  6115.    Specifies the level of detail (0 or 1) requested for the returned
  6116.    chardev_info data structure.
  6117.  
  6118.  pbBuffer
  6119.    Points to the buffer in which to store the return data. On a successful
  6120.    return, the buffer contains a sequence of chardev_info_X data structures,
  6121.    where X is 0 or 1, depending on the level of detail requested.
  6122.  
  6123.  cbBuffer
  6124.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  6125.  
  6126.  pcEntriesRead
  6127.    Points to an unsigned short integer that specifies how many entries were
  6128.    returned. This count is valid only if NetCharDevEnum returns NERR_Success
  6129.    or ERROR_MORE_DATA.
  6130.  
  6131.  pcTotalAvail
  6132.    Points to an unsigned short integer that specifies how many entries were
  6133.    available. This count is valid only if NetCharDevEnum returns NERR_Success
  6134.    or ERROR_MORE_DATA.
  6135.  
  6136.  Return Codes
  6137.  
  6138. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  6139.  Code                              Value   Meaning
  6140.  ────────────────────────────────────────────────────────────────────────────
  6141.  NERR_Success                      0       The function encountered no
  6142.                                            errors.
  6143.  
  6144.  ERROR_ACCESS_DENIED               5       The user has insufficient
  6145.                                            privilege for this operation.
  6146.  
  6147.  ERROR_BAD_NETPATH                 53      The network path was not found.
  6148.  
  6149.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  6150.  
  6151.  ERROR_INVALID_LEVEL               124     The level for information
  6152.                                            retrieval or setting is invalid.
  6153.  
  6154.  ERROR_MORE_DATA                   234     Additional data is available.
  6155.  Code                              Value   Meaning
  6156.  ────────────────────────────────────────────────────────────────────────────
  6157. ERROR_MORE_DATA                   234     Additional data is available.
  6158.  
  6159.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6160.                                            is not installed.
  6161.  
  6162.  NERR_RemoteOnly                   2106    This operation can be performed
  6163.                                            only on a server.
  6164.  
  6165.  NERR_ServerNotStarted             2114    The Server service is not
  6166.                                            started.
  6167.  
  6168.  NERR_WkstaNotStarted              2138    The Workstation service is not
  6169.                                            started.
  6170.  
  6171.  NERR_BadTransactConfig            2141    The server is not configured for
  6172.                                            this transaction: IPC$ is not
  6173.                                            shared.
  6174.  
  6175.  NERR_NoCommDevs                   2337    There are no shared
  6176.  Code                              Value   Meaning
  6177.  ────────────────────────────────────────────────────────────────────────────
  6178. NERR_NoCommDevs                   2337    There are no shared
  6179.                                            communication devices.
  6180.  
  6181.  NERR_InvalidComputer              2351    The specified computername is
  6182.                                            invalid.
  6183.  
  6184.  ────────────────────────────────────────────────────────────────────────────
  6185.  
  6186.  
  6187.  
  6188.  See Also
  6189.  
  6190.  For information about             See
  6191.  ────────────────────────────────────────────────────────────────────────────
  6192.  Enum functions                    Chapter 1, "Overview of the LAN Manager
  6193.                                    API"
  6194.  
  6195.  Listing communication-device      NetCharDevQEnum
  6196.  queues on a server
  6197.  
  6198.  
  6199.  NetCharDevGetInfo
  6200.  ────────────────────────────────────────────────────────────────────────────
  6201.  
  6202.  NetCharDevGetInfo retrieves information about a particular communication
  6203.  device in a shared communication-device queue on a server.
  6204.  
  6205.  
  6206.  Operating Systems Supported
  6207.  
  6208.  
  6209.    ■   MS OS/2 version 1.2, local and remote
  6210.  
  6211.    ■   MS OS/2 version 1.1, remote only
  6212.  
  6213.    ■   MS-DOS, remote only
  6214.  
  6215.  
  6216.  
  6217.  Privilege Level
  6218.  
  6219.  No special privilege is required to successfully execute NetCharDevGetInfo.
  6220.  
  6221.  
  6222.  
  6223.  Syntax
  6224.  
  6225.    #define INCL_NETCHARDEV
  6226.    #define INCL_NETERRORS
  6227.    #include <lan.h>
  6228.  
  6229.    API_FUNCTION
  6230.    NetCharDevGetInfo (const char far *      pszServer,
  6231.                       const char far *      pszDevName,
  6232.                       short                 sLevel,
  6233.                       char far *            pbBuffer,
  6234.                       unsigned short        cbBuffer,
  6235.                       unsigned short far *  pcbTotalAvail
  6236.                      );
  6237.  
  6238.  where
  6239.  
  6240.  pszServer
  6241.    Points to an ASCIIZ string that contains the name of the server on which
  6242.    to execute NetCharDevGetInfo. A null pointer or null string specifies the
  6243.    local computer.
  6244.  
  6245.  pszDevName
  6246.    Points to an ASCIIZ string that contains the name of the specified
  6247.    communication device.
  6248.  
  6249.  sLevel
  6250.    Specifies the level of detail (0 or 1) to be provided in the return
  6251.    buffer.
  6252.  
  6253.  pbBuffer
  6254.    Points to the buffer in which to store the return data. On a successful
  6255.    return, the buffer contains the chardev_info_X data structure, where X is
  6256.    0 or 1, depending on the level of detail requested.
  6257.  
  6258.  cbBuffer
  6259.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  6260.  
  6261.  pcbTotalAvail
  6262.    Points to an unsigned short integer that specifies how many bytes of
  6263.    information were available. This count is valid only if NetCharDevGetInfo
  6264.    returns NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  6265.  
  6266.  Return Codes
  6267.  
  6268. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  6269.  Code                              Value   Meaning
  6270.  ────────────────────────────────────────────────────────────────────────────
  6271.  NERR_Success                      0       The function encountered no
  6272.                                            errors.
  6273.  
  6274.  ERROR_ACCESS_DENIED               5       The user has insufficient
  6275.                                            privilege for this operation.
  6276.  
  6277.  ERROR_BAD_NETPATH                 53      The network path was not found.
  6278.  
  6279.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  6280.  
  6281.  Code                              Value   Meaning
  6282.  ────────────────────────────────────────────────────────────────────────────
  6283. 
  6284.  ERROR_INVALID_LEVEL               124     The level for information
  6285.                                            retrieval or setting is invalid.
  6286.  
  6287.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6288.                                            is not installed.
  6289.  
  6290.  NERR_RemoteOnly                   2106    This operation can be performed
  6291.                                            only on a server.
  6292.  
  6293.  NERR_ServerNotStarted             2114    The Server service is not
  6294.                                            started.
  6295.  
  6296.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  6297.  
  6298.  NERR_WkstaNotStarted              2138    The Workstation service is not
  6299.                                            started.
  6300.  
  6301.  NERR_BadTransactConfig            2141    The server is not configured for
  6302.  Code                              Value   Meaning
  6303.  ────────────────────────────────────────────────────────────────────────────
  6304. NERR_BadTransactConfig            2141    The server is not configured for
  6305.                                            this transaction: IPC$ is not
  6306.                                            shared.
  6307.  
  6308.  NERR_DevNotFound                  2332    This device cannot be shared.
  6309.  
  6310.  NERR_NoCommDevs                   2337    There are no shared
  6311.                                            communication devices.
  6312.  
  6313.  NERR_InvalidComputer              2351    The specified computername is
  6314.                                            invalid.
  6315.  
  6316.  ────────────────────────────────────────────────────────────────────────────
  6317.  
  6318.  
  6319.  
  6320.  See Also
  6321.  
  6322.  For information about             See
  6323.  ────────────────────────────────────────────────────────────────────────────
  6324.  GetInfo functions                 Chapter 1, "Overview of the LAN Manager
  6325.                                    API"
  6326.  
  6327.  Listing all communication         NetCharDevEnum
  6328.  devices
  6329.  
  6330.  Modifying the state of a          NetCharDevControl
  6331.  communication device
  6332.  
  6333.  
  6334.  NetCharDevQEnum
  6335.  ────────────────────────────────────────────────────────────────────────────
  6336.  
  6337.  NetCharDevQEnum enumerates all communication-device queues on a server.
  6338.  
  6339.  
  6340.  Operating Systems Supported
  6341.  
  6342.  
  6343.    ■   MS OS/2 version 1.2, local and remote
  6344.  
  6345.    ■   MS OS/2 version 1.1, remote only
  6346.  
  6347.    ■   MS-DOS, remote only
  6348.  
  6349.  
  6350.  
  6351.  Privilege Level
  6352.  
  6353.  No special privilege is required to successfully execute NetCharDevQEnum.
  6354.  
  6355.  
  6356.  Syntax
  6357.  
  6358.    #define INCL_NETCHARDEV
  6359.    #define INCL_NETERRORS
  6360.    #include <lan.h>
  6361.  
  6362.    API_FUNCTION
  6363.    NetCharDevQEnum (const char far *      pszServer,
  6364.                     const char far *      pszUserName,
  6365.                     short                 sLevel,
  6366.                     char far *            pbBuffer,
  6367.                     unsigned short        cbBuffer,
  6368.                     unsigned short far *  pcEntriesRead,
  6369.                     unsigned short far *  pcTotalAvail
  6370.                    );
  6371.  
  6372.  where
  6373.  
  6374.  pszServer
  6375.    Points to an ASCIIZ string that contains the name of the server on which
  6376.    to execute NetCharDevQEnum. A null pointer or null string specifies the
  6377.    local computer.
  6378.  
  6379.  pszUserName
  6380.    Points to an ASCIIZ string that contains the name of a user. When level 1
  6381.    is specified, the cq1_numahead element of the chardevQ_info_1 data
  6382.    structure represents the number of requests ahead of the request submitted
  6383.    by this user.
  6384.  
  6385.  sLevel
  6386.    Specifies the level of detail (0 or 1) to be returned in the buffer
  6387.    pointed to by pbBuffer.
  6388.  
  6389.  pbBuffer
  6390.    Points to the buffer in which to store the return data. On a successful
  6391.    return, the buffer contains a sequence of chardevQ_info_X data structures,
  6392.    where X is 0 or 1, depending on the level of detail requested.
  6393.  
  6394.  cbBuffer
  6395.    Specifies the size (in bytes) of the return buffer pointed to by pbBuffer.
  6396.  
  6397.  pcEntriesRead
  6398.    Points to an unsigned short integer that specifies how many entries were
  6399.    returned. This count is valid only if NetCharDevQEnum returns NERR_Success
  6400.    or ERROR_MORE_DATA.
  6401.  
  6402.  pcTotalAvail
  6403.    Points to an unsigned short integer that specifies how many entries were
  6404.    available. This count is valid only if NetCharDevQEnum returns
  6405.    NERR_Success or ERROR_MORE_DATA.
  6406.  
  6407.  Return Codes
  6408.  
  6409. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  6410.  Code                              Value   Meaning
  6411.  ────────────────────────────────────────────────────────────────────────────
  6412.  NERR_Success                      0       The function encountered no
  6413.                                            errors.
  6414.  
  6415.  ERROR_ACCESS_DENIED               5       The user has insufficient
  6416.                                            privilege for this operation.
  6417.  
  6418.  ERROR_BAD_NETPATH                 53      The network path was not found.
  6419.  
  6420.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  6421.  
  6422.  ERROR_INVALID_LEVEL               124     The level for information
  6423.                                            retrieval or setting is invalid.
  6424.  
  6425.  ERROR_MORE_DATA                   234     Additional data is available.
  6426.  
  6427.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6428.  Code                              Value   Meaning
  6429.  ────────────────────────────────────────────────────────────────────────────
  6430. NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6431.                                            is not installed.
  6432.  
  6433.  NERR_RemoteOnly                   2106    This operation can be performed
  6434.                                            only on a server.
  6435.  
  6436.  NERR_ServerNotStarted             2114    The Server service is not
  6437.                                            started.
  6438.  
  6439.  NERR_WkstaNotStarted              2138    The Workstation service is not
  6440.                                            started.
  6441.  
  6442.  NERR_BadTransactConfig            2141    The server is not configured for
  6443.                                            this transaction: IPC$ is not
  6444.                                            shared.
  6445.  
  6446.  NERR_NoCommDevs                   2337    There are no shared
  6447.                                            communication devices.
  6448.  
  6449.  Code                              Value   Meaning
  6450.  ────────────────────────────────────────────────────────────────────────────
  6451. 
  6452.  NERR_InvalidComputer              2351    The specified computername is
  6453.                                            invalid.
  6454.  
  6455.  ────────────────────────────────────────────────────────────────────────────
  6456.  
  6457.  
  6458.  
  6459.  See Also
  6460.  
  6461.  For information about             See
  6462.  ────────────────────────────────────────────────────────────────────────────
  6463.  Enum functions                    Chapter 1, "Overview of the LAN Manager
  6464.                                    API"
  6465.  
  6466.  Listing all communication         NetCharDevEnum
  6467.  devices associated with
  6468.  communicationdevice queues on a
  6469.  server
  6470.  
  6471.  Retrieving information about a    NetCharDevQGetInfo
  6472.  specific communication-device
  6473.  queue
  6474.  
  6475.  
  6476.  NetCharDevQGetInfo
  6477.  ────────────────────────────────────────────────────────────────────────────
  6478.  
  6479.  NetCharDevQGetInfo retrieves information about a particular
  6480.  communication-device queue on a server.
  6481.  
  6482.  
  6483.  Operating Systems Supported
  6484.  
  6485.  
  6486.    ■   MS OS/2 version 1.2, local and remote
  6487.  
  6488.    ■   MS OS/2 version 1.1, remote only
  6489.  
  6490.    ■   MS-DOS, remote only
  6491.  
  6492.  
  6493.  
  6494.  Privilege Level
  6495.  
  6496.  No special privilege is required to successfully execute NetCharDevQGetInfo.
  6497.  
  6498.  
  6499.  
  6500.  Syntax
  6501.  
  6502.    #define INCL_NETCHARDEV
  6503.    #define INCL_NETERRORS
  6504.    #include <lan.h>
  6505.  
  6506.    API_FUNCTION
  6507.    NetCharDevQGetInfo (const char far *      pszServer,
  6508.                        const char far *      pszQueueName,
  6509.                        const char far *      pszUserName,
  6510.                        short                 sLevel,
  6511.                        char far *            pbBuffer,
  6512.                        unsigned short        cbBuffer,
  6513.                        unsigned short far *  pcbTotalAvail
  6514.                       );
  6515.  
  6516.  where
  6517.  
  6518.  pszServer
  6519.    Points to an ASCIIZ string that contains the name of the server on which
  6520.    to execute NetCharDevQGetInfo. A null pointer or null string specifies the
  6521.    local computer.
  6522.  
  6523.  pszQueueName
  6524.    Points to an ASCIIZ string that contains the name of the
  6525.    communication-device queue about which information is requested.
  6526.  
  6527.  pszUserName
  6528.    Points to an ASCIIZ string that contains the name of a user. The
  6529.    cq1_numahead element in the returned chardevQ_info_1 data structure
  6530.    represents the number of requests in the queue ahead of the request
  6531.    submitted by this user.
  6532.  
  6533.  sLevel
  6534.    Specifies the level of detail (0 or 1) to be provided in the return
  6535.    buffer.
  6536.  
  6537.  pbBuffer
  6538.    Points to the buffer in which to store return data. On a successful
  6539.    return, the buffer  contains the chardevQ_info_X data structure, where X
  6540.    is 0 or 1, depending on the level of detail specified.
  6541.  
  6542.  cbBuffer
  6543.    Specifies the size (in bytes) of the return buffer pointed to by pbBuffer.
  6544.  
  6545.  pcbTotalAvail
  6546.    Points to an unsigned short integer that specifies how many bytes of
  6547.    information were available. This count is valid only if NetCharDevQGetInfo
  6548.    returns NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  6549.  
  6550.  Return Codes
  6551.  
  6552. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  6553.  Code                              Value   Meaning
  6554.  Code                              Value   Meaning
  6555.  ────────────────────────────────────────────────────────────────────────────
  6556.  NERR_Success                      0       The function encountered no
  6557.                                            errors.
  6558.  
  6559.  ERROR_ACCESS_DENIED               5       The user has insufficient
  6560.                                            privilege for this operation.
  6561.  
  6562.  ERROR_BAD_NETPATH                 53      The network path was not found.
  6563.  
  6564.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  6565.  
  6566.  ERROR_INVALID_NAME                123     The character or file system
  6567.                                            name is invalid.
  6568.  
  6569.  ERROR_INVALID_LEVEL               124     The level for information
  6570.                                            retrieval or setting is invalid.
  6571.  
  6572.  ERROR_MORE_DATA                   234     Additional data is available.
  6573.  
  6574.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6575.  Code                              Value   Meaning
  6576.  ────────────────────────────────────────────────────────────────────────────
  6577. NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6578.                                            is not installed.
  6579.  
  6580.  NERR_RemoteOnly                   2106    This operation can be performed
  6581.                                            only on a server.
  6582.  
  6583.  NERR_ServerNotStarted             2114    The Server service is not
  6584.                                            started.
  6585.  
  6586.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  6587.  
  6588.  NERR_WkstaNotStarted              2138    The Workstation service is not
  6589.                                            started.
  6590.  
  6591.  NERR_BadTransactConfig            2141    The server is not configured for
  6592.                                            this transaction: IPC$ is not
  6593.                                            shared.
  6594.  
  6595.  NERR_BadUsername                  2202    The username or groupname is
  6596.  Code                              Value   Meaning
  6597.  ────────────────────────────────────────────────────────────────────────────
  6598. NERR_BadUsername                  2202    The username or groupname is
  6599.                                            invalid.
  6600.  
  6601.  NERR_NoCommDevs                   2337    There are no shared
  6602.                                            communication devices.
  6603.  
  6604.  NERR_QueueNotFound                2338    The sharename does not exist.
  6605.  
  6606.  NERR_InvalidComputer              2351    The specified computername is
  6607.                                            invalid.
  6608.  
  6609.  ────────────────────────────────────────────────────────────────────────────
  6610.  
  6611.  
  6612.  
  6613.  See Also
  6614.  
  6615.  For information about             See
  6616.  ────────────────────────────────────────────────────────────────────────────
  6617.  GetInfo functions                 Chapter 1, "Overview of the LAN Manager
  6618.                                    API"
  6619.  
  6620.  Listing all communication-device  NetCharDevQEnum
  6621.  queues on a server
  6622.  
  6623.  Modifying the state of a          NetCharDevQSetInfo
  6624.  communication-device queue
  6625.  
  6626.  
  6627.  NetCharDevQPurge
  6628.  ────────────────────────────────────────────────────────────────────────────
  6629.  
  6630.  NetCharDevQPurge deletes all pending requests in a communication-device
  6631.  queue.
  6632.  
  6633.  
  6634.  Operating Systems Supported
  6635.  
  6636.  
  6637.    ■   MS OS/2 version 1.2, local and remote
  6638.  
  6639.    ■   MS OS/2 version 1.1, remote only
  6640.  
  6641.    ■   MS-DOS, remote only
  6642.  
  6643.  
  6644.  
  6645.  Privilege Level
  6646.  
  6647.  Admin privilege or comm operator privilege is required to successfully
  6648.  execute NetCharDevQPurge on a remote server or on a computer that has local
  6649.  security enabled.
  6650.  
  6651.  
  6652.  Syntax
  6653.  
  6654.    #define INCL_NETCHARDEV
  6655.    #define INCL_NETERRORS
  6656.    #include <lan.h>
  6657.  
  6658.    API_FUNCTION
  6659.    NetCharDevQPurge (const char far *  pszServer,
  6660.                      const char far *  pszQueueName
  6661.                     );
  6662.  
  6663.  where
  6664.  
  6665.  pszServer
  6666.    Points to an ASCIIZ string that contains the name of the server on which
  6667.    to execute NetCharDevQPurge. A null pointer or null string specifies the
  6668.    local computer.
  6669.  
  6670.  pszQueueName
  6671.    Points to an ASCIIZ string that contains the name of the queue from which
  6672.    to purge pending requests.
  6673.  
  6674.  Return Codes
  6675.  
  6676. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  6677.  Code                              Value   Meaning
  6678.  ────────────────────────────────────────────────────────────────────────────
  6679.  NERR_Success                      0       The function encountered no
  6680.  Code                              Value   Meaning
  6681.  ────────────────────────────────────────────────────────────────────────────
  6682.  NERR_Success                      0       The function encountered no
  6683.                                            errors.
  6684.  
  6685.  ERROR_ACCESS_DENIED               5       The user has insufficient
  6686.                                            privilege for this operation.
  6687.  
  6688.  ERROR_BAD_NETPATH                 53      The network path was not found.
  6689.  
  6690.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  6691.  
  6692.  ERROR_SEM_TIMEOUT                 121     A time-out occurred from the
  6693.                                            Semaphore API functions.
  6694.  
  6695.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6696.                                            is not installed.
  6697.  
  6698.  NERR_RemoteOnly                   2106    This operation can be performed
  6699.                                            only on a server.
  6700.  
  6701.  Code                              Value   Meaning
  6702.  ────────────────────────────────────────────────────────────────────────────
  6703. 
  6704.  NERR_ServerNotStarted             2114    The Server service is not
  6705.                                            started.
  6706.  
  6707.  NERR_WkstaNotStarted              2138    The Workstation service is not
  6708.                                            started.
  6709.  
  6710.  NERR_BadTransactConfig            2141    The server is not configured for
  6711.                                            this transaction: IPC$ is not
  6712.                                            shared.
  6713.  
  6714.  NERR_NoCommDevs                   2337    There are no shared
  6715.                                            communication devices.
  6716.  
  6717.  NERR_QueueNotFound                2338    The sharename does not exist.
  6718.  
  6719.  NERR_InvalidComputer              2351    The specified computername is
  6720.                                            invalid.
  6721.  
  6722.  Code                              Value   Meaning
  6723.  ────────────────────────────────────────────────────────────────────────────
  6724. 
  6725.  ────────────────────────────────────────────────────────────────────────────
  6726.  
  6727.  
  6728.  
  6729.  
  6730.  Remarks
  6731.  
  6732.  NetCharDevQPurge deletes only requests that have not yet been assigned to a
  6733.  device. It does not affect a process that currently has a device open. All
  6734.  pending requests in the queue pointed to by pszQueueName are canceled, and
  6735.  ERROR_BAD_NET_RESP is returned for each call to the DosOpen function. All
  6736.  handles remain valid.
  6737.  
  6738.  See Also
  6739.  
  6740.  For information about             See
  6741.  ────────────────────────────────────────────────────────────────────────────
  6742.  Closing the current session of a  NetCharDevControl
  6743.  communication device
  6744.  
  6745.  Deleting the                      NetCharDevQPurgeSelf
  6746.  communication-device queue
  6747.  requests made by the specified
  6748.  computer
  6749.  
  6750.  Listing the communication-device  NetCharDevQEnum
  6751.  queues on a server
  6752.  
  6753.  
  6754.  NetCharDevQPurgeSelf
  6755.  ────────────────────────────────────────────────────────────────────────────
  6756.  
  6757.  NetCharDevQPurgeSelf deletes all pending requests submitted by a particular
  6758.  computer in a communication-device queue.
  6759.  
  6760.  
  6761.  Operating Systems Supported
  6762.  
  6763.  
  6764.    ■   MS OS/2 version 1.2, local and remote
  6765.  
  6766.    ■   MS OS/2 version 1.1, remote only
  6767.  
  6768.    ■   MS-DOS, remote only
  6769.  
  6770.  
  6771.  
  6772.  Privilege Level
  6773.  
  6774.  Admin privilege or comm operator privilege is required to successfully
  6775.  execute NetCharDevQPurgeSelf on a remote server or on a computer that has
  6776.  local security enabled.
  6777.  
  6778.  
  6779.  Syntax
  6780.  
  6781.    #define INCL_NETCHARDEV
  6782.    #define INCL_NETERRORS
  6783.    #include <lan.h>
  6784.  
  6785.    API_FUNCTION
  6786.    NetCharDevQPurgeSelf (const char far *  pszServer,
  6787.                          const char far *  pszQueueName,
  6788.                          const char far *  pszComputerName
  6789.                         );
  6790.  
  6791.  where
  6792.  
  6793.  pszServer
  6794.    Points to an ASCIIZ string that contains the name of the server on which
  6795.    to execute NetCharDevQPurgeSelf. A null pointer or null string specifies
  6796.    the local computer.
  6797.  
  6798.  pszQueueName
  6799.    Points to an ASCIIZ string that contains the name of the queue from which
  6800.    to purge requests.
  6801.  
  6802.  pszComputerName
  6803.    Points to an ASCIIZ string that contains the name of the computer whose
  6804.    requests are to be deleted from the queue specified by pszQueueName.
  6805.  
  6806.  Return Codes
  6807.  
  6808. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  6809.  Code                              Value   Meaning
  6810.  ────────────────────────────────────────────────────────────────────────────
  6811.  NERR_Success                      0       The function encountered no
  6812.                                            errors.
  6813.  
  6814.  ERROR_ACCESS_DENIED               5       The user has insufficient
  6815.                                            privilege for this operation.
  6816.  
  6817.  ERROR_BAD_NETPATH                 53      The network path was not found.
  6818.  
  6819.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  6820.  
  6821.  ERROR_SEM_TIMEOUT                 121     A time-out occurred from the
  6822.                                            Semaphore API functions.
  6823.  
  6824.  ERROR_INVALID_NAME                123     The character or file system
  6825.                                            name is invalid.
  6826.  
  6827.  Code                              Value   Meaning
  6828.  ────────────────────────────────────────────────────────────────────────────
  6829. 
  6830.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6831.                                            is not installed.
  6832.  
  6833.  NERR_RemoteOnly                   2106    This operation can be performed
  6834.                                            only on a server.
  6835.  
  6836.  NERR_ServerNotStarted             2114    The Server service is not
  6837.                                            started.
  6838.  
  6839.  NERR_ItemNotFound                 2115    The queue is empty.
  6840.  
  6841.  NERR_WkstaNotStarted              2138    The Workstation service is not
  6842.                                            started.
  6843.  
  6844.  NERR_BadTransactConfig            2141    The server is not configured for
  6845.                                            this transaction: IPC$ is not
  6846.                                            shared.
  6847.  
  6848.  Code                              Value   Meaning
  6849.  ────────────────────────────────────────────────────────────────────────────
  6850. 
  6851.  NERR_NoCommDevs                   2337    There are no shared
  6852.                                            communication devices.
  6853.  
  6854.  NERR_QueueNotFound                2338    The sharename does not exist.
  6855.  
  6856.  NERR_InvalidComputer              2351    The specified computername is
  6857.                                            invalid.
  6858.  
  6859.  ────────────────────────────────────────────────────────────────────────────
  6860.  
  6861.  
  6862.  
  6863.  
  6864.  Remarks
  6865.  
  6866.  NetCharDevQPurgeSelf is similar to NetCharDevQPurge, except that it deletes
  6867.  only requests made from the computer specified by pszComputerName. A process
  6868.  that has a device open is unaffected.
  6869.  
  6870.  See Also
  6871.  
  6872.  For information about             See
  6873.  ────────────────────────────────────────────────────────────────────────────
  6874.  Deleting the contents of a        NetCharDevQPurge
  6875.  communication-device queue
  6876.  
  6877.  Listing communication-device      NetCharDevQEnum
  6878.  queues on a server
  6879.  
  6880.  Modifying the state of a          NetCharDevQSetInfo
  6881.  communication-device queue
  6882.  
  6883.  
  6884.  NetCharDevQSetInfo
  6885.  ────────────────────────────────────────────────────────────────────────────
  6886.  
  6887.  NetCharDevQSetInfo modifies the settable fields of a specified
  6888.  communication-device queue on a server.
  6889.  
  6890.  
  6891.  Operating Systems Supported
  6892.  
  6893.  
  6894.    ■   MS OS/2 version 1.2, local and remote
  6895.  
  6896.    ■   MS OS/2 version 1.1, remote only
  6897.  
  6898.    ■   MS-DOS, remote only
  6899.  
  6900.  
  6901.  
  6902.  Privilege Level
  6903.  
  6904.  Admin privilege or comm operator privilege is required to successfully
  6905.  execute NetCharDevQSetInfo on a remote server or on a computer that has
  6906.  local security enabled.
  6907.  
  6908.  
  6909.  Syntax
  6910.  
  6911.    #define INCL_NETCHARDEV
  6912.    #define INCL_NETERRORS
  6913.    #include <lan.h>
  6914.  
  6915.    API_FUNCTION
  6916.    NetCharDevQSetInfo (const char far *  pszServer,
  6917.                        const char far *  pszQueueName,
  6918.                        short             sLevel,
  6919.                        char far *        pbBuffer,
  6920.                        unsigned short    cbBuffer,
  6921.                        short             sParmNum
  6922.                       );
  6923.  
  6924.  where
  6925.  
  6926.  pszServer
  6927.    Points to an ASCIIZ string that contains the name of the server on which
  6928.    to execute NetCharDevQSetInfo. A null pointer or null string specifies the
  6929.    local computer.
  6930.  
  6931.  pszQueueName
  6932.    Points to an ASCIIZ string that contains the name of the
  6933.    communication-device queue to set.
  6934.  
  6935.  sLevel
  6936.    Specifies the level of detail; must be 1.
  6937.  
  6938.  pbBuffer
  6939.    Points to the buffer that contains the data to set. The buffer contains
  6940.    the entire chardevQ_info_1 data structure or an individual record as
  6941.    specified by sParmNum.
  6942.  
  6943.  cbBuffer
  6944.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  6945.  
  6946.  sParmNum
  6947.    Specifies whether to set one or all elements of the chardevQ_info_1 data
  6948.    structure. If sParmNum is PARMNUM_ALL, all elements are to be set, and
  6949.    pbBuffer must point to a chardevQ_info_1 data structure. If sParmNum is
  6950.    any other defined value, only one element is to be set, and pbBuffer must
  6951.    point to that element.
  6952.  
  6953.    Not all elements can be set. Only those elements that have a specific
  6954.    PARMNUM constant value defined can be set. The CHARDEV.H and NETCONS.H
  6955.    header files define these possible values for sParmNum:
  6956.  
  6957.  Code                       Value  Element of chardevQ_info_1
  6958.  ────────────────────────────────────────────────────────────────────────────
  6959.  PARMNUM_ALL                0      All elements.
  6960.  CHARDEVQ_PRIORITY_PARMNUM  2      cq1_priority
  6961.  CHARDEVQ_DEVICES_PARMNUM   3      cq1_devs
  6962.  ────────────────────────────────────────────────────────────────────────────
  6963.  
  6964.  Return Codes
  6965.  
  6966. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  6967.  Code                              Value   Meaning
  6968.  ────────────────────────────────────────────────────────────────────────────
  6969.  NERR_Success                      0       The function encountered no
  6970.                                            errors.
  6971.  
  6972.  ERROR_ACCESS_DENIED               5       The user has insufficient
  6973.                                            privilege for this operation.
  6974.  Code                              Value   Meaning
  6975.  ────────────────────────────────────────────────────────────────────────────
  6976.                                           privilege for this operation.
  6977.  
  6978.  ERROR_BAD_NETPATH                 53      The network path was not found.
  6979.  
  6980.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  6981.  
  6982.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  6983.                                            invalid.
  6984.  
  6985.  ERROR_SEM_TIMEOUT                 121     A time-out occurred from the
  6986.                                            Semaphore API functions.
  6987.  
  6988.  ERROR_INVALID_LEVEL               124     The level for information
  6989.                                            retrieval or setting is invalid.
  6990.  
  6991.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  6992.                                            is not installed.
  6993.  
  6994.  NERR_RemoteOnly                   2106    This operation can be performed
  6995.  Code                              Value   Meaning
  6996.  ────────────────────────────────────────────────────────────────────────────
  6997. NERR_RemoteOnly                   2106    This operation can be performed
  6998.                                            only on a server.
  6999.  
  7000.  NERR_ServerNotStarted             2114    The Server service is not
  7001.                                            started.
  7002.  
  7003.  NERR_RedirectedPath               2117    The operation is invalid for a
  7004.                                            redirected resource. The
  7005.                                            devicename specified is assigned
  7006.                                            to a shared resource.
  7007.  
  7008.  NERR_NoRoom                       2119    The server could not access
  7009.                                            enough of a resource, such as
  7010.                                            memory, to complete the task.
  7011.  
  7012.  NERR_WkstaNotStarted              2138    The Workstation service is not
  7013.                                            started.
  7014.  
  7015.  NERR_BadTransactConfig            2141    The server is not configured for
  7016.  Code                              Value   Meaning
  7017.  ────────────────────────────────────────────────────────────────────────────
  7018. NERR_BadTransactConfig            2141    The server is not configured for
  7019.                                            this transaction: IPC$ is not
  7020.                                            shared.
  7021.  
  7022.  NERR_UseNotFound                  2250    This network connection does not
  7023.                                            exist.
  7024.  
  7025.  NERR_BadQueuePriority             2335    The queue priority is invalid.
  7026.  
  7027.  NERR_NoCommDevs                   2337    There are no shared
  7028.                                            communication devices.
  7029.  
  7030.  NERR_QueueNotFound                2338    The sharename does not exist.
  7031.  
  7032.  NERR_BadDevString                 2340    The list of devices is invalid.
  7033.  
  7034.  NERR_BadDev                       2341    The devicename is invalid
  7035.                                            because it does not represent a
  7036.                                            physical device, or because the
  7037.  Code                              Value   Meaning
  7038.  ────────────────────────────────────────────────────────────────────────────
  7039.                                           physical device, or because the
  7040.                                            device hardware is faulty.
  7041.  
  7042.  NERR_InUseBySpooler               2342    The device is already used with
  7043.                                            a printer queue. It cannot be
  7044.                                            used
  7045.                                            with both printer queues and
  7046.                                            communication-device queues.
  7047.  
  7048.  NERR_InvalidComputer              2351    The specified computername is
  7049.                                            invalid.
  7050.  
  7051.  ────────────────────────────────────────────────────────────────────────────
  7052.  
  7053.  
  7054.  
  7055.  See Also
  7056.  
  7057.  For information about             See
  7058.  ────────────────────────────────────────────────────────────────────────────
  7059.  Listing all communication-device  NetCharDevQEnum
  7060.  queues on a server
  7061.  
  7062.  Remote calls                      Chapter 1, "Overview of the LAN Manager
  7063.                                    API"
  7064.  
  7065.  Retrieving information about a    NetCharDevQGetInfo
  7066.  specific communication-device
  7067.  queue on a server
  7068.  
  7069.  SetInfo functions                 Chapter 1, "Overview of the LAN Manager
  7070.                                    API"
  7071.  
  7072.  
  7073.  
  7074.  
  7075.  
  7076.  Character Device Category Example
  7077.  
  7078.    /*
  7079.       NETCHAR1.C -- a sample program demonstrating NetCharDev API functions.
  7080.  
  7081.       This program requires that you have admin privilege or comm operator
  7082.       privilege on the specified server.
  7083.  
  7084.          usage:  netchar1 [-s \\server] [-d device] [-q queue]
  7085.                           [-u user] [-w wksta] [-p priority]
  7086.          where  \\server = Name of the server. A servername must be preceded
  7087.                            by two backslashes (\\).
  7088.                 device   = Actual physical devicename.
  7089.                 queue    = Shared communication-device queue.
  7090.                 user     = Name of logged-on user.
  7091.                 wksta    = Workstation name.
  7092.                 priority = Queue priority (1 through 9).
  7093.  
  7094.       This program spawns the child process netchar2.exe.
  7095.  
  7096.       API                      Used to...
  7097.       ====================     ==========================================
  7098.       NetCharDevQPurge         Remove all inactive jobs from a queue
  7099.       NetCharDevControl        Close a communication device
  7100.       NetCharDevQPurgeSelf     Remove own inactive jobs from a queue
  7101.       NetCharDevQGetInfo       Get information about a particular queue
  7102.       NetCharDevQSetInfo       Set priority level, comm devices for queue
  7103.       NetCharDevQEnum          Get information about all device queues
  7104.       NetCharDevEnum           Get information about all devices
  7105.       NetCharDevGetInfo        Get information about a particular device
  7106.  
  7107.       This code sample is provided for demonstration purposes only.
  7108.       Microsoft makes no warranty, either express or implied,
  7109.       as to its usability in any given situation.
  7110.    */
  7111.  
  7112.    #define     INCL_BASE
  7113.    #include    <os2.h>        // MS OS/2 base header files
  7114.  
  7115.    #define     INCL_NETCHARDEV
  7116.    #define     INCL_NETERRORS
  7117.    #define     INCL_NETWKSTA
  7118.    #include    <lan.h>        // LAN Manager header files
  7119.  
  7120.    #include    <stdio.h>      // C run-time header files
  7121.    #include    <stdlib.h>
  7122.    #include    <ctype.h>
  7123.    #include    <conio.h>
  7124.    #include    <string.h>
  7125.    #include    <process.h>
  7126.  
  7127.    #include    "samples.h"    // Internal routine header file
  7128.  
  7129.    /*
  7130.     * List max. size of buffer for each character-device queue.
  7131.     * Note: In this program there is only one device attached.
  7132.     */
  7133.  
  7134.    #define MAX_CHARDEVQ_INFO_1 (sizeof(struct chardevQ_info_1) + DEVLEN
  7135.    + 1)
  7136.  
  7137.    #define  SEMAPHORE            "\\sem\\chardev"
  7138.    #define  CHILD_PROCESS        "netchar2.exe"
  7139.  
  7140.    #define  START_JOB            '0'
  7141.    #define  STATUS_DEVICE        '1'
  7142.    #define  LIST_DEVICES         '2'
  7143.    #define  ENUM_QUEUES          '3'
  7144.    #define  VIEW_PRIORITY        '4'
  7145.    #define  CHANGE_PRIORITY      '5'
  7146.    #define  KILL_ACTIVE_JOB      '6'
  7147.    #define  PURGE_OWN_JOBS       '7'
  7148.    #define  PURGE_QUEUE          '8'
  7149.    #define  EXIT                 '9'
  7150.  
  7151.    #define STACK_SIZE             4096
  7152.  
  7153.    // Function prototypes
  7154.    BOOL GetDeviceInfo (char *, char *);
  7155.    BOOL EnumerateQueues (char *, char far *);
  7156.    BOOL EnumerateDevices (char *);
  7157.    BOOL ViewPriority (char *, char * , char far *);
  7158.    BOOL ChangePriority (char *, char * , unsigned short);
  7159.    BOOL OpenPort (HSYSSEM, char *, char *);
  7160.    BOOL StopInactiveJobs (char *, char *, char far *);
  7161.    void DisplayPrompt (void);
  7162.    char GetNextAction (void);
  7163.    char far * FarStrcpy (char far *, char far *);
  7164.  
  7165.    void Usage(char *pszString);
  7166.  
  7167.    void main(int argc, char *argv[])
  7168.    {
  7169.       char *pszDevice = "COM1";       // Default comm device
  7170.       char *pszQueue = "COMQUEUE";    // Default comm-queue name
  7171.       char *pszServer = "";           // Default to local computer
  7172.       char far *pszUser = "";         // far * from NetWkstaGetInfo call
  7173.       char far *pszWksta = "";        // far * from NetWkstaGetInfo call
  7174.       char chAction;                  // Menu selection
  7175.       char pszShare[RMLEN+1];         // Server, queuename for semaphore
  7176.       HSYSSEM hssmClose;              // Handle to system semaphore
  7177.       USHORT cbBuflen;                // Size of buffer
  7178.       int    iCount;                  // Index counter
  7179.       USHORT usPriority = 1;          // Priority assigned to queue
  7180.       USHORT cbTotalAvail;            // Value for NetWkstaGetInfo call
  7181.       USHORT usRet;                   // MS OS/2 return code
  7182.       unsigned uRet;                  // LAN Manager return code
  7183.       struct wksta_info_10 *pBuf;     // Pointer to return buffer
  7184.  
  7185.       for (iCount = 1; iCount < argc; iCount++)
  7186.       {
  7187.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  7188.          {
  7189.             switch (tolower(*(argv[iCount]+1))) // Process switches
  7190.             {
  7191.                case 's':                        // -s servername
  7192.                   pszServer = argv[++iCount];
  7193.                   break;
  7194.                case 'q':                        // -q queuename
  7195.                   pszQueue = argv[++iCount];
  7196.                   break;
  7197.                case 'u':                        // -u username
  7198.                   pszUser = (char far *)argv[++iCount];
  7199.                   break;
  7200.                case 'd':                        // -d devicename
  7201.                   pszDevice = argv[++iCount];
  7202.                   break;
  7203.                case 'w':                        // -w workstation
  7204.                   pszWksta = (char far *)argv[++iCount];
  7205.                   break;
  7206.                case 'p':                        // -p priority
  7207.                   usPriority = atoi(argv[++iCount]);
  7208.                   break;
  7209.  
  7210.  
  7211.  
  7212.  
  7213.                case 'h':
  7214.                default:
  7215.                   Usage(argv[0]);
  7216.             }
  7217.          }
  7218.          else
  7219.             Usage(argv[0]);
  7220.       } // End for loop
  7221.  
  7222.       if ((pszServer == NULL) || (*pszServer == '\0') ||
  7223.           (pszUser   == NULL) || (*pszUser   == '\0') ||
  7224.           (pszWksta  == NULL) || (*pszWksta  == '\0')  )
  7225.       {
  7226.          uRet = NetWkstaGetInfo(pszServer,   // Servername
  7227.                          10,                 // Level
  7228.                          NULL,               // Return buffer
  7229.                          0,                  // Size of buffer
  7230.                          &cbTotalAvail);     // Count of bytes available
  7231.          if ((uRet != NERR_BufTooSmall) && (uRet != ERROR_MORE_DATA))
  7232.          {
  7233.             printf("NetWkstaGetInfo returned %u\n", uRet);
  7234.             exit(1);
  7235.          }
  7236.          pBuf = (struct wksta_info_10 *) SafeMalloc(cbBuflen);
  7237.          uRet = NetWkstaGetInfo(pszServer,   // Servername
  7238.                          10,                 // Level
  7239.                          (char far *) pBuf,  // Return buffer
  7240.                          cbBuflen,           // Size of buffer
  7241.                          &cbTotalAvail);     // Count of bytes available
  7242.          if (uRet != NERR_Success)
  7243.          {
  7244.             printf("NetWkstaGetInfo returned %u\n", uRet);
  7245.             exit(1);
  7246.          }
  7247.       }
  7248.       if ((pszServer != NULL) && (*pszServer != '\0')) // Set up for
  7249.    semaphore
  7250.          strcpy (pszShare, pszServer);
  7251.       else
  7252.       {
  7253.          strcpy (pszShare, "\\\\");          //Insert leading backslashes
  7254.          FarStrcat((char far *)pszShare, pBuf->wki10_computername);
  7255.       }
  7256.       strcat (pszShare, "\\" );
  7257.       strcat (pszShare, pszQueue);
  7258.       if ((pszUser == NULL) || (*pszUser == '\0'))
  7259.          pszUser = pBuf->wki10_username;
  7260.       if ((pszWksta == NULL) || (*pszWksta == '\0'))
  7261.          pszWksta = pBuf->wki10_computername;
  7262.       // Create the semaphore that will be used to stop the active job.
  7263.       if ( (usRet = DosCreateSem (CSEM_PUBLIC, &hssmClose, SEMAPHORE
  7264.    )) != 0)
  7265.       {
  7266.          printf ("DosCreateSem returned %hu\n", usRet);
  7267.          exit(1);
  7268.       }
  7269.       while (TRUE)
  7270.       {
  7271.          DisplayPrompt();
  7272.          chAction = GetNextAction ();
  7273.          printf("\n");
  7274.          switch (chAction)
  7275.          {
  7276.             // Open the com port.
  7277.             case START_JOB:
  7278.                OpenPort (hssmClose, pszShare, SEMAPHORE);
  7279.                continue;
  7280.  
  7281.             // Close (has no effect if there is no active job).
  7282.             case PURGE_QUEUE:
  7283.                uRet = NetCharDevQPurge(pszServer, pszQueue);
  7284.                printf("NetCharDevQPurge returned %u\n", uRet);
  7285.                continue;
  7286.  
  7287.             //Kill the active job.
  7288.             case KILL_ACTIVE_JOB:
  7289.                uRet = NetCharDevControl(pszServer,
  7290.                                          pszDevice,
  7291.                                          CHARDEV_CLOSE);
  7292.                printf("NetCharDevControl returned %u\n", uRet);
  7293.                usRet = DosSemClear(hssmClose);
  7294.                printf("DosSemClear returned %hu\n", usRet);
  7295.                continue;
  7296.  
  7297.             // NetCharDevQPurgeSelf
  7298.             case PURGE_OWN_JOBS:
  7299.                StopInactiveJobs(pszServer, pszQueue, pszWksta);
  7300.                continue;
  7301.  
  7302.             // NetCharDevQGetInfo
  7303.             case VIEW_PRIORITY:
  7304.                ViewPriority (pszServer, pszQueue, pszUser);
  7305.                continue;
  7306.  
  7307.             // NetCharDevQSetInfo
  7308.             case CHANGE_PRIORITY:
  7309.                ChangePriority (pszServer, pszQueue, usPriority);
  7310.                continue;
  7311.             // NetCharDevQEnum
  7312.             case ENUM_QUEUES:
  7313.                EnumerateQueues (pszServer, pszUser);
  7314.                continue;
  7315.  
  7316.             // NetCharDevEnum
  7317.             case LIST_DEVICES:
  7318.                EnumerateDevices (pszServer);
  7319.                continue;
  7320.  
  7321.             // NetCharDevGetInfo
  7322.             case STATUS_DEVICE:
  7323.                GetDeviceInfo (pszServer, pszDevice);
  7324.                continue;
  7325.  
  7326.             // Close if currently using port or NetCharDevQPurgeSelf.
  7327.             case EXIT:
  7328.                StopInactiveJobs( pszServer, pszQueue, pszWksta);
  7329.                usRet = DosSemClear(hssmClose);
  7330.                printf("DosSemClear returned %hu\n", usRet);
  7331.                break;
  7332.  
  7333.             default:
  7334.                printf("Invalid option: select 1-%c\n", EXIT);
  7335.                continue;
  7336.          }
  7337.          break;
  7338.       }
  7339.       free (pBuf);
  7340.       exit(0);
  7341.    }
  7342.  
  7343.  
  7344.    // OpenPort spawns a child process that:
  7345.    //     -  Opens the com port (using the UNC name)
  7346.    //     -  Writes a test message to the port
  7347.    //     -  Waits on the \sem\chardev semaphore, then closes the port
  7348.    //
  7349.    // If the port is being used by another process, the DosOpen function
  7350.    // in the child process blocks until the port is freed.
  7351.    //
  7352.    // Note: You can always use the same semaphore because the DosOpen
  7353.    function
  7354.    // in the child process blocks if another process currently owns the
  7355.    port
  7356.    // (that is, only one process can wait on the semaphore at any one
  7357.    time).
  7358.  
  7359.  
  7360.    BOOL OpenPort (HSYSSEM hssmClose, char * pszShare, char * pszSem)
  7361.    {
  7362.       char achFailName[PATHLEN];
  7363.       RESULTCODES rescResults;
  7364.       char pszArgs[PATHLEN];
  7365.       char *pszNextArg;
  7366.       USHORT usRet;
  7367.  
  7368.        /*
  7369.         * Set the semaphore to cause the child process to wait after
  7370.    printing
  7371.         * the first line.
  7372.         */
  7373.       usRet = DosSemSet(hssmClose);
  7374.       printf("DosSemSet returned %hu\n", usRet);
  7375.  
  7376.        /*
  7377.         * Make up the argument list for the child process:
  7378.         *       usecom<NULL>sharename semaphore<NULL><NULL>
  7379.         * Make sure there are two null terminators in the argument list.
  7380.         */
  7381.  
  7382.       strnset (pszArgs, '\0', PATHLEN);
  7383.  
  7384.       strcpy (pszArgs, CHILD_PROCESS);
  7385.       pszNextArg = pszArgs + strlen(pszArgs) + 1;
  7386.       strcpy (pszNextArg, pszShare);
  7387.       strcat (pszNextArg, " ");
  7388.       strcat (pszNextArg, pszSem);
  7389.  
  7390.       usRet = DosExecPgm (achFailName,
  7391.                   PATHLEN,
  7392.                   EXEC_ASYNC,
  7393.                   pszArgs,
  7394.                   NULL,
  7395.                   &rescResults,
  7396.                   CHILD_PROCESS);
  7397.  
  7398.       printf ("DosExecPgm returned %hu\n", usRet);
  7399.       if (usRet)
  7400.          return FALSE;
  7401.       return TRUE;
  7402.    }
  7403.  
  7404.    //========================================================================
  7405.    // NetCharDevGetInfo
  7406.    //
  7407.    // This API finds the status of the ComShare device.
  7408.    //========================================================================
  7409.  
  7410.    BOOL GetDeviceInfo (char * pszServer, char * pszDev)
  7411.    {
  7412.       unsigned short cbTotalAvail;
  7413.       unsigned uRet;
  7414.       struct chardev_info_1 * pCharDevInfo;
  7415.  
  7416.        /*
  7417.         * The chardev_info_1 structure contains no variable-length data,
  7418.    so
  7419.         * there's no need to find out how much buffer space is required.
  7420.         */
  7421.  
  7422.       pCharDevInfo = SafeMalloc(sizeof (struct chardev_info_1));
  7423.  
  7424.       uRet = NetCharDevGetInfo(pszServer,               // Servername
  7425.                        pszDev,                          // Devicename
  7426.                        1,                               // Info level
  7427.                        (char far *)pCharDevInfo,        // Buffer
  7428.                        sizeof(struct chardev_info_1),   // Size of buffer
  7429.  
  7430.                        &cbTotalAvail);
  7431.  
  7432.       printf("NetCharDevGetInfo returned %u\n", uRet);
  7433.  
  7434.       if (uRet != NERR_Success)
  7435.          return FALSE;
  7436.       else
  7437.       {
  7438.          printf ("Status of device %s ",pCharDevInfo->ch1_dev);
  7439.          printf ("is %d ", pCharDevInfo->ch1_status);
  7440.          if (pCharDevInfo->ch1_status & CHARDEV_STAT_OPENED)
  7441.             printf ("(open");
  7442.          else
  7443.             printf ("(idle");
  7444.          if (pCharDevInfo->ch1_status & CHARDEV_STAT_ERROR)
  7445.             printf (" and in error");
  7446.          printf(")\n\n");
  7447.          if (pCharDevInfo->ch1_username[0] != '\0')
  7448.             printf ("Username is %s", pCharDevInfo->ch1_username);
  7449.          else
  7450.             printf ("No current users\n");
  7451.       }
  7452.  
  7453.  
  7454.       free(pCharDevInfo);
  7455.       return TRUE;
  7456.    }
  7457.  
  7458.    //========================================================================
  7459.    // NetCharDevEnum
  7460.    //
  7461.    // This API displays a list of character devices on the server.
  7462.    // Note: The attached devices are available only at info level 1.
  7463.    //========================================================================
  7464.  
  7465.    BOOL EnumerateDevices (char * pszServer)
  7466.    {
  7467.       unsigned short cEntriesRead;
  7468.       unsigned short cTotalEntries;
  7469.       unsigned short cbBuflen;
  7470.       unsigned short iCount;
  7471.       unsigned uRet;
  7472.       struct chardev_info_1 *pBuf, *pB;
  7473.  
  7474.       // First, a call to see what size buffer is needed.
  7475.       uRet = NetCharDevEnum(pszServer,           // Servername
  7476.                               1,                 // Info level
  7477.                               NULL,              // No buffer provided
  7478.                               0,                 // Size of buffer
  7479.                               &cEntriesRead,     // Count of entries
  7480.    read
  7481.                               &cTotalEntries);   // Count of entries
  7482.    available
  7483.       cbBuflen = (cTotalEntries + 1) * sizeof(struct chardev_info_1);
  7484.  
  7485.       pBuf = (struct chardev_info_1 *) SafeMalloc(cbBuflen);
  7486.       pB = pBuf;
  7487.       uRet = NetCharDevEnum(pszServer,          // Servername
  7488.                              1,                 // Info level
  7489.                              (char far *)pBuf,  // Data returned here
  7490.                              cbBuflen,          // Size of buffer, in
  7491.    bytes
  7492.                              &cEntriesRead,     // Count of entries read
  7493.                              &cTotalEntries);   // Count of entries available
  7494.  
  7495.       printf("NetCharDevEnum returned %u\n", uRet);
  7496.       if (uRet != NERR_Success)
  7497.       {
  7498.          free(pB);
  7499.          return FALSE;
  7500.       }
  7501.       if (cTotalEntries == 0)
  7502.          printf("There are no comm devices on this server\n");
  7503.  
  7504.       else
  7505.       {
  7506.          for (iCount = 0; iCount < cEntriesRead; iCount++)
  7507.          {
  7508.             printf("Device %s: ", pBuf->ch1_dev);
  7509.             printf("has status %d\n", pBuf->ch1_status);
  7510.             if (pBuf->ch1_status && CHARDEV_STAT_OPENED)
  7511.             {
  7512.                printf("Open %lu seconds ", pBuf->ch1_time);
  7513.                printf("by %s\n", pBuf->ch1_username);
  7514.             }
  7515.          pBuf++;
  7516.          }
  7517.       }
  7518.       free(pB);
  7519.       return TRUE;
  7520.    }
  7521.  
  7522.    //========================================================================
  7523.    // NetCharDevQEnum
  7524.    //
  7525.    // This API displays a list of character-device queues and the devices
  7526.  
  7527.    // they are attached to.
  7528.    // Note: The attached devices are available only at info level 1.
  7529.    //========================================================================
  7530.  
  7531.  
  7532.    BOOL EnumerateQueues (char * pszServer, char far * pszUser)
  7533.    {
  7534.  
  7535.       unsigned short cEntriesRead;
  7536.       unsigned short cTotalEntries;
  7537.       unsigned short cbBuflen;
  7538.       unsigned short iCount;
  7539.       unsigned uRet;
  7540.       struct chardevQ_info_1 * pQInfo;
  7541.       struct chardevQ_info_1 * pBuf;
  7542.  
  7543.       // First, a call to see what size buffer is needed.
  7544.       uRet = NetCharDevQEnum(pszServer,          // Servername
  7545.                               pszUser,           // Username
  7546.                               1,                 // Info level
  7547.                               NULL,              // No buffer provided
  7548.                               0,                 // Size of buffer
  7549.                               &cEntriesRead,     // Count of entries
  7550.    read
  7551.                               &cTotalEntries);   // Count of entries
  7552.    available
  7553.  
  7554.       cbBuflen = cTotalEntries * MAX_CHARDEVQ_INFO_1;
  7555.  
  7556.       pBuf = SafeMalloc(cbBuflen);          // Remember start of memory
  7557.    block
  7558.       pQInfo = pBuf;
  7559.       uRet = NetCharDevQEnum(pszServer,     // Servername
  7560.                         pszUser,            // Username
  7561.                         1,                  // Info level
  7562.                         (char far *)pQInfo, // Data returned here
  7563.                         cbBuflen,           // Size of buffer, in bytes
  7564.                         &cEntriesRead,      // Count of entries read
  7565.                         &cTotalEntries);    // Count of entries available
  7566.  
  7567.  
  7568.       printf("NetCharDevQEnum returned %u\n", uRet);
  7569.       if (uRet != NERR_Success)
  7570.          return FALSE;
  7571.       else
  7572.       {
  7573.          if (cTotalEntries == 0)
  7574.          {
  7575.             printf("There are no comm queues on this server\n");
  7576.          }
  7577.          else
  7578.          {
  7579.             for (iCount = 0; iCount < cEntriesRead; iCount++)
  7580.             {
  7581.                printf("\nQueue %s: ",pQInfo->cq1_dev );
  7582.                printf("has devices: %Fs\n", pQInfo->cq1_devs );
  7583.                printf("%u users, ", pQInfo->cq1_numusers );
  7584.                /*
  7585.                 * If numahead = CHARDEVQ_NO_REQUESTS, user has no jobs
  7586.  
  7587.                 * in the queue.
  7588.                 */
  7589.                if (pQInfo->cq1_numahead == CHARDEVQ_NO_REQUESTS)
  7590.                   printf("user %s has no jobs\n", pszUser);
  7591.                else
  7592.                   printf("%d users ahead of %s\n",
  7593.                           pQInfo->cq1_numahead, pszUser);
  7594.             pQInfo++;
  7595.             }
  7596.          }
  7597.       }
  7598.       free(pBuf);
  7599.       return TRUE;
  7600.    }
  7601.  
  7602.    //========================================================================
  7603.    // NetCharDevQGetInfo
  7604.    //
  7605.    // This API views the queue priority.
  7606.    //========================================================================
  7607.  
  7608.    BOOL ViewPriority (char *pszServer, char *pszQ, char far *pszUser)
  7609.    {
  7610.       struct chardevQ_info_1 *pBuf;
  7611.       unsigned short cbTotalAvail;
  7612.       unsigned short cbBuflen = sizeof( struct chardevQ_info_1) + 256;
  7613.       unsigned uRet;
  7614.  
  7615.       pBuf = (struct chardevQ_info_1 *) SafeMalloc (cbBuflen);
  7616.       uRet = NetCharDevQGetInfo(pszServer,   // Servername
  7617.                         pszQ,                // Queuename
  7618.                         pszUser,             // Username
  7619.                         1,                   // Info level
  7620.                         (char far *)pBuf,    // Buffer
  7621.                         cbBuflen,            // Size of buffer
  7622.                         &cbTotalAvail);      // Count of bytes available
  7623.       printf("NetCharDevQGetInfo returned %u\n", uRet);
  7624.  
  7625.       if (uRet == NERR_Success)
  7626.       {
  7627.          printf ("Queue %s ", pBuf->cq1_dev);
  7628.          printf ("has priority %d\n", pBuf->cq1_priority);
  7629.          printf ("Devices = %s\n", pBuf->cq1_devs);
  7630.          printf ("Number of users in queue = %d\n", pBuf->cq1_numusers);
  7631.          printf ("Number ahead of %s ", pszUser);
  7632.          printf ("= %d\n", pBuf->cq1_numahead);
  7633.       }
  7634.       free(pBuf);
  7635.       return TRUE; }
  7636.  
  7637.    //========================================================================
  7638.    // NetCharDevQSetInfo
  7639.    //
  7640.    // This API changes the queue priority from the default (5).
  7641.    //========================================================================
  7642.  
  7643.    BOOL ChangePriority (char * pszSrv, char * pszQ, unsigned short usPrty
  7644.    )
  7645.    {
  7646.  
  7647.       unsigned uRet;
  7648.  
  7649.  
  7650.       /*
  7651.        * There are two ways to call NetCharDevQSetInfo.
  7652.        * If sParmNum == PARMNUM_ALL, you must pass it a whole structure.
  7653.        * Otherwise, you can set sParmNum to the element of the structure
  7654.  
  7655.        * you want to change. Only the latter method is shown here.
  7656.        */
  7657.  
  7658.       uRet = NetCharDevQSetInfo(pszSrv,              // Servername
  7659.                         pszQ,                        // Queuename
  7660.                         1,                           // Info level
  7661.                         (char far *)&usPrty,         // Buffer
  7662.                         sizeof (usPrty),             // Size of buffer
  7663.  
  7664.                         CHARDEVQ_PRIORITY_PARMNUM);  // Parameter code
  7665.    number
  7666.       printf("NetCharDevQSetInfo returned %u\n", uRet);
  7667.  
  7668.       if (uRet != NERR_Success)
  7669.          return FALSE;
  7670.       else
  7671.          printf ("Priority for queue changed to %d\n", usPrty);
  7672.       return TRUE;
  7673.    }
  7674.  
  7675.    //========================================================================
  7676.    // NetCharDevQPurgeSelf
  7677.    //
  7678.    // This API removes its own jobs from the queue. It removes only
  7679.    // jobs that have not started printing.
  7680.    //========================================================================
  7681.  
  7682.    BOOL StopInactiveJobs (char *pszServer, char *pszQ, char far *pszComputer)
  7683.    {
  7684.       unsigned uRet;
  7685.       uRet = NetCharDevQPurgeSelf (pszServer,     // Servername
  7686.                                     pszQ,         // Queuename
  7687.                                     pszComputer); // Workstation name
  7688.  
  7689.       printf("NetCharDevQPurgeSelf returned %u\n", uRet);
  7690.       switch (uRet)
  7691.       {
  7692.          case NERR_Success:
  7693.             break;
  7694.          case NERR_ItemNotFound:
  7695.             printf ("There are no jobs in the queue\n");
  7696.             break;
  7697.          default:
  7698.             return FALSE;
  7699.       }
  7700.       return TRUE;
  7701.  
  7702.    }
  7703.  
  7704.    void DisplayPrompt(void)
  7705.    {
  7706.       printf("\n\nCharacter Device Category API Examples\n\n");
  7707.       printf("%c. Start job: DosExecPgm DosOpen comm device\n",
  7708.                                                           START_JOB);
  7709.       printf("%c. Device status: NetCharDevGetInfo\n",
  7710.                                                           STATUS_DEVICE);
  7711.       printf("%c. List all devices: NetCharDevEnum\n",
  7712.                                                           LIST_DEVICES);
  7713.       printf("%c. List all queues: NetCharDevQEnum\n",
  7714.                                                           ENUM_QUEUES);
  7715.       printf("%c. View queue: NetCharDevQGetInfo\n",
  7716.                                                           VIEW_PRIORITY);
  7717.       printf("%c. Change priority: NetCharDevQSetInfo\n",
  7718.                                                           CHANGE_PRIORITY);
  7719.       printf("%c. Close device, kill job: NetCharDevControl\n",
  7720.                                                           KILL_ACTIVE_JOB);
  7721.       printf("%c. Stop all jobs: NetCharDevQPurgeSelf\n",
  7722.                                                           PURGE_OWN_JOBS);
  7723.       printf("%c. Purge queue: NetCharDevQPurge\n",
  7724.                                                           PURGE_QUEUE);
  7725.       printf("%c. Exit\n",
  7726.                                                           EXIT);
  7727.       printf("Enter selection:  ");
  7728.    }
  7729.  
  7730.    // Return the next character typed from the keyboard.
  7731.    char GetNextAction ()
  7732.    {
  7733.       return ((char)getche());
  7734.    }
  7735.  
  7736.    void Usage(char *pszString)
  7737.    {
  7738.       fprintf(stderr, "Usage: %s [-s \\\\server] [-q queue]", pszString);
  7739.       fprintf(stderr, " [-u username]\n");
  7740.       fprintf(stderr, "\t[-w wksta] [-d device] [-p priority]\n");
  7741.       exit(1);
  7742.    }
  7743.  
  7744.    /*
  7745.       NETCHAR2.C -- a sample program demonstrating NetCharDev API functions.
  7746.                     This program should only be executed from NETCHAR1.C.
  7747.  
  7748.       This program attempts to open the comm device using the UNC name.
  7749.       Note: If the device has already been opened by another process,
  7750.       DosOpen blocks until the device is freed.
  7751.  
  7752.       Once the port is open, a sentence is written out and the process
  7753.    waits
  7754.       on a semaphore to be told to close the port.
  7755.  
  7756.          usage: netchar2 \\server\share semaphore
  7757.  
  7758.       This code sample is provided for demonstration purposes only.
  7759.       Microsoft makes no warranty, either express or implied,
  7760.       as to its usability in any given situation.
  7761.    */
  7762.  
  7763.    #define CALLING_PROGRAM  "netchar1"
  7764.    #define STRING1          "A test message\r\n"
  7765.    #define STRING1LEN       strlen(STRING1)
  7766.    #define STRING2          "Closing statement\r\n"
  7767.    #define STRING2LEN       strlen(STRING2)
  7768.  
  7769.    #define     INCL_BASE
  7770.    #include    <os2.h>        // MS OS/2 base header files
  7771.  
  7772.    #define     INCL_NETERRORS
  7773.    #include    <lan.h>        // LAN Manager header files
  7774.  
  7775.    #include    <stdio.h>      // C run-time header file
  7776.    #include    <stdlib.h>
  7777.    #include    <string.h>
  7778.  
  7779.    void Usage(char *pszString);
  7780.  
  7781.    void main(int argc, char *argv[])
  7782.    {
  7783.       HFILE   fh;
  7784.       USHORT  usAction;
  7785.       unsigned short usRet;
  7786.       USHORT   cbWritten;
  7787.       HSYSSEM  hssmClose;
  7788.  
  7789.       if (argc != 3)
  7790.          Usage(CALLING_PROGRAM);
  7791.  
  7792.  
  7793.       // Open the semaphore this thread waits for.
  7794.       if (DosOpenSem(&hssmClose, argv[2]) != 0)
  7795.          exit(1);
  7796.  
  7797.       /*
  7798.        * The first process to open gets a file handle immediately;
  7799.        * all subsequent processes are suspended until the device
  7800.        * is freed (that is, until the current owner closes the device).
  7801.        */
  7802.       usRet = DosOpen (argv[1],
  7803.                   &fh,
  7804.                   &usAction,
  7805.                   0L,   // No file length, since this is a com port
  7806.                   0,    // No action specified since we aren't creating
  7807.                   FILE_OPEN,
  7808.                   OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE,
  7809.                   0L    // Reserved
  7810.                 );
  7811.  
  7812.       if (usRet != NERR_Success)
  7813.          exit(1);
  7814.  
  7815.       DosWrite(fh, STRING1, STRING1LEN, &cbWritten);
  7816.  
  7817.       // Wait to be told to close or for 30 seconds (whichever comes
  7818.    first).
  7819.       usRet = DosSemWait(hssmClose, 30000L);
  7820.       if (usRet != ERROR_SEM_TIMEOUT)
  7821.       {
  7822.          printf("\nQueue was forced closed, DosSemWait returned %hu\n",
  7823.                    usRet);
  7824.          exit(1);
  7825.       }
  7826.  
  7827.       DosWrite(fh, STRING2, STRING2LEN, &cbWritten);
  7828.  
  7829.       /*
  7830.        * Close the device using DosClose instead of NetCharDevControl.
  7831.  
  7832.        * The NetCharDevControl function is designed for administrators
  7833.  
  7834.        * when they need to force the device closed.
  7835.        */
  7836.  
  7837.       DosClose(fh);
  7838.       exit(0);
  7839.    }
  7840.  
  7841.    void Usage(char *pszString)
  7842.    {
  7843.       fprintf(stderr, "This program should not be called directly.\n");
  7844.       fprintf(stderr, "Usage: %s [-s \\\\server] [-q queue]", pszString);
  7845.       fprintf(stderr, " [-u username]\n");
  7846.       fprintf(stderr, "\t[-w wksta] [-d device] [-p priority]\n");
  7847.       exit(1);
  7848.    }
  7849.  
  7850.  
  7851.  
  7852.  
  7853.  
  7854.  Configuration Category
  7855.  
  7856.  Configuration API functions retrieve network configuration information from
  7857.  the LANMAN.INI file. When executed on the local computer, Configuration API
  7858.  functions require that the NETWKSTA device driver be installed. When
  7859.  executed on a remote server, they require that the local Workstation service
  7860.  be started.
  7861.  
  7862.  The Configuration category functions, datatypes, structures, and constants
  7863.  are defined in the NETCONS.H, NETERR.H, and CONFIG.H header files. A source
  7864.  program can access these definitions by defining the constants
  7865.  INCL_NETERRORS and INCL_NETCONFIG, and including the master header file,
  7866.  LAN.H. For more information about these definitions, see the "Example"
  7867.  section, later in this category.
  7868.  
  7869.  These are the Configuration API functions:
  7870.  
  7871.  
  7872.    ■   NetConfigGet2
  7873.  
  7874.    ■   NetConfigGetAll2
  7875.  
  7876.  
  7877.  
  7878.  Description
  7879.  
  7880.  NetConfigGet2 retrieves a single entry value from the LANMAN.INI file on the
  7881.  local computer or on a remote server.
  7882.  
  7883.  NetConfigGetAll2 retrieves the value of the entries for a given component
  7884.  from the LANMAN.INI file on the local computer or on a remote server.
  7885.  
  7886.  The LANMAN.INI file is an ASCII file that contains configuration information
  7887.  for LAN Manager services, as well as network configuration information for
  7888.  user-defined services and applications. It consists of component lines,
  7889.  entry lines, and comment lines, in the following format:
  7890.  
  7891.  
  7892.    ■   Component lines mark the start of a set of information, in this form:
  7893.  
  7894.        [component name]
  7895.  
  7896.    ■   Entry lines contain a parameter and a value, in this form:
  7897.  
  7898.        entry = value
  7899.  
  7900.        The entry value can consist of any text. Configuration API functions
  7901.        do not process the text, although they do remove leading and trailing
  7902.        spaces. Interpretation of the value is left to the caller.
  7903.  
  7904.        If an entry appears several times in a single component,
  7905.        NetConfigGetAll2 returns each instance; NetConfigGet2 returns only the
  7906.        first instance. Using the same entry name in different components does
  7907.        not affect the data returned by NetConfigGet2.
  7908.  
  7909.    ■   Comment lines are any blank lines or lines that have a semicolon (;)
  7910.        as the first nonblank character.
  7911.  
  7912.  
  7913.  For example, a LANMAN.INI [workstation] component might contain the
  7914.  following information:
  7915.  
  7916.    [workstation]
  7917.        ; define net_tools workstation
  7918.        computername = NET_TOOLS
  7919.        charcount = 16
  7920.        chartime = 250
  7921.        charwait = 3600
  7922.        domain = LAN
  7923.  
  7924.  The LANMAN.INI file contains default values for network parameters. These
  7925.  values are not necessarily the current values for those parameters. For
  7926.  example, in the preceding example, the computername component is set to
  7927.  NET_TOOLS, but the workstation does not necessarily have that name. A
  7928.  different name could be specified from the command line when the Workstation
  7929.  service is started. Use NetWkstaGetInfo to retrieve the current value of
  7930.  parameters in the [workstation] component; use NetServerGetInfo to retrieve
  7931.  the current values for the [server] component.
  7932.  
  7933.  See Also
  7934.  
  7935.  For information about             See
  7936.  ────────────────────────────────────────────────────────────────────────────
  7937.  LANMAN.INI file                   LAN Manager administrator's manual(s)
  7938.  
  7939.  
  7940.  NetConfigGet2
  7941.  ────────────────────────────────────────────────────────────────────────────
  7942.  
  7943.  NetConfigGet2 retrieves the value of a single specified entry for a
  7944.  particular component of the LANMAN.INI file on the local computer or on a
  7945.  remote server.
  7946.  
  7947.  
  7948.  Operating Systems Supported
  7949.  
  7950.  
  7951.    ■   MS OS/2 version 1.2, local and remote
  7952.  
  7953.    ■   MS OS/2 version 1.1, local and remote
  7954.  
  7955.    ■   MS-DOS, local and remote
  7956.  
  7957.  
  7958.  
  7959.  Privilege Level
  7960.  
  7961.  Admin privilege or accounts, comm, print, or server operator privilege is
  7962.  required to successfully execute NetConfigGet2 on a remote server.
  7963.  
  7964.  
  7965.  Syntax
  7966.  
  7967.    #define INCL_NETCONFIG
  7968.    #define INCL_NETERRORS
  7969.    #include <lan.h>
  7970.  
  7971.    API_FUNCTION
  7972.    NetConfigGet2 (const char far *      pszServer,
  7973.                   const char far *      pszReserved,
  7974.                   const char far *      pszComponent,
  7975.                   const char far *      pszParameter,
  7976.                   const char far *      pbBuffer,
  7977.                   unsigned short        cbBuffer,
  7978.                   unsigned short far *  pcbParmlen
  7979.                  );
  7980.  
  7981.  where
  7982.  
  7983.  pszServer
  7984.    Points to an ASCIIZ string that contains the name of the server on which
  7985.    to execute NetConfigGet2. A null pointer or null string specifies the
  7986.    local computer.
  7987.  
  7988.  pszReserved
  7989.    Reserved; must be a null pointer.
  7990.  
  7991.  pszComponent
  7992.    Points to an ASCIIZ string that specifies which LANMAN.INI component to
  7993.    search.
  7994.  
  7995.  pszParameter
  7996.    Points to an ASCIIZ string that specifies the entry whose value is to be
  7997.    returned.
  7998.  
  7999.  pbBuffer
  8000.    Points to the buffer where the value of the entry is to be returned.
  8001.  
  8002.  cbBuffer
  8003.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  8004.  
  8005.  pcbParmlen
  8006.    Points to an unsigned short integer in which the size of the entry value
  8007.    (in bytes) is returned. This count is valid only if NetConfigGet2 returns
  8008.    NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  8009.  
  8010.  Return Codes
  8011.  
  8012. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  8013.  Code                              Value   Meaning
  8014.  ────────────────────────────────────────────────────────────────────────────
  8015.  NERR_Success                      0       The function encountered no
  8016.                                            errors.
  8017.  
  8018.  ERROR_FILE_NOT_FOUND              2       The file was not found.
  8019.  
  8020.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  8021.  
  8022.  ERROR_ACCESS_DENIED               5       The user has insufficient
  8023.                                            privilege for this operation.
  8024.  Code                              Value   Meaning
  8025.  ────────────────────────────────────────────────────────────────────────────
  8026.                                           privilege for this operation.
  8027.  
  8028.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  8029.  
  8030.  ERROR_BAD_NETPATH                 53      The network path was not found.
  8031.  
  8032.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  8033.  
  8034.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  8035.                                            invalid.
  8036.  
  8037.  ERROR_MORE_DATA                   234     Additional data is available.
  8038.  
  8039.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  8040.                                            is not installed.
  8041.  
  8042.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  8043.  
  8044.  NERR_BadTransactConfig            2141    The server is not configured for
  8045.  Code                              Value   Meaning
  8046.  ────────────────────────────────────────────────────────────────────────────
  8047. NERR_BadTransactConfig            2141    The server is not configured for
  8048.                                            this transaction: IPC$ is not
  8049.                                            shared.
  8050.  
  8051.  NERR_InvalidAPI                   2142    The requested API is not
  8052.                                            supported on the remote server.
  8053.  
  8054.  NERR_CfgCompNotFound              2146    The specified component in the
  8055.                                            LANMAN.INI file is not found.
  8056.  
  8057.  NERR_CfgParamNotFound             2147    The specified parameter in the
  8058.                                            LANMAN.INI file is not found.
  8059.  
  8060.  NERR_InvalidComputer              2351    The specified computername is
  8061.                                            invalid.
  8062.  
  8063.  ────────────────────────────────────────────────────────────────────────────
  8064.  
  8065.  
  8066.  
  8067.  
  8068.  Remarks
  8069.  
  8070.  NetConfigGet2 returns the entry value of the specified LANMAN.INI component
  8071.  as an ASCIIZ string in the buffer pointed to by pbBuffer. This string
  8072.  consists of all text to the right of the equal sign (=) in the LANMAN.INI
  8073.  entry. NetConfigGet2 removes leading and trailing spaces, but performs no
  8074.  other processing on the text.
  8075.  
  8076.  For example, the LANMAN.INI entry
  8077.  
  8078.    "    sky  =  blue,1,long comment string    "
  8079.  
  8080.  is returned as the following string:
  8081.  
  8082.    "blue,1,long comment string"
  8083.  
  8084.  The value of cbBuffer must be at least 1 larger than the value returned in
  8085.  pcbParmlen; this is necessary to provide for the NUL at the end of the
  8086.  ASCIIZ string.
  8087.  
  8088.  NetConfigGet2 supersedes NetConfigGet (used in earlier versions of LAN
  8089.  Manager). These functions are the same except that NetConfigGet2 has the
  8090.  pszServer parameter, which enables it to be called remotely. For more
  8091.  information, see Appendix B, "Upgrading LAN Manager 1.0 Applications."
  8092.  
  8093.  See Also
  8094.  
  8095.  For information about             See
  8096.  ────────────────────────────────────────────────────────────────────────────
  8097.  LANMAN.INI file                   LAN Manager administrator's manual(s)
  8098.  
  8099.  
  8100.  NetConfigGetAll2
  8101.  ────────────────────────────────────────────────────────────────────────────
  8102.  
  8103.  NetConfigGetAll2 retrieves all the configuration information for a given
  8104.  component in the LANMAN.INI file on a local or a remote computer.
  8105.  
  8106.  
  8107.  Operating Systems Supported
  8108.  
  8109.  
  8110.    ■   MS OS/2 version 1.2, local and remote
  8111.  
  8112.    ■   MS OS/2 version 1.1, local and remote
  8113.  
  8114.    ■   MS-DOS, local and remote
  8115.  
  8116.  
  8117.  
  8118.  Privilege Level
  8119.  
  8120.  Admin privilege or account, comm, print, or server operator privilege is
  8121.  required to successfully execute NetConfigGetAll2 on a remote server.
  8122.  
  8123.  
  8124.  Syntax
  8125.  
  8126.    #define INCL_NETCONFIG
  8127.    #define INCL_NETERRORS
  8128.    #include <lan.h>
  8129.  
  8130.    API_FUNCTION
  8131.    NetConfigGetAll2 (const char far *      pszServer,
  8132.                      const char far *      pszReserved,
  8133.                      const char far *      pszComponent,
  8134.                      char far *            pbBuffer,
  8135.                      unsigned short        cbBuffer,
  8136.                      unsigned short far *  pcbReturned,
  8137.                      unsigned short far *  pcbTotalAvail
  8138.                     );
  8139.  
  8140.  where
  8141.  
  8142.  pszServer
  8143.    Points to an ASCIIZ string that contains the name of the server on which
  8144.    to execute NetConfigGetAll2. A null pointer or null string specifies the
  8145.    local computer.
  8146.  
  8147.  pszReserved
  8148.    Reserved; must be a null pointer.
  8149.  
  8150.  pszComponent
  8151.    Points to an ASCIIZ string that specifies which LANMAN.INI component to
  8152.    search.
  8153.  
  8154.  pbBuffer
  8155.    Points to the buffer where the entry values are to be returned.
  8156.  
  8157.  cbBuffer
  8158.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  8159.  
  8160.  pcbReturned
  8161.    Points to an unsigned short integer in which the number of bytes returned
  8162.    in the buffer pointed to by pbBuffer is returned.
  8163.  
  8164.  pcbTotalAvail
  8165.    Points to an unsigned short integer in which the number of bytes of data
  8166.    available is returned. This count is valid only if NetConfigGetAll2
  8167.    returns NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  8168.  
  8169.  Return Codes
  8170.  
  8171. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  8172.  Code                              Value   Meaning
  8173.  ────────────────────────────────────────────────────────────────────────────
  8174.  NERR_Success                      0       The function encountered no
  8175.                                            errors.
  8176.  
  8177.  ERROR_FILE_NOT_FOUND              2       The file was not found.
  8178.  
  8179.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  8180.  
  8181.  ERROR_ACCESS_DENIED               5       The user has insufficient
  8182.                                            privilege for this operation.
  8183.  
  8184.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  8185.  
  8186.  ERROR_BAD_NETPATH                 53      The network path was not found.
  8187.  
  8188.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  8189.  
  8190.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  8191.                                            invalid.
  8192.  Code                              Value   Meaning
  8193.  ────────────────────────────────────────────────────────────────────────────
  8194.                                           invalid.
  8195.  
  8196.  ERROR_MORE_DATA                   234     Additional data is available.
  8197.  
  8198.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  8199.                                            is not installed.
  8200.  
  8201.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  8202.  
  8203.  NERR_BadTransactConfig            2141    The server is not configured for
  8204.                                            this transaction: IPC$ is not
  8205.                                            shared.
  8206.  
  8207.  NERR_InvalidAPI                   2142    The requested API is not
  8208.                                            supported on the remote server.
  8209.  
  8210.  NERR_CfgCompNotFound              2146    The specified component in the
  8211.                                            LANMAN.INI file is not found.
  8212.  
  8213.  Code                              Value   Meaning
  8214.  ────────────────────────────────────────────────────────────────────────────
  8215. 
  8216.  NERR_InvalidComputer              2351    The specified computername is
  8217.                                            invalid.
  8218.  
  8219.  ────────────────────────────────────────────────────────────────────────────
  8220.  
  8221.  
  8222.  
  8223.  
  8224.  Remarks
  8225.  
  8226.  NetConfigGetAll2 returns a set of concatenated ASCIIZ strings in the buffer
  8227.  pointed to by pbBuffer, representing configuration information for the
  8228.  specified component. Each string is terminated by a NUL, and the whole
  8229.  buffer is terminated by a null string. NetConfigGetAll2 removes leading and
  8230.  trailing spaces, but performs no other processing on the text. Information
  8231.  is returned in the form ENTRY=value. The entry name (left of the equal sign)
  8232.  is converted to uppercase.
  8233.  
  8234.  For example, the LANMAN.INI entry
  8235.  
  8236.    "   sky  =  blue, 1, long comment string   "
  8237.    "    ground  =  brown, 2"
  8238.  
  8239.  is returned as these two consecutive strings:
  8240.  
  8241.    "SKY=blue, 1, long comment string"
  8242.    "GROUND=brown, 2"
  8243.  
  8244.  NetConfigGetAll2 supersedes NetConfigGetAll (used in earlier versions of LAN
  8245.  Manager). These functions are the same except that NetConfigGetAll2 has the
  8246.  pszServer parameter, which enables it to be called remotely. For more
  8247.  information, see Appendix B, "Upgrading LAN Manager 1.0 Applications."
  8248.  
  8249.  See Also
  8250.  
  8251.  For information about             See
  8252.  ────────────────────────────────────────────────────────────────────────────
  8253.  LANMAN.INI file                   LAN Manager administrator's manual(s)
  8254.  
  8255.  
  8256.  
  8257.  
  8258.  
  8259.  Configuration Category Example
  8260.  
  8261.    /*
  8262.       NETCNFG.C -- a sample program demonstrating NetConfig API functions.
  8263.  
  8264.       This program requires that you have admin privilege or any
  8265.       type of operator privilege on the specified server.
  8266.  
  8267.          usage:  netcnfg [-s \\server] [-p parameter] [-c component]
  8268.  
  8269.          where  \\server  = Name of the server. A servername must be
  8270.                             preceded by two backslashes (\\).
  8271.                 parameter = Name of the LANMAN.INI parameter to get.
  8272.                 component = Name of the component from which the
  8273.                             parameter is to be retrieved.
  8274.  
  8275.       API                  Used to...
  8276.       ================     ===========================================
  8277.       NetConfigGet2        Retrieve a parameter in the LANMAN.INI file
  8278.                            on the specified server
  8279.       NetConfigGetAll2     Retrieve complete component info from the
  8280.                            specified LANMAN.INI file
  8281.  
  8282.       This code sample is provided for demonstration purposes only.
  8283.       Microsoft makes no warranty, either express or implied,
  8284.       as to its usability in any given situation.
  8285.    */
  8286.  
  8287.    #define     INCL_NETCONFIG
  8288.    #define     INCL_NETERRORS
  8289.    #include    <lan.h>        // LAN Manager header files
  8290.  
  8291.    #include    <stdio.h>      // C run-time header files
  8292.    #include    <stdlib.h>
  8293.    #include    <string.h>
  8294.  
  8295.    #include    "samples.h"    // Internal routine header file
  8296.  
  8297.    #define DEFAULT_COMPONENT  "Workstation"
  8298.    #define DEFAULT_PARAMETER  "Domain"
  8299.    #define SMALL_BUFF         64
  8300.    #define BIG_BUFF           4096
  8301.  
  8302.    void Usage (char * pszProgram);
  8303.  
  8304.    void main(int argc, char *argv[])
  8305.    {
  8306.       char *pszServer = "";                     // Servername
  8307.       char *pszComponent  = DEFAULT_COMPONENT;  // Component to list
  8308.       char *pszParameter  = DEFAULT_PARAMETER;  // Parameter within component
  8309.       char *pszBuffer, *p;                      // String pointers
  8310.       int            iCount;                    // Index counter
  8311.       unsigned short cbBuffer;                  // Count of bytes in
  8312.    buffer
  8313.       unsigned short cbParmlen;                 // Length of returned
  8314.    parameter
  8315.       unsigned short cbRead;                    // Count of bytes read
  8316.       unsigned short cbAvail;                   // Count of bytes available
  8317.       API_RET_TYPE   uReturnCode;               // API return code
  8318.  
  8319.       for (iCount = 1; iCount < argc; iCount++)
  8320.       {
  8321.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  8322.          {
  8323.             switch (tolower(*(argv[iCount]+1))) // Process switches
  8324.             {
  8325.                case 's':                        // -s servername
  8326.                   pszServer = argv[++iCount];
  8327.                   break;
  8328.                case 'c':                        // -c component
  8329.                   pszComponent = argv[++iCount];
  8330.                   break;
  8331.                case 'p':                        // -p parameter
  8332.                   pszParameter = argv[++iCount];
  8333.                   break;
  8334.                case 'h':
  8335.                default:
  8336.                   Usage(argv[0]);
  8337.             }
  8338.          }
  8339.          else
  8340.             Usage(argv[0]);
  8341.       }
  8342.  
  8343.    //========================================================================
  8344.    //  NetConfigGet2
  8345.    //
  8346.    //  This API retrieves a single entry from the LANMAN.INI file on
  8347.    a
  8348.    //  specified server. If no servername is given, the local LANMAN.INI
  8349.    //  file is used. When executed remotely, the user must have admin
  8350.    //  privilege or at least one operator privilege on the remote server.
  8351.    //========================================================================
  8352.       cbBuffer = SMALL_BUFF;
  8353.       pszBuffer = SafeMalloc(cbBuffer);
  8354.  
  8355.       uReturnCode = NetConfigGet2(
  8356.                               pszServer,     // Servername
  8357.                               NULL,          // Reserved; must be NULL
  8358.                               pszComponent,  // Component in LANMAN.INI
  8359.                               pszParameter,  // Parameter in component
  8360.                               pszBuffer,     // Pointer to return buffer
  8361.                               cbBuffer,      // Size of buffer
  8362.                               &cbParmlen);   // Length of returned parameter
  8363.  
  8364.       printf("NetConfigGet2 returned %u \n", uReturnCode);
  8365.  
  8366.       if (uReturnCode == NERR_Success)
  8367.          printf("   %s = %s\n\n", pszParameter, pszBuffer);
  8368.       else if (uReturnCode == NERR_BufTooSmall)
  8369.          printf("   %hu bytes were provided, but %hu bytes were needed\n\n",
  8370.                cbBuffer, cbParmlen);
  8371.       free(pszBuffer);
  8372.  
  8373.    //========================================================================
  8374.    //  NetConfigGetAll2
  8375.    //
  8376.    //  This API returns information for an entire LANMAN.INI component
  8377.  
  8378.    //  such as [networks] or [workstation]. The returned information
  8379.    is a
  8380.    //  sequence of null-terminated strings followed by a null string.
  8381.    //========================================================================
  8382.  
  8383.       cbBuffer = BIG_BUFF;
  8384.       pszBuffer = SafeMalloc(cbBuffer);
  8385.  
  8386.       uReturnCode = NetConfigGetAll2(
  8387.                               pszServer,     // Name of remote server
  8388.                               NULL,          // Reserved; must be NULL
  8389.                               pszComponent,  // Component of LANMAN.INI
  8390.                               pszBuffer,     // Pointer to return buffer
  8391.                               cbBuffer,      // Size of buffer
  8392.                               &cbRead,       // Count of bytes read
  8393.                               &cbAvail);     // Count of bytes available
  8394.  
  8395.  
  8396.    printf("NetConfigGetAll2 returned %u \n", uReturnCode);
  8397.  
  8398.       switch(uReturnCode)
  8399.       {
  8400.          case NERR_Success:                  // It worked
  8401.             p = pszBuffer;
  8402.             while (*p)                       // While not at null string
  8403.             {
  8404.                printf("   %s\n", p);         // Print string
  8405.                p += (strlen(p) + 1);         // Step past trailing NUL
  8406.             }
  8407.             break;
  8408.          case ERROR_BAD_NETPATH:
  8409.             printf("   Server %s not found.\n", pszServer);
  8410.             break;
  8411.          case NERR_InvalidAPI:
  8412.             printf("   The remote server %s does not support this API.\n",
  8413.                     pszServer);
  8414.             break;
  8415.          default:
  8416.             break;
  8417.       }
  8418.       free(pszBuffer);
  8419.    }
  8420.  
  8421.    void Usage (char * pszProgram)
  8422.    {
  8423.       fprintf(stderr, "Usage: %s [-s \\\\server] [-c component]" \
  8424.                       " [-p parameter]\n", pszProgram);
  8425.       exit(1);
  8426.    }
  8427.  
  8428.  
  8429.  
  8430.  
  8431.  
  8432.  Connection Category
  8433.  
  8434.  The Connection API function, NetConnectionEnum, lists server connections.
  8435.  When a remote server is specified, NetConnectionEnum requires that the
  8436.  Workstation service be started on the local computer and that the Server
  8437.  service be started on the specified server.
  8438.  
  8439.  The Connection category function, datatypes, structures, and constants are
  8440.  defined in the NETCONS.H, NETERR.H, and SHARES.H header files. A source
  8441.  program can access these definitions by defining the constants
  8442.  INCL_NETERRORS and INCL_NETCONNECTION, and including the master header file,
  8443.  LAN.H. For more information about these definitions, see the "Example"
  8444.  section, later in this category.
  8445.  
  8446.  
  8447.  Description
  8448.  
  8449.  A computer accesses a shared resource on a server by means of a connection.
  8450.  A connection is a software link between a computer and a server, made by
  8451.  assigning a local or null devicename to the shared resource on the server.
  8452.  The NetUseAdd function establishes connections.
  8453.  
  8454.  NetConnectionEnum lists information about all connections to a server made
  8455.  by a specified computer, or about all connections made to a specified
  8456.  sharename.
  8457.  
  8458.  
  8459.  Data Structures
  8460.  
  8461.  NetConnectionEnum returns data at a detail level of 0 or 1, using the
  8462.  connection_info_0 and connection_info_1 data structures.
  8463.  
  8464.  
  8465.  Connection Information (level 0)
  8466.  
  8467.  The connection_info_0 data structure has this format:
  8468.  
  8469.    struct connection_info_0 {
  8470.        unsigned short  coni0_id;
  8471.    };
  8472.  
  8473.  where
  8474.  
  8475.  coni0_id
  8476.    Specifies the connection identification number.
  8477.  
  8478.  
  8479.  Connection Information (level 1)
  8480.  
  8481.  The connection_info_1 data structure has this format:
  8482.  
  8483.    struct connection_info_1 {
  8484.        unsigned short  coni1_id;
  8485.        unsigned short  coni1_type;
  8486.        unsigned short  coni1_num_opens;
  8487.        unsigned short  coni1_num_users;
  8488.        unsigned long   coni1_time;
  8489.        char far *      coni1_username;
  8490.        char far *      coni1_netname;
  8491.    };
  8492.  
  8493.  where
  8494.  
  8495.  coni1_id
  8496.    Specifies the connection identification number.
  8497.  
  8498.  coni1_type
  8499.    Specifies the type of connection made from the local computer to the
  8500.    shared resource. The SHARES.H header file defines these possible
  8501.    connections:
  8502.  
  8503.  Code            Value  Meaning
  8504.  ────────────────────────────────────────────────────────────────────────────
  8505.  STYPE_DISKTREE  0      Disk connection.
  8506.  STYPE_PRINTQ    1      Printer queue connection.
  8507.  STYPE_DEVICE    2      Communication-device connection.
  8508.  STYPE_IPC       3      Interprocess communication (IPC) connection.
  8509.  ────────────────────────────────────────────────────────────────────────────
  8510.  
  8511.  coni1_num_opens
  8512.    Specifies the number of resources (files, pipes, or devices) open as a
  8513.    result of the connection.
  8514.  
  8515.  coni1_num_users
  8516.    Specifies the number of connected users.
  8517.  
  8518.  coni1_time
  8519.    Specifies the number of seconds the connection has been established.
  8520.  
  8521.  coni1_username
  8522.    Points to an ASCIIZ string. On a server that has user-level security, the
  8523.    string contains the name of the user who established the connection. On a
  8524.    server that has share-level security, the string contains the name of the
  8525.    computer that established the connection.
  8526.  
  8527.  coni1_netname
  8528.    Points to an ASCIIZ string that contains the sharename or a computername.
  8529.    This value is the inverse of the NetConnectionEnum pszQualifier parameter:
  8530.    when pszQualifier is a sharename, coni1_netname is a computername; when
  8531.    pszQualifier is a computername, coni1_netname is a sharename.
  8532.  
  8533.  See Also
  8534.  
  8535.  For information about             See
  8536.  ────────────────────────────────────────────────────────────────────────────
  8537.  Connecting to a shared resource   NetUseAdd
  8538.  on a server
  8539.  
  8540.  
  8541.  NetConnectionEnum
  8542.  ────────────────────────────────────────────────────────────────────────────
  8543.  
  8544.  NetConnectionEnum lists all connections made to a shared resource on the
  8545.  server or all connections established from a particular computer.
  8546.  
  8547.  
  8548.  Operating Systems Supported
  8549.  
  8550.  
  8551.    ■   MS OS/2 version 1.2, local and remote
  8552.  
  8553.    ■   MS OS/2 version 1.1, remote only
  8554.  
  8555.    ■   MS-DOS, remote only
  8556.  
  8557.  
  8558.  
  8559.  Privilege Level
  8560.  
  8561.  Admin privilege or server, print, or comm operator privilege is required to
  8562.  successfully execute NetConnectionEnum on a remote server or on a computer
  8563.  that has local security enabled.
  8564.  
  8565.  
  8566.  Syntax
  8567.  
  8568.    #define INCL_NETCONNECTION
  8569.    #define INCL_NETERRORS
  8570.    #include <lan.h>
  8571.  
  8572.    API_FUNCTION
  8573.    NetConnectionEnum (const char far *      pszServer,
  8574.                       const char far *      pszQualifier,
  8575.                       short                 sLevel,
  8576.                       char far *            pbBuffer,
  8577.                       unsigned short        cbBuffer,
  8578.                       unsigned short far *  pcEntriesRead,
  8579.                       unsigned short far *  pcTotalEntries
  8580.                      );
  8581.  
  8582.  where
  8583.  
  8584.  pszServer
  8585.    Points to an ASCIIZ string that contains the name of the server on which
  8586.    to execute NetConnectionEnum. A null pointer or null string specifies the
  8587.    local computer.
  8588.  
  8589.  pszQualifier
  8590.    Points to an ASCIIZ string that specifies either a sharename or a
  8591.    computername. If pszQualifier is a sharename, NetConnectionEnum lists all
  8592.    connections made to that sharename. If pszQualifier is a computername,
  8593.    NetConnectionEnum lists all connections made from that computer to the
  8594.    server specified by pszServer. This parameter cannot be a null pointer or
  8595.    null string. When pszQualifier represents a computername, it must start
  8596.    with two backslash characters (\\).
  8597.  
  8598.  sLevel
  8599.    Specifies the level of detail (0 or 1) to be returned in the buffer
  8600.    pointed to by pbBuffer.
  8601.  
  8602.  pbBuffer
  8603.    Points to the buffer for data returned by NetConnectionEnum. On a
  8604.    successful return, the buffer contains connection_info_X data structures,
  8605.    where X is 0 or 1, depending on the level of detail requested.
  8606.  
  8607.  cbBuffer
  8608.    Specifies the size (in bytes) of the return buffer pointed to by pbBuffer.
  8609.  
  8610.  pcEntriesRead
  8611.    Points to an unsigned short integer that specifies the number of entries
  8612.    in the return buffer pointed to by pbBuffer. This count is valid only if
  8613.    NetConnectionEnum returns NERR_Success or ERROR_MORE_DATA.
  8614.  
  8615.  pcTotalEntries
  8616.    Points to an unsigned short integer that specifies the total number of
  8617.    entries available. This count is valid only if NetConnectionEnum returns
  8618.    NERR_Success or ERROR_MORE_DATA.
  8619.  
  8620.  Return Codes
  8621.  
  8622. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  8623.  Code                              Value   Meaning
  8624.  ────────────────────────────────────────────────────────────────────────────
  8625.  NERR_Success                      0       The function encountered no
  8626.                                            errors.
  8627.  
  8628.  ERROR_ACCESS_DENIED               5       The user has insufficient
  8629.                                            privilege for this operation.
  8630.  
  8631.  ERROR_BAD_NETPATH                 53      The network path was not found.
  8632.  
  8633.  Code                              Value   Meaning
  8634.  ────────────────────────────────────────────────────────────────────────────
  8635. 
  8636.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  8637.  
  8638.  ERROR_INVALID_LEVEL               124     The level for information
  8639.                                            retrieval or setting is invalid.
  8640.  
  8641.  ERROR_MORE_DATA                   234     Additional data is available.
  8642.  
  8643.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  8644.                                            is not installed.
  8645.  
  8646.  NERR_RemoteOnly                   2106    This operation can be performed
  8647.                                            only on a server.
  8648.  
  8649.  NERR_ServerNotStarted             2114    The Server service is not
  8650.                                            started.
  8651.  
  8652.  NERR_WkstaNotStarted              2138    The Workstation service is not
  8653.                                            started.
  8654.  Code                              Value   Meaning
  8655.  ────────────────────────────────────────────────────────────────────────────
  8656.                                           started.
  8657.  
  8658.  NERR_BadTransactConfig            2141    The server is not configured for
  8659.                                            this transaction: IPC$ is not
  8660.                                            shared.
  8661.  
  8662.  NERR_NetNameNotFound              2310    The sharename does not exist.
  8663.  
  8664.  NERR_ClientNameNotFound           2312    The specified computer does not
  8665.                                            have a session with the server.
  8666.  
  8667.  NERR_InvalidComputer              2351    The specified computername is
  8668.                                            invalid.
  8669.  
  8670.  ────────────────────────────────────────────────────────────────────────────
  8671.  
  8672.  
  8673.  
  8674.  See Also
  8675.  
  8676.  For information about             See
  8677.  ────────────────────────────────────────────────────────────────────────────
  8678.  Listing all available servers     NetServerEnum
  8679.  
  8680.  Listing sessions on a server      NetSessionEnum
  8681.  
  8682.  
  8683.  
  8684.  
  8685.  
  8686.  Connection Category Example
  8687.  
  8688.    /*
  8689.       NETCONS.C -- a sample program demonstrating NetConnectionEnum.
  8690.  
  8691.       This program requires that you have admin privilege on the specified
  8692.       server.
  8693.  
  8694.          usage:  netcons [-s \\server] [-r sharename | -w \\wkstaname]
  8695.  
  8696.          where  \\server    = Name of the server. A servername must
  8697.    be
  8698.                               preceded by two backslashes (\\).
  8699.                 sharename   = Name of the shared resource as qualifier.
  8700.                 \\wkstaname = Computername used as qualifier.
  8701.  
  8702.       API                   Used to...
  8703.       =================     ==========================================
  8704.       NetConnectionEnum     List connections to a server's shared
  8705.                             resources, or list connections established
  8706.  
  8707.                             from a particular computer
  8708.  
  8709.       This code sample is provided for demonstration purposes only.
  8710.       Microsoft makes no warranty, either express or implied,
  8711.       as to its usability in any given situation.
  8712.  
  8713.    */
  8714.  
  8715.    #define     INCL_NETERRORS
  8716.    #define     INCL_NETCONNECTION
  8717.    #define     INCL_NETSHARE
  8718.    #include    <lan.h>                     // LAN Manager header files
  8719.  
  8720.    #include    <stdio.h>                   // C run-time header files
  8721.    #include    <stdlib.h>
  8722.  
  8723.    #include    "samples.h"                 // Internal routine header
  8724.    file
  8725.  
  8726.    void Usage(char *pszString);
  8727.  
  8728.    void main(int argc, char *argv[])
  8729.    {
  8730.       char *pszServerName = "";     // Can be null; default to local
  8731.    machine
  8732.       char *pszQualifier = "C$";    // Cannot be null; default to shared
  8733.    drive
  8734.       unsigned uRet;                // API return code
  8735.       unsigned short  cbBuflen;     // Buffer length
  8736.       unsigned short  cEntriesRead; // Count of entries read
  8737.       unsigned short  cTotAvail;    // Count of entries available
  8738.  
  8739.       unsigned short  fSetQualifier = 0;  // Flag; set qualifier only
  8740.    once
  8741.       int             iCount;             // Index; loop counter
  8742.       struct connection_info_1 *pBuf1, *p1;
  8743.  
  8744.       for (iCount = 1; iCount < argc; iCount++)
  8745.       {
  8746.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  8747.          {
  8748.             switch (tolower(*(argv[iCount]+1))) // Process switches
  8749.             {
  8750.                case 's':                        // -s servername
  8751.                   pszServerName = argv[++iCount];
  8752.                   break;
  8753.                case 'w':                        // -w workstation
  8754.                   if (fSetQualifier == 1)
  8755.                      Usage(argv[0]);            // Exit program
  8756.                   fSetQualifier = 1;
  8757.                   pszQualifier = argv[++iCount];
  8758.                   break;
  8759.                case 'r':                        // -r sharename
  8760.                   if (fSetQualifier == 1)
  8761.                      Usage(argv[0]);            // Exit program
  8762.                   fSetQualifier = 1;
  8763.                   pszQualifier = argv[++iCount];
  8764.                   break;
  8765.                case 'h':
  8766.                default:
  8767.                   Usage(argv[0]);               // Exit program
  8768.             }
  8769.          }
  8770.          else
  8771.             Usage(argv[0]);
  8772.       }
  8773.       printf("\nConnection Category API Example\n\n");
  8774.  
  8775.       // Initial call to determine how large a return buffer is needed.
  8776.  
  8777.       uRet = NetConnectionEnum(pszServerName,   // Servername
  8778.                                 pszQualifier,   // Qualifier
  8779.                                 1,              // Reporting level (0
  8780.    or 1)
  8781.                                 NULL,           // Return buffer
  8782.                                 0,              // Size of target buffer
  8783.                                 &cEntriesRead,  // Count of entries read
  8784.                                 &cTotAvail);    // Count of entries available
  8785.  
  8786.  
  8787.  
  8788.  
  8789.       if ((uRet != NERR_Success) && (uRet != ERROR_MORE_DATA))
  8790.       {
  8791.          printf("NetConnectionEnum returned %u\n", uRet);
  8792.          exit(1);
  8793.       }
  8794.  
  8795.       if (cTotAvail == 0)
  8796.       {
  8797.          printf("No connections with %s\n", pszQualifier);
  8798.          exit(0);
  8799.       }
  8800.  
  8801.       // Each structure contains strings UNLEN+1 and NNLEN+1 long.
  8802.       cbBuflen = cTotAvail *
  8803.                   (sizeof (struct connection_info_1) + UNLEN + NNLEN
  8804.    + 2);
  8805.       pBuf1 = (struct connection_info_1 *) SafeMalloc(cbBuflen);
  8806.       p1 = pBuf1;         // Save start of memory block for cleanup
  8807.  
  8808.       uRet = NetConnectionEnum(pszServerName,     // Servername
  8809.                                pszQualifier,      // Qualifier
  8810.                                1,                 // Reporting level
  8811.    (0 or 1)
  8812.                                (char far *)pBuf1, // Target buffer for
  8813.    info
  8814.                                cbBuflen,          // Size of target buffer
  8815.                                &cEntriesRead,     // Count of entries
  8816.    read
  8817.                                &cTotAvail);       // Count of entries
  8818.    available
  8819.  
  8820.       printf("NetConnectionEnum returned %u \n", uRet);
  8821.  
  8822.  
  8823.       if (uRet != NERR_Success)
  8824.          exit(1);             // Exit if error occurred
  8825.  
  8826.       for (iCount = 0; iCount < (int) cEntriesRead; iCount++)
  8827.       {
  8828.          printf("Connection id number %hu\n", pBuf1->coni1_id);
  8829.          printf(" connection type          :  %hu  ", pBuf1->coni1_type);
  8830.          switch (pBuf1->coni1_type)
  8831.          {
  8832.             case STYPE_DISKTREE:
  8833.                printf("Disk Connection\n");
  8834.                break;
  8835.             case STYPE_PRINTQ:
  8836.                printf("Printer Queue Connection\n");
  8837.                break;
  8838.             case STYPE_DEVICE:
  8839.                printf("Character Device Connection\n");
  8840.                break;
  8841.  
  8842.              case STYPE_IPC:
  8843.                printf("IPC Connection\n");
  8844.                break;
  8845.              default:
  8846.                printf("Unknown Connection Type\n");
  8847.                break;
  8848.          }
  8849.          printf(" open files on connection :  %hu\n",
  8850.  pBuf1->coni1_num_opens);
  8851.          printf(" users on connection      :  %hu\n",
  8852.  pBuf1->coni1_num_users);
  8853.          printf(" seconds since established:  %lu\n", pBuf1->coni1_time);
  8854.  
  8855.          /*
  8856.           * Print the name of the user or computer that made the connection.
  8857.           * If server has share-level security, the name is a username.
  8858.           * If server has user-level security, the name is a computername.
  8859.           */
  8860.  
  8861.          printf(" connection user name     :  %s\n", pBuf1->coni1_username);
  8862.  
  8863.          /*
  8864.           * Print the network name, the inverse of the qualifier.
  8865.           * If qualifier is a sharename, netname is a computername.
  8866.           * If qualifier is a computername, netname is a username.
  8867.           */
  8868.  
  8869.          printf(" connection network name  :  %s\n", pBuf1->coni1_netname);
  8870.  
  8871.          pBuf1++;                          // Increment the record pointer
  8872.       }
  8873.       printf("%hu out of %hu entries read\n", cEntriesRead, cTotAvail);
  8874.  
  8875.       free(p1);
  8876.       exit(0);
  8877.    }
  8878.  
  8879.    void Usage(char *pszString)
  8880.    {
  8881.       fprintf(stderr, "Usage: %s [-s \\\\server]", pszString);
  8882.       fprintf(stderr, " [-r sharename | -w \\\\wkstaname]\n");
  8883.       exit(1);
  8884.    }
  8885.  
  8886.  
  8887.  
  8888.  
  8889.  
  8890.  
  8891.  
  8892.  Domain Category
  8893.  
  8894.  Domain API functions retrieve information about a domain. They require that
  8895.  the Workstation service be started. NetLogonEnum also requires that the
  8896.  Netlogon service be started on the specified server.
  8897.  
  8898.  The Domain category functions, datatypes, structures, and constants are
  8899.  defined in the NETCONS.H, NETERR.H, and ACCESS.H header files. A source
  8900.  program can access these definitions by defining the constants
  8901.  INCL_NETERRORS and INCL_NETDOMAIN, and including the master header file,
  8902.  LAN.H. For more information about these definitions,  see the "Example"
  8903.  section, later in this category.
  8904.  
  8905.  These are the Domain API functions:
  8906.  
  8907.  
  8908.    ■   NetGetDCName
  8909.  
  8910.    ■   NetLogonEnum
  8911.  
  8912.  
  8913.  
  8914.  Description
  8915.  
  8916.  NetGetDCName retrieves the name of the domain controller. NetLogonEnum
  8917.  retrieves information about the users who are logged on in a domain.
  8918.  
  8919.  
  8920.  Data Structures
  8921.  
  8922.  NetGetDCName returns the domain name in the form of an ASCIIZ string.
  8923.  NetLogonEnum uses the user_logon_info_X data structure, where X is 0 or 2,
  8924.  depending on the level of detail specified.
  8925.  
  8926.  
  8927.  Logon Information (Level 0)
  8928.  
  8929.  The user_logon_info_0 data structure has this format:
  8930.  
  8931.    struct user_logon_info_0 {
  8932.       char  usrlog0_eff_name[UNLEN+1];
  8933.       char  usrlog0_pad_1;
  8934.    };
  8935.  
  8936.  where
  8937.  
  8938.  usrlog0_eff_name
  8939.    Specifies the name of the user. The constant UNLEN is defined in the
  8940.    NETCONS.H header file.
  8941.  
  8942.  usrlog0_pad_1
  8943.    Aligns the next data structure element on a word boundary.
  8944.  
  8945.  
  8946.  Logon Information (Level 2)
  8947.  
  8948.  The user_logon_info_2 data structure has this format:
  8949.  
  8950.    struct user_logon_info_2 {
  8951.        char           usrlog2_eff_name[UNLEN+1];
  8952.        char           usrlog2_pad_1;
  8953.        char far *     usrlog2_computer;
  8954.        char far *     usrlog2_full_name;
  8955.        char far *     usrlog2_usrcomment;
  8956.        unsigned long  usrlog2_logon_time;
  8957.    };
  8958.  
  8959.  where
  8960.  
  8961.  usrlog2_eff_name
  8962.    Specifies the name of the user. The constant UNLEN is defined in the
  8963.    NETCONS.H header file.
  8964.  
  8965.  usrlog2_pad_1
  8966.    Aligns the next data structure element on a word boundary.
  8967.  
  8968.  usrlog2_computer
  8969.    Points to an ASCIIZ string that contains the name of the computer where
  8970.    the user logged on.
  8971.  
  8972.  usrlog2_full_name
  8973.    Points to an ASCIIZ string that contains the full name of the user.
  8974.  
  8975.  usrlog2_usrcomment
  8976.    Points to the ASCIIZ string that contains the user's comment.
  8977.  
  8978.  usrlog2_logon_time
  8979.    Specifies the time the user logged on to the network. This value is stored
  8980.    as the number of seconds elapsed since 00:00:00, January 1, 1970. A value
  8981.    of -1 indicates that the logon time is not available.
  8982.  
  8983.  
  8984.  NetGetDCName
  8985.  ────────────────────────────────────────────────────────────────────────────
  8986.  
  8987.  NetGetDCName returns the name of a domain controller for a specified domain.
  8988.  If no domain name or servername is supplied, NetGetDCName returns the name
  8989.  of the domain controller for the local workstation's primary domain.
  8990.  
  8991.  
  8992.  Operating Systems Supported
  8993.  
  8994.  
  8995.    ■   MS OS/2 version 1.2, local and remote
  8996.  
  8997.    ■   MS OS/2 version 1.1, local and remote
  8998.  
  8999.    ■   MS-DOS, local and remote
  9000.  
  9001.  
  9002.  
  9003.  Privilege Level
  9004.  
  9005.  No special privilege level is required to successfully execute NetGetDCName.
  9006.  
  9007.  
  9008.  
  9009.  Syntax
  9010.  
  9011.    #define INCL_NETDOMAIN
  9012.    #define INCL_NETERRORS
  9013.    #include <lan.h>
  9014.  
  9015.    API_FUNCTION
  9016.    NetGetDCName (const char far *  pszServer,
  9017.                  const char far *  pszDomain,
  9018.                  char far *        pbBuffer,
  9019.                  unsigned short    cbBuffer
  9020.                 );
  9021.  
  9022.  where
  9023.  
  9024.  pszServer
  9025.    Points to an ASCIIZ string that contains the name of the server on which
  9026.    to execute NetGetDCName. A null pointer or null string specifies the local
  9027.    computer.
  9028.  
  9029.  pszDomain
  9030.    Points to an ASCIIZ string that contains the name of the domain. A null
  9031.    pointer or null string indicates that the name of the domain controller
  9032.    for the primary domain is to be returned.
  9033.  
  9034.  pbBuffer
  9035.    Points to the buffer in which to return the name of the domain controller.
  9036.  
  9037.  cbBuffer
  9038.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  9039.  
  9040.  Return Codes
  9041.  
  9042. ╓┌───────────────────────┌───────┌───────────────────────────────────────────╖
  9043.  Code                    Value   Meaning
  9044.  ────────────────────────────────────────────────────────────────────────────
  9045.  NERR_Success            0       The function encountered no errors.
  9046.  
  9047.  ERROR_ACCESS_DENIED     5       The user has insufficient privilege for
  9048.                                  this operation.
  9049.  
  9050.  ERROR_BAD_NETPATH       53      The network path was not found.
  9051.  
  9052.  NERR_NetNotStarted      2102    The LAN Manager NETWKSTA driver is not
  9053.  Code                    Value   Meaning
  9054.  ────────────────────────────────────────────────────────────────────────────
  9055. NERR_NetNotStarted      2102    The LAN Manager NETWKSTA driver is not
  9056.                                  installed.
  9057.  
  9058.  NERR_BufTooSmall        2123    The supplied buffer is too small.
  9059.  
  9060.  NERR_WkstaNotStarted    2138    The Workstation service is not started.
  9061.  
  9062.  NERR_BadTransactConfig  2141    The server is not configured for this
  9063.                                  transaction: IPC$ is not shared.
  9064.  
  9065.  NERR_InvalidAPI         2142    The requested API is not supported on the
  9066.                                  remote server.
  9067.  
  9068.  NERR_InvalidComputer    2351    The specified computername is invalid.
  9069.  
  9070.  NERR_DCNotFound         2453    The domain controller for this domain was
  9071.                                  not found.
  9072.  
  9073.  ────────────────────────────────────────────────────────────────────────────
  9074.  Code                    Value   Meaning
  9075.  ────────────────────────────────────────────────────────────────────────────
  9076. ────────────────────────────────────────────────────────────────────────────
  9077.  
  9078.  
  9079.  
  9080.  
  9081.  Remarks
  9082.  
  9083.  If the return code is NERR_Success, the buffer contains an ASCIIZ string
  9084.  that contains the name of the domain controller in UNC format, for example:
  9085.  
  9086.  
  9087.    \\SERVER
  9088.  
  9089.  NetGetDCName can require a large amount of network time and can affect the
  9090.  performance of applications that call it often. Because the domain
  9091.  controller of a domain can change, you should not assume that the domain
  9092.  controller remains unchanged for long periods. Applications that require the
  9093.  name of the domain controller should call NetGetDCName when necessary,
  9094.  unless performance tests indicate that these calls cause poor performance.
  9095.  You can assume only that the domain controller remains unchanged for short
  9096.  periods.
  9097.  
  9098.  
  9099.  NetLogonEnum
  9100.  ────────────────────────────────────────────────────────────────────────────
  9101.  
  9102.  NetLogonEnum supplies information about users who are logged on in a domain.
  9103.  
  9104.  
  9105.  
  9106.  Operating Systems Supported
  9107.  
  9108.  
  9109.    ■   MS OS/2 version 1.2, local and remote
  9110.  
  9111.    ■   MS OS/2 version 1.1, remote only
  9112.  
  9113.    ■   MS-DOS, remote only
  9114.  
  9115.  
  9116.  
  9117.  Privilege Level
  9118.  
  9119.  No special privilege level is required to successfully execute NetLogonEnum.
  9120.  
  9121.  
  9122.  
  9123.  Syntax
  9124.  
  9125.    #define INCL_NETDOMAIN
  9126.    #define INCL_NETERRORS
  9127.    #include <lan.h>
  9128.  
  9129.    API_FUNCTION
  9130.    NetLogonEnum (const char far *      pszServer,
  9131.                  short                 sLevel,
  9132.                  char far *            pbBuffer,
  9133.                  unsigned short        cbBuffer,
  9134.                  unsigned short far *  pcEntriesRead,
  9135.                  unsigned short far *  pcTotalAvail
  9136.                 );
  9137.  
  9138.  where
  9139.  
  9140.  pszServer
  9141.    Points to an ASCIIZ string that contains the name of the server on which
  9142.    to execute NetLogonEnum. A null pointer or null string specifies the local
  9143.    computer.
  9144.  
  9145.  sLevel
  9146.    Specifies the level of detail (0 or 2) requested.
  9147.  
  9148.  pbBuffer
  9149.    Points to the buffer in which to store the returned data. On a successful
  9150.    return, the buffer contains a sequence of user_logon_info_X data
  9151.    structures, where X is 0 or 2, depending on the level of detail requested.
  9152.  
  9153.  cbBuffer
  9154.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  9155.  
  9156.  pcEntriesRead
  9157.    Points to an unsigned short integer in which a count of the number of
  9158.    users listed in the buffer is returned. This count is valid only if
  9159.    NetLogonEnum returns NERR_Success or ERROR_MORE_DATA.
  9160.  
  9161.  pcTotalAvail
  9162.    Points to an unsigned short integer in which a count of the total number
  9163.    of logon data structures available is returned. This count is valid only
  9164.    if NetLogonEnum returns NERR_Success or ERROR_MORE_DATA.
  9165.  
  9166.  Return Codes
  9167.  
  9168. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  9169.  Code                              Value   Meaning
  9170.  ────────────────────────────────────────────────────────────────────────────
  9171.  NERR_Success                      0       The function encountered no
  9172.                                            errors.
  9173.  
  9174.  ERROR_ACCESS_DENIED               5       The user has insufficient
  9175.                                            privilege for this operation.
  9176.  
  9177.  ERROR_BAD_NETPATH                 53      The network path was not found.
  9178.  
  9179.  Code                              Value   Meaning
  9180.  ────────────────────────────────────────────────────────────────────────────
  9181. 
  9182.  ERROR_INVALID_LEVEL               124     The level for information
  9183.                                            retrieval or setting is invalid.
  9184.  
  9185.  ERROR_MORE_DATA                   234     Additional data is available.
  9186.  
  9187.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  9188.                                            is not installed.
  9189.  
  9190.  NERR_RemoteOnly                   2106    This operation can be performed
  9191.                                            only on a server.
  9192.  
  9193.  NERR_WkstaNotStarted              2138    The Workstation service is not
  9194.                                            started.
  9195.  
  9196.  NERR_BadTransactConfig            2141    The server is not configured for
  9197.                                            this transaction: IPC$ is not
  9198.                                            shared.
  9199.  
  9200.  Code                              Value   Meaning
  9201.  ────────────────────────────────────────────────────────────────────────────
  9202. 
  9203.  NERR_InvalidAPI                   2142    The requested API is not
  9204.                                            supported on the remote server.
  9205.  
  9206.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  9207.                                            user accounts database file,
  9208.                                            NET.ACC. This file should be in
  9209.                                            the ACCOUNTS subdirectory of the
  9210.                                            LANMAN directory.
  9211.  
  9212.  NERR_ACFNotLoaded                 2227    The user accounts database is
  9213.                                            not active. This database must
  9214.                                            be active for the command to run.
  9215.  
  9216.  
  9217.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  9218.  
  9219.  NERR_InvalidDatabase              2247    The user accounts database file,
  9220.                                            NET.ACC, is corrupted.
  9221.  Code                              Value   Meaning
  9222.  ────────────────────────────────────────────────────────────────────────────
  9223.                                           NET.ACC, is corrupted.
  9224.  
  9225.  NERR_InvalidComputer              2351    The specified computername is
  9226.                                            invalid.
  9227.  
  9228.  NERR_NetlogonNotStarted           2455    The Netlogon service is not
  9229.                                            running.
  9230.  
  9231.  ────────────────────────────────────────────────────────────────────────────
  9232.  
  9233.  
  9234.  
  9235.  
  9236.  Remarks
  9237.  
  9238.  NetLogonEnumcan return more than one entry for a particular username, if
  9239.  that user is logged on at more than one workstation.
  9240.  
  9241.  
  9242.  
  9243.  Domain Category Example
  9244.  
  9245.    /*
  9246.       NETDOM.C -- a sample program demonstrating the Domain API functions.
  9247.  
  9248.       This program requires that the Netlogon service be started on
  9249.       the specified server.
  9250.  
  9251.          usage:  netdom [-s \\server] [-d domain]
  9252.  
  9253.          where  \\server = Name of the server. A servername must
  9254.    be preceded
  9255.                            by two backslashes (\\).
  9256.                 domain   = Name of the domain.
  9257.  
  9258.       API              Used to...
  9259.       ============     ================================================
  9260.       NetGetDCName     Find the domain controller for a given domain
  9261.       NetLogonEnum     Get details about users at the domain controller
  9262.  
  9263.       This code sample is provided for demonstration purposes only.
  9264.       Microsoft makes no warranty, either express or implied,
  9265.       as to its usability in any given situation.
  9266.    */
  9267.  
  9268.    #define     INCL_NETDOMAIN
  9269.    #define     INCL_NETERRORS
  9270.    #include    <lan.h>        // LAN Manager header files
  9271.  
  9272.    #include    <stdio.h>      // C run-time header files
  9273.    #include    <stdlib.h>
  9274.    #include    <string.h>
  9275.    #include    <time.h>
  9276.  
  9277.    #include    "samples.h"    // Internal routine header file
  9278.  
  9279.    #define     BIG_BUFF       32768
  9280.  
  9281.    void Usage (char * pszProgram);
  9282.  
  9283.    void main(int argc, char *argv[])
  9284.    {
  9285.       char *         pszServer = "";            // Servername
  9286.       char *         pszDomain = "";            // Domain name
  9287.       char           pszDCName[UNCLEN+1];       // Name of domain controller
  9288.       int            iCount;                    // Index counter
  9289.       unsigned short cRead;                     // Count of entries read
  9290.       unsigned short cAvail;                    // Count of entries available
  9291.       unsigned short cbBuffer;                  // Size of buffer, in
  9292.    bytes
  9293.       API_RET_TYPE   uReturnCode;               // API return code
  9294.       struct user_logon_info_2 *pBuffer;        // Data buffer
  9295.  
  9296.       for (iCount = 1; iCount < argc; iCount++)
  9297.       {
  9298.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  9299.          {
  9300.             switch (tolower(*(argv[iCount]+1))) // Process switches
  9301.             {
  9302.                case 's':                        // -s servername
  9303.                   pszServer = argv[++iCount];
  9304.                   break;
  9305.                case 'd':                        // -d domain
  9306.                   pszDomain = argv[++iCount];
  9307.                   break;
  9308.                case 'h':
  9309.                default:
  9310.                   Usage(argv[0]);
  9311.             }
  9312.          }
  9313.          else
  9314.             Usage(argv[0]);
  9315.       }
  9316.  
  9317.    //========================================================================
  9318.    //  NetGetDCName
  9319.    //
  9320.    //  This API returns the name of the server that is the domain
  9321.    //  controller in the specified domain. If no domain name is given,
  9322.    //  the name of the primary domain controller is returned.
  9323.    //========================================================================
  9324.  
  9325.       cbBuffer = sizeof(pszDCName);
  9326.       uReturnCode = NetGetDCName(pszServer,     // Server; NULL means
  9327.    local
  9328.                                  pszDomain,     // Domain; NULL means
  9329.    primary
  9330.                                  pszDCName,     // Return buffer
  9331.                                  cbBuffer);     // Size of buffer
  9332.  
  9333.       printf("NetGetDCName returned %u\n", uReturnCode);
  9334.  
  9335.       if (uReturnCode == NERR_Success)
  9336.          printf("   the domain controller is %s\n", pszDCName);
  9337.       else if (uReturnCode == NERR_DCNotFound)
  9338.       {
  9339.          printf("   domain controller not found\n");
  9340.       }
  9341.  
  9342.    //========================================================================
  9343.    //  NetLogonEnum
  9344.    //
  9345.    //  This API lists the logon names, logon times, and machines the
  9346.    users
  9347.    //  logged on from.
  9348.    //
  9349.    //  Note: In the printf() statement, the computername is pointed to
  9350.    by
  9351.    //  a far pointer and so is formatted with %Fs. NetLogonEnum will
  9352.    NOT list
  9353.    //  all the users logged on in a domain. It lists only those users
  9354.    logged
  9355.    //  on to the specified server.
  9356.    //========================================================================
  9357.  
  9358.       cbBuffer = BIG_BUFF;                      // Can be up to 64K
  9359.       pBuffer = (struct user_logon_info_2 *) SafeMalloc(cbBuffer);
  9360.  
  9361.       uReturnCode = NetLogonEnum(pszDCName,     // Servername
  9362.                           2,                    // Level (0 or 2)
  9363.                           (char far *)pBuffer,  // Data returned here
  9364.                           cbBuffer,             // Size of supplied buffer
  9365.                           &cRead,               // Count of entries read
  9366.                           &cAvail);             // Count of entries available
  9367.  
  9368.       printf("NetLogonEnum for \"%s\" returned %u\n",
  9369.                      pszDCName, uReturnCode);
  9370.  
  9371.       if (uReturnCode == NERR_Success || uReturnCode == ERROR_MORE_DATA)
  9372.       {
  9373.          putenv("TZ=GMT0");         // Allow ctime() to report local
  9374.    time
  9375.          for (iCount = 0; iCount < (int) cRead; iCount++)
  9376.          {
  9377.             printf(" %15s on machine %-15Fs  Logon: %s",
  9378.                         pBuffer->usrlog2_eff_name,
  9379.                         pBuffer->usrlog2_computer,
  9380.                         ctime(&pBuffer->usrlog2_logon_time));
  9381.             pBuffer++;
  9382.          }
  9383.          printf("%hu out of %hu entries returned\n", cRead, cAvail);
  9384.       }
  9385.       free(pBuffer);
  9386.       exit(0);
  9387.    }
  9388.  
  9389.    void Usage (char * pszProgram)
  9390.    {
  9391.       fprintf(stderr, "Usage: %s [-s \\\\server] [-d domain]\n", pszProgram);
  9392.       exit(1);
  9393.    }
  9394.  
  9395.  
  9396.  
  9397.  
  9398.  
  9399.  Error Logging Category
  9400.  
  9401.  Error Logging API functions control the error log. All Error Logging API
  9402.  functions require that the NETWKSTA device driver be installed.
  9403.  NetErrorLogWrite also requires that the Workstation service be started.
  9404.  
  9405.  The Error Logging category functions, datatypes, structures, and constants
  9406.  are defined in the NETCONS.H, NETERR.H, and ERRLOG.H header files. A source
  9407.  program  can access these definitions by defining the constants
  9408.  INCL_NETERRORS and INCL_NETERRORLOG, and including the master header file,
  9409.  LAN.H. For more information about these definitions, see the "Example"
  9410.  section, later in this category.
  9411.  
  9412.  These are the Error Logging API functions:
  9413.  
  9414.  
  9415.    ■   NetErrorLogClear
  9416.  
  9417.    ■   NetErrorLogRead
  9418.  
  9419.    ■   NetErrorLogWrite
  9420.  
  9421.  
  9422.  
  9423.  Description
  9424.  
  9425.  The error log is a file that stores error messages (in binary format). It
  9426.  contains information about LAN Manager software internal errors, MS OS/2 and
  9427.  MS-DOS internal errors, and network service errors.
  9428.  
  9429.  The default error log is NET.ERR in the LAN Manager LOGS directory. All
  9430.  Error Logging functions operate on this file.
  9431.  
  9432.  NetErrorLogWrite writes an entry to the error log; NetErrorLogRead reads
  9433.  entries from the error log; and NetErrorLogClear clears the error log and,
  9434.  optionally, saves the entries in a backup file.
  9435.  
  9436.  To set a maximum size for the error log, use one of these methods:
  9437.  
  9438.  
  9439.    ■   Use the net config command with the /maxerrorlog option. For more
  9440.        information, see your LAN Manager user's manual(s).
  9441.  
  9442.    ■   Set the maxerrorlog entry in the [workstation] section of the
  9443.        LANMAN.INI file. For a description of the LANMAN.INI file, see your
  9444.        LAN Manager administrator's manual(s).
  9445.  
  9446.    ■   Call the NetWkstaSetInfo function with the sParmNum parameter set to
  9447.        WKSTA_ERRLOGSZ_PARMNUM.
  9448.  
  9449.  
  9450.  
  9451.  Data Structure
  9452.  
  9453.  NetErrorLogRead and NetErrorLogWrite use the error_log data structure to
  9454.  read entries from and write entries to the error log. An entry consists of a
  9455.  fixed-length data structure. The data structure can be followed by ASCIIZ
  9456.  strings (el_text) that describe the error message, and a block of raw data
  9457.  (el_data) related to the cause of the error. Because of the variable lengths
  9458.  and structures of the el_data and el_text portions of the entry, only the
  9459.  fixed-length data structure is defined in the error_log data structure.
  9460.  
  9461.  The error log entry has the following format:
  9462.  
  9463.    struct error_log {
  9464.        unsigned short  el_len;
  9465.        unsigned short  el_reserved;
  9466.        unsigned long   el_time;
  9467.        unsigned short  el_error;
  9468.        char            el_name[SNLEN+1];
  9469.        unsigned short  el_data_offset;
  9470.        unsigned short  el_nstrings;
  9471.    };
  9472.  
  9473.    /*
  9474.     *   Variable-length data specific to the error. The
  9475.     *   data consists of message strings and raw data.
  9476.     *   The number of bytes of data is equivalent to:
  9477.     *   el_len - el_data_offset - sizeof(unsigned short);
  9478.     */
  9479.  
  9480.        char el_text[];     /* Error messages */
  9481.        char el_data[];     /* Raw data       */
  9482.  
  9483.        unsigned short el_len;
  9484.  
  9485.  where
  9486.  
  9487.  el_len
  9488.    Specifies the length of the error log entry (in bytes). The el_len element
  9489.    is included both at the beginning and at the end of the entry to enable
  9490.    both forward and backward scanning of the log.
  9491.  
  9492.  el_reserved
  9493.    Reserved; must be 0.
  9494.  
  9495.  el_time
  9496.    Specifies the time that the service or application specified by el_name
  9497.    submitted the error entry. The value is stored as the number of seconds
  9498.    elapsed since 00:00:00, January 1, 1970.
  9499.  
  9500.  el_error
  9501.    Specifies the error code for the error. You can use el_error to obtain an
  9502.    error message from the NET.MSG file.
  9503.  
  9504.  el_name
  9505.    Contains an ASCIIZ string that specifies the name of the network service
  9506.    or application that returned the error entry. The constant SNLEN is
  9507.    defined in the NETCONS.H header file.
  9508.  
  9509.  el_data_offset
  9510.    Specifies the byte offset from the beginning of the error log entry to the
  9511.    start of its variable-length portion (el_text).
  9512.  
  9513.  el_nstrings
  9514.    Specifies how many ASCIIZ strings the el_text portion of the entry
  9515.    contains.
  9516.  
  9517.  el_text
  9518.    Points to ASCIIZ strings that describe the error.
  9519.  
  9520.  el_data
  9521.    Points to the raw data associated with the error.
  9522.  
  9523.  
  9524.  Error Log Codes
  9525.  
  9526.  The ERRLOG.H header file defines a number of standard error codes that can
  9527.  be written to the error log. Applications can use these values or they can
  9528.  define their own.
  9529.  
  9530.  The defined codes allow string data and raw data to be inserted along with
  9531.  the error code. The string data is represented in the table by a number
  9532.  preceded by a percent sign (%). For example, %1 is the first string. The
  9533.  string entries go in the el_text element of the data buffer. The raw data
  9534.  goes in the el_data element of the data buffer. For more information, see
  9535.  the "Example" section, later in this category.
  9536.  
  9537.  The ERRLOG.H header file defines the code, values, and meanings for these
  9538.  LAN Manager error codes:
  9539.  
  9540. ╓┌─────────────────────────────────┌──────┌──────────────────────────────────╖
  9541.  Code                              Value  Meaning
  9542.  ────────────────────────────────────────────────────────────────────────────
  9543.  NELOG_Internal_Error              3100   The operation failed because a
  9544.                                           network software error occurred.
  9545.  
  9546.  NELOG_Resource_Shortage           3101   The system ran out of a resource
  9547.                                           controlled by the %1 option.
  9548.  
  9549.  NELOG_Unable_To_Lock_Segment      3102   The service failed to obtain a
  9550.                                           long-term lock on the  segment
  9551.                                           for NCBs. The error code is the
  9552.                                           data.
  9553.  
  9554.  NELOG_Unable_To_Unlock_Segment    3103   The service failed to release the
  9555.                                           long-term lock on the segment for
  9556.                                           NCBs. The error code is the data.
  9557.  Code                              Value  Meaning
  9558.  ────────────────────────────────────────────────────────────────────────────
  9559.                                          NCBs. The error code is the data.
  9560.  
  9561.  
  9562.  NELOG_Uninstall_Service           3104   An error stopped service %1.
  9563.                                           The error code from
  9564.                                           NetServiceControl is the data.
  9565.  
  9566.  NELOG_Init_Exec_Fail              3105   Initialization failed because of
  9567.                                           an MS OS/2 exec failure on path
  9568.                                           %1. The MS OS/2 error code is the
  9569.                                           data.
  9570.  
  9571.  NELOG_Ncb_Error                   3106   An unexpected NCB was received.
  9572.                                           The NCB is the data.
  9573.  
  9574.  NELOG_Net_Not_Started             3107   The network is not started.
  9575.  
  9576.  NELOG_Ioctl_Error                 3108   A DosDevIOCtl or DosFSCtl call to
  9577.                                           NETWKSTA.SYS failed.
  9578.  Code                              Value  Meaning
  9579.  ────────────────────────────────────────────────────────────────────────────
  9580.                                          NETWKSTA.SYS failed.
  9581.                                           The data shown is in this format:
  9582.                                           dword Approximate CS:IP of   call
  9583.                                           to IOCtl or FSCtl
  9584.                                           word Error code
  9585.                                           word IOCtl or FSCtl number
  9586.  
  9587.  NELOG_System_Semaphore            3109   Unable to create or open system
  9588.                                           semaphore %1. The error code is
  9589.                                           the data.
  9590.  
  9591.  NELOG_Init_OpenCreate_Err         3110   Initialization failed because of
  9592.                                           an open/create error on the file
  9593.                                           %1. The MS OS/2 error code is the
  9594.                                           data.
  9595.  
  9596.  NELOG_NetBios                     3111   An unexpected NetBIOS error
  9597.                                           occurred. The error code is the
  9598.                                           data.
  9599.  Code                              Value  Meaning
  9600.  ────────────────────────────────────────────────────────────────────────────
  9601.                                          data.
  9602.  
  9603.  NELOG_SMB_Illegal                 3112   An illegal SMB was received. The
  9604.                                           SMB is the data.
  9605.  
  9606.  NELOG_Service_Fail                3113   Initialization failed because the
  9607.                                           requested service %1 could not be
  9608.                                           started.
  9609.  
  9610.  NELOG_Entries_Lost                3114   Some entries in the error log
  9611.                                           were lost because of a buffer
  9612.                                           overflow.
  9613.  
  9614.  NELOG_Init_Seg_Overflow           3120   Initialization parameters that
  9615.                                           control resource use other than
  9616.                                           network buffers are sized so that
  9617.                                           too much memory is needed.
  9618.  
  9619.  NELOG_Srv_No_Mem_Grow             3121   The server cannot increase the
  9620.  Code                              Value  Meaning
  9621.  ────────────────────────────────────────────────────────────────────────────
  9622. NELOG_Srv_No_Mem_Grow             3121   The server cannot increase the
  9623.                                           size of a memory segment.
  9624.  
  9625.  NELOG_Access_File_Bad             3122   Initialization failed because
  9626.                                           account file: %1 is either
  9627.                                           incorrect or not present.
  9628.  
  9629.  NELOG_Srvnet_Not_Started          3123   Initialization failed because
  9630.                                           network: %1 was not started.
  9631.  
  9632.  NELOG_Init_Chardev_Err            3124   The server failed to start.
  9633.                                           Either all three character device
  9634.                                           parameters must be 0 or all three
  9635.                                           must be nonzero.
  9636.  
  9637.  NELOG_Remote_API                  3125   A remote API request was halted
  9638.                                           due to the following invalid
  9639.                                           description string: %1.
  9640.  
  9641.  Code                              Value  Meaning
  9642.  ────────────────────────────────────────────────────────────────────────────
  9643. 
  9644.  NELOG_Ncb_TooManyErr              3126   The network %1 ran out of NCBs.
  9645.                                           You may need to increase NCBs for
  9646.                                           this network. The following
  9647.                                           information includes the number
  9648.                                           of NCBs submitted by the server
  9649.                                           when this error occurred:
  9650.  
  9651.  NELOG_Mailslot_err                3127   The server cannot create the %1
  9652.                                           mailslot needed to send the
  9653.                                           ReleaseMemory alert message. The
  9654.                                           error received is:
  9655.  
  9656.  NELOG_ReleaseMem_Alert            3128   The server failed to register for
  9657.                                           the RELEASEMEMORY alert, with
  9658.                                           recipient %1. The error code from
  9659.                                           NetAlertStart is the data.
  9660.  
  9661.  NELOG_AT_cannot_write             3129   The server cannot update the AT
  9662.  Code                              Value  Meaning
  9663.  ────────────────────────────────────────────────────────────────────────────
  9664. NELOG_AT_cannot_write             3129   The server cannot update the AT
  9665.                                           schedule file. The file is
  9666.                                           corrupt.
  9667.  
  9668.  NELOG_Cant_Make_Msg_File          3130   The server encountered an error.
  9669.                                           The error code is the data.
  9670.  
  9671.  NELOG_Exec_Netservr_NoMem         3131   Initialization failed because of
  9672.                                           an MS OS/2 exec failure on path
  9673.                                           %1. There is not enough memory to
  9674.                                           start the process. The MS OS/2
  9675.                                           error code is the data.
  9676.  
  9677.  NELOG_Server_Lock_Failure         3132   Long-term lock of server buffers
  9678.                                           failed. Check swap disk free
  9679.                                           space and reboot system to start
  9680.                                           server.
  9681.  
  9682.  NELOG_Msg_Shutdown                3140   The service has stopped due
  9683.  Code                              Value  Meaning
  9684.  ────────────────────────────────────────────────────────────────────────────
  9685. NELOG_Msg_Shutdown                3140   The service has stopped due
  9686.                                           to repeated consecutive
  9687.                                           occurrences of an NCB error. The
  9688.                                           last bad NCB follows in raw data.
  9689.  
  9690.  NELOG_Msg_Sem_Shutdown            3141   Shutdown has occurred due to a
  9691.                                           lock on the shared data segment.
  9692.  
  9693.  NELOG_Msg_Log_Err                 3150   A file system error occurred
  9694.                                           while opening or writing to the
  9695.                                           system message log file, %1.
  9696.                                           Message logging has been switched
  9697.                                           off due to the error. The error
  9698.                                           code is the data.
  9699.  
  9700.  NELOG_VIO_POPUP_ERR               3151   Unable to display message popup
  9701.                                           due to an MS OS/2 VIO call error.
  9702.                                           The error code is the data.
  9703.  
  9704.  Code                              Value  Meaning
  9705.  ────────────────────────────────────────────────────────────────────────────
  9706. 
  9707.  NELOG_Msg_Unexpected_SMB_Type     3152   An illegal SMB was received. The
  9708.                                           SMB is the data.
  9709.  
  9710.  NELOG_Wksta_Infoseg               3160   The workstation information
  9711.                                           segment is bigger than 64K bytes.
  9712.                                           The size follows, in dword
  9713.                                           format:
  9714.  
  9715.  NELOG_Wksta_Compname              3161   The workstation was unable to get
  9716.                                           the name/number of the
  9717.                                           computername.
  9718.  
  9719.  NELOG_Wksta_BiosThreadFailure     3162   The workstation could not
  9720.                                           initialize the async NetBIOS
  9721.                                           thread. The error code is the
  9722.                                           data.
  9723.  
  9724.  NELOG_Wksta_IniSeg                3163   The workstation could not open
  9725.  Code                              Value  Meaning
  9726.  ────────────────────────────────────────────────────────────────────────────
  9727. NELOG_Wksta_IniSeg                3163   The workstation could not open
  9728.                                           the initial shared segment. The
  9729.                                           error code is the data.
  9730.  
  9731.  NELOG_Wksta_HostTab_Full          3164   The workstation host table is
  9732.                                           full.
  9733.  
  9734.  NELOG_Wksta_Bad_Mailslot_SMB      3165   A bad mailslot SMB was received.
  9735.                                           The SMB is the data.
  9736.  
  9737.  NELOG_Wksta_UASInit               3166   The workstation encountered an
  9738.                                           error while trying to start the
  9739.                                           UAS. The error code is the data.
  9740.  
  9741.  NELOG_Wksta_SSIRelogon            3167   The workstation encountered an
  9742.                                           error while responding to an SSI
  9743.                                           revalidation request. The
  9744.                                           function code and the error codes
  9745.                                           are the data.
  9746.  Code                              Value  Meaning
  9747.  ────────────────────────────────────────────────────────────────────────────
  9748.                                          are the data.
  9749.  
  9750.  NELOG_Build_Name                  3170   The Alerter service had a problem
  9751.                                           creating the list of alert
  9752.                                           recipients. The error code is %1.
  9753.  
  9754.  NELOG_Name_Expansion              3171   There was an error expanding %1
  9755.                                           as a groupname. Try splitting the
  9756.                                           group into two or more smaller
  9757.                                           groups.
  9758.  
  9759.  NELOG_Message_Send                3172   There was an error sending %2 the
  9760.                                           alert message - (%3). The error
  9761.                                           code is %1.
  9762.  
  9763.  NELOG_Mail_Slt_Err                3173   There was an error in creating or
  9764.                                           reading the alerter mailslot. The
  9765.                                           error code is %1.
  9766.  
  9767.  Code                              Value  Meaning
  9768.  ────────────────────────────────────────────────────────────────────────────
  9769. 
  9770.  NELOG_AT_cannot_read              3174   The server could not read the AT
  9771.                                           schedule file.
  9772.  
  9773.  NELOG_AT_sched_err                3175   The server found an invalid AT
  9774.                                           schedule record.
  9775.  
  9776.  NELOG_AT_schedule_file_created    3176   The server could not find an AT
  9777.                                           schedule file so it created one.
  9778.  
  9779.  NELOG_Srvnet_NB_Open              3177   The server could not access the
  9780.                                           %1 network with NetBiosOpen.
  9781.  
  9782.  NELOG_AT_Exec_Err                 3178   The AT command processor couldn't
  9783.                                           run %1.
  9784.  
  9785.  NELOG_Lazy_Write_Err              3180   WARNING:  Because of a lazy-write
  9786.                                           error, drive %1 now contains some
  9787.                                           corrupt data. The cache is
  9788.  Code                              Value  Meaning
  9789.  ────────────────────────────────────────────────────────────────────────────
  9790.                                          corrupt data. The cache is
  9791.                                           stopped.
  9792.  
  9793.  NELOG_HotFix                      3181   A defective sector on drive %1
  9794.                                           has been replaced (hotfixed). No
  9795.                                           data was lost. You should run
  9796.                                           CHKDSK soon to restore full
  9797.                                           performance and replenish the
  9798.                                           volume's spare sector pool. The
  9799.                                           hotfix occurred while processing
  9800.                                           a remote request.
  9801.  
  9802.  NELOG_HardErr_From_Server         3182   A disk error occurred on the HPFS
  9803.                                           volume in drive %1. The error
  9804.                                           occurred while processing a
  9805.                                           remote request.
  9806.  
  9807.  NELOG_LocalSecFail1               3183   The UAS database (NET.ACC) is
  9808.                                           corrupt. The local security
  9809.  Code                              Value  Meaning
  9810.  ────────────────────────────────────────────────────────────────────────────
  9811.                                          corrupt. The local security
  9812.                                           system is replacing the corrupted
  9813.                                           NET.ACC with the backup made at
  9814.                                           %1. Any updates to the UAS made
  9815.                                           after this time are lost.
  9816.  
  9817.  NELOG_LocalSecFail2               3184   The UAS database (NET.ACC) is
  9818.                                           missing. The local security
  9819.                                           system is restoring the backup
  9820.                                           database made at %1. Any updates
  9821.                                           to the UAS made after this time
  9822.                                           are lost.
  9823.  
  9824.  NELOG_LocalSecFail3               3185   Local security could not be
  9825.                                           started because the UAS database
  9826.                                           (NET.ACC) was missing or corrupt,
  9827.                                           and no usable backup database was
  9828.                                           present. THE SYSTEM IS NOT SECURE.
  9829.  
  9830.  Code                              Value  Meaning
  9831.  ────────────────────────────────────────────────────────────────────────────
  9832. 
  9833.  NELOG_LocalSecGeneralFail         3186   Local security could not be
  9834.                                           started because an error occurred
  9835.                                           during initialization. The error
  9836.                                           code returned is %1. THE SYSTEM
  9837.                                           IS NOT SECURE.
  9838.  
  9839.  NELOG_NetWkSta_Internal_Error     3190   A NetWksta internal error has
  9840.                                           occurred: %1.
  9841.  
  9842.  NELOG_NetWkSta_No_Resource        3191   The redirector is out of a
  9843.                                           resource: %1.
  9844.  
  9845.  NELOG_NetWkSta_SMB_Err            3192   An SMB error occurred on
  9846.                                           connection to %1. The SMB header
  9847.                                           is the data.
  9848.  
  9849.  NELOG_NetWkSta_VC_Err             3193   A virtual circuit error occurred
  9850.                                           on the session to %1. The NCB
  9851.  Code                              Value  Meaning
  9852.  ────────────────────────────────────────────────────────────────────────────
  9853.                                          on the session to %1. The NCB
  9854.                                           command and return code is the
  9855.                                           data.
  9856.  
  9857.  NELOG_NetWkSta_Stuck_VC_Err       3194   Hanging up a stuck session to %1.
  9858.  
  9859.  
  9860.  NELOG_NetWkSta_NCB_Err            3195   An NCB error occurred (%1). The
  9861.                                           NCB is the data.
  9862.  
  9863.  NELOG_NetWkSta_Write_Behind_Err   3196   A write operation to %1 failed.
  9864.                                           Data may have been lost.
  9865.  
  9866.  NELOG_NetWkSta_Reset_Err          3197   Reset of driver %1 failed to
  9867.                                           complete the NCB. The NCB is the
  9868.                                           data.
  9869.  
  9870.  NELOG_NetWkSta_Too_Many           3198   The amount of resource %1
  9871.                                           requested was more than the
  9872.  Code                              Value  Meaning
  9873.  ────────────────────────────────────────────────────────────────────────────
  9874.                                          requested was more than the
  9875.                                           maximum. The maximum amount was
  9876.                                           allocated.
  9877.  
  9878.  NELOG_Srv_Thread_Failure          3204   The server could not create a
  9879.                                           thread. The threads parameter in
  9880.                                           CONFIG.SYS should be increased.
  9881.  
  9882.  NELOG_Srv_Close_Failure           3205   The server could not close %1.
  9883.                                           The file is probably corrupt.
  9884.  
  9885.  NELOG_ReplUserCurDir              3206   The replicator cannot update
  9886.                                           directory %1. It has tree
  9887.                                           integrity and is the current
  9888.                                           directory for some process.
  9889.  
  9890.  NELOG_ReplCannotMasterDir         3207   The server cannot export
  9891.                                           directory %1 to client %2. It is
  9892.                                           exported from another server.
  9893.  Code                              Value  Meaning
  9894.  ────────────────────────────────────────────────────────────────────────────
  9895.                                          exported from another server.
  9896.  
  9897.  NELOG_ReplUpdateError             3208   The replication server could not
  9898.                                           update directory %2 from the
  9899.                                           source on %3 due to error %1.
  9900.  
  9901.  NELOG_ReplLostMaster              3209   Master %1 did not send an update
  9902.                                           notice for directory %2 at the
  9903.                                           expected time.
  9904.  
  9905.  NELOG_NetlogonAuthDCFail          3210   Failed to authenticate with %2,
  9906.                                           the domain controller for domain
  9907.                                           %1.
  9908.  
  9909.  NELOG_ReplLogonFailed             3211   The replicator attempted to log
  9910.                                           on at %3 as %2 and failed.
  9911.  
  9912.  NELOG_ReplNetErr                  3212   Network error %1 occurred.
  9913.  
  9914.  Code                              Value  Meaning
  9915.  ────────────────────────────────────────────────────────────────────────────
  9916. 
  9917.  NELOG_ReplMaxFiles                3213   Replicator limit for files in a
  9918.                                           directory has been exceeded.
  9919.  
  9920.  NELOG_ReplMaxTreeDepth            3214   Replicator limit for tree depth
  9921.                                           has been exceeded.
  9922.  
  9923.  NELOG_ReplBadMsg                  3215   Unrecognized message received in
  9924.                                           mailslot.
  9925.  
  9926.  NELOG_ReplSysErr                  3216   System error %1 occurred.
  9927.  
  9928.  NELOG_ReplUserLoged               3217   Cannot log on. User is currently
  9929.                                           logged on and argument TRYUSER is
  9930.                                           set to NO.
  9931.  
  9932.  NELOG_ReplBadImport               3218   IMPORT path %1 cannot be found.
  9933.  
  9934.  NELOG_ReplBadExport               3219   EXPORT path %1 cannot be found.
  9935.  Code                              Value  Meaning
  9936.  ────────────────────────────────────────────────────────────────────────────
  9937. NELOG_ReplBadExport               3219   EXPORT path %1 cannot be found.
  9938.  
  9939.  NELOG_ReplSignalFileErr           3220   Replicator failed to update
  9940.                                           signal file in directory %2 due
  9941.                                           to %1 system error.
  9942.  
  9943.  NELOG_DiskFT                      3221   Disk fault tolerance error %1.
  9944.  
  9945.  NELOG_ReplAccessDenied            3222   Replicator could not access %2 on
  9946.                                           %3 due to %1 system error.
  9947.  
  9948.  NELOG_NetlogonFailedPrimary       3223   The primary domain controller for
  9949.                                           domain %1 has apparently failed.
  9950.  
  9951.  NELOG_NetlogonPasswdSetFailed     3224   Error in changing this computer's
  9952.                                           password.
  9953.  
  9954.  NELOG_NetlogonTrackingError       3225   Error in updating the logon or
  9955.                                           logoff information for %1.
  9956.  Code                              Value  Meaning
  9957.  ────────────────────────────────────────────────────────────────────────────
  9958.                                          logoff information for %1.
  9959.  
  9960.  NELOG_NetlogonSyncError           3226   Error in synchronizing with
  9961.                                           primary domain controller %1.
  9962.  
  9963.  NELOG_UPS_PowerOut                3230   A power failure was detected.
  9964.  
  9965.  NELOG_UPS_Shutdown                3231   The UPS service performed server
  9966.                                           shutdown.
  9967.  
  9968.  NELOG_UPS_CmdFileError            3232   The UPS service did not complete
  9969.                                           execution of the user-specified
  9970.                                           shutdown command file.
  9971.  
  9972.  NELOG_UPS_CannotOpenDriver        3233   The UPS driver could not be
  9973.                                           opened. The error code is the
  9974.                                           data.
  9975.  
  9976.  NELOG_Missing_Parameter           3250   Initialization failed because of
  9977.  Code                              Value  Meaning
  9978.  ────────────────────────────────────────────────────────────────────────────
  9979. NELOG_Missing_Parameter           3250   Initialization failed because of
  9980.                                           an invalid or missing  parameter
  9981.                                           in LANMAN.INI: %1.
  9982.  
  9983.  NELOG_Invalid_Config_Line         3251   Initialization failed because of
  9984.                                           an invalid line in the
  9985.                                           configuration file %1. The
  9986.                                           invalid line is the data.
  9987.  
  9988.  NELOG_Invalid_Config_File         3252   Initialization failed because of
  9989.                                           an error in the configuration
  9990.                                           file %1.
  9991.  
  9992.  NELOG_File_Changed                3253   The file %1 has been changed
  9993.                                           after initialization. The boot
  9994.                                           block loading was temporarily
  9995.                                           terminated.
  9996.  
  9997.  NELOG_Files_Dont_Fit              3254   The files do not fit the boot
  9998.  Code                              Value  Meaning
  9999.  ────────────────────────────────────────────────────────────────────────────
  10000. NELOG_Files_Dont_Fit              3254   The files do not fit the boot
  10001.                                           block configuration file %1.
  10002.                                           Change BASE and ORG definitions
  10003.                                           or the order of the files.
  10004.  
  10005.  NELOG_Wrong_DLL_Version           3255   Initialization failed because the
  10006.                                           dynamic-link library %1 returned
  10007.                                           a wrong version number.
  10008.  
  10009.  NELOG_Error_in_DLL                3256   There was an unrecoverable error
  10010.                                           in the dynamic-link library of
  10011.                                           the service.
  10012.  
  10013.  NELOG_System_Error                3257   The system returned an unexpected
  10014.                                           error code. The error code is the
  10015.                                           data.
  10016.  
  10017.  NELOG_FT_ErrLog_Too_Large         3258   The fault-tolerance error log,
  10018.                                           LANROOT\LOGS\FT.LOG, is more than
  10019.  Code                              Value  Meaning
  10020.  ────────────────────────────────────────────────────────────────────────────
  10021.                                          LANROOT\LOGS\FT.LOG, is more than
  10022.                                           64K.
  10023.  
  10024.  NELOG_FT_Update_In_Progress       3259   The fault-tolerance error log,
  10025.                                           LANROOT\LOGS\FT.LOG, had the
  10026.                                           update-in-progress bit set upon
  10027.                                           opening, which means that the
  10028.                                           system crashed while working on
  10029.                                           the error log.
  10030.  
  10031.  NELOG_OEM_Code                    3299   Generic error log entry for OEMs
  10032.                                           to use to log errors from OEM
  10033.                                           value-added services. The text
  10034.                                           for the entry is: %1 %2 %3 %4 %5
  10035.                                           %6 %7 %8 %9. (For more detail,
  10036.                                           see ERRLOG.H.)
  10037.  
  10038.  ────────────────────────────────────────────────────────────────────────────
  10039.  
  10040.  Code                              Value  Meaning
  10041.  ────────────────────────────────────────────────────────────────────────────
  10042. 
  10043.  
  10044.  
  10045.  
  10046.  NetErrorLogClear
  10047.  ────────────────────────────────────────────────────────────────────────────
  10048.  
  10049.  NetErrorLogClear clears the error log and optionally saves the entries in a
  10050.  backup file. When executed locally, NetErrorLogClear requires that the
  10051.  NETWKSTA device driver be installed. When a servername parameter is
  10052.  supplied, NetErrorLogClear requires that the local Workstation service be
  10053.  started.
  10054.  
  10055.  
  10056.  Operating Systems Supported
  10057.  
  10058.  
  10059.    ■   MS OS/2 version 1.2, local and remote
  10060.  
  10061.    ■   MS OS/2 version 1.1, local and remote
  10062.  
  10063.    ■   MS-DOS, remote only
  10064.  
  10065.  
  10066.  
  10067.  Privilege Level
  10068.  
  10069.  Admin privilege is required to successfully execute NetErrorLogClear on a
  10070.  remote server or on a computer that has local security enabled.
  10071.  
  10072.  
  10073.  Syntax
  10074.  
  10075.    #define INCL_NETERRORLOG
  10076.    #define INCL_NETERRORS
  10077.    #include <lan.h>
  10078.  
  10079.    API_FUNCTION
  10080.    NetErrorLogClear (const char far *  pszServer,
  10081.                      const char far *  pszBackupFile,
  10082.                      char far *        pszReserved
  10083.                     );
  10084.  
  10085.  where
  10086.  
  10087.  pszServer
  10088.    Points to an ASCIIZ string that contains the name of the server on which
  10089.    to execute NetErrorLogClear. A null pointer or null string specifies the
  10090.    local computer.
  10091.  
  10092.  pszBackupFile
  10093.    Points to an ASCIIZ string that assigns a name for an optional backup
  10094.    file. The calling application must have write permission for the path
  10095.    specified by pszBackupFile. The DosMove function must also be able to
  10096.    access the pathname. If the pathname is relative, it is assumed to be
  10097.    relative to the LAN Manager LOGS directory. A null pointer indicates not
  10098.    to back up the error log.
  10099.  
  10100.  pszReserved
  10101.    Reserved; must be a null pointer.
  10102.  
  10103.  Return Codes
  10104.  
  10105. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  10106.  Code                              Value   Meaning
  10107.  ────────────────────────────────────────────────────────────────────────────
  10108.  NERR_Success                      0       The function encountered no
  10109.                                            errors.
  10110.  
  10111.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  10112.  
  10113.  ERROR_ACCESS_DENIED               5       The user has insufficient
  10114.                                            privilege for this operation.
  10115.  
  10116.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  10117.  
  10118.  ERROR_BAD_NETPATH                 53      The network path was not found.
  10119.  
  10120.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  10121.  
  10122.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  10123.                                            invalid.
  10124.  Code                              Value   Meaning
  10125.  ────────────────────────────────────────────────────────────────────────────
  10126.                                           invalid.
  10127.  
  10128.  ERROR_INVALID_NAME                123     The character or file system
  10129.                                            name is invalid.
  10130.  
  10131.  ERROR_FILENAME_EXCED_RANGE        206     The filename specified is
  10132.                                            invalid for the file system.
  10133.                                            This code is returned when
  10134.                                            checking a FAT disk partition
  10135.                                            only. It cannot be returned for
  10136.                                            an HPFS partition.
  10137.  
  10138.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  10139.                                            is not installed.
  10140.  
  10141.  NERR_RemoteOnly                   2106    This operation can be performed
  10142.                                            only on a server.
  10143.  
  10144.  NERR_WkstaNotStarted              2138    The Workstation service is not
  10145.  Code                              Value   Meaning
  10146.  ────────────────────────────────────────────────────────────────────────────
  10147. NERR_WkstaNotStarted              2138    The Workstation service is not
  10148.                                            started.
  10149.  
  10150.  NERR_BadTransactConfig            2141    The server is not configured for
  10151.                                            this transaction: IPC$ is not
  10152.                                            shared.
  10153.  
  10154.  NERR_InvalidComputer              2351    The specified computername is
  10155.                                            invalid.
  10156.  
  10157.  ────────────────────────────────────────────────────────────────────────────
  10158.  
  10159.  
  10160.  
  10161.  
  10162.  Remarks
  10163.  
  10164.  NetErrorLogClear returns ERROR_SHARING_VIOLATION if the error log is
  10165.  currently opened by another process.
  10166.  
  10167.  
  10168.  NetErrorLogRead
  10169.  ────────────────────────────────────────────────────────────────────────────
  10170.  
  10171.  NetErrorLogRead reads from the specified error log. When executed locally,
  10172.  NetErrorLogRead requires that the NETWKSTA device driver be installed. When
  10173.  a servername parameter is supplied, NetErrorLogRead requires that the local
  10174.  Workstation service be started.
  10175.  
  10176.  
  10177.  Operating Systems Supported
  10178.  
  10179.  
  10180.    ■   MS OS/2 version 1.2, local and remote
  10181.  
  10182.    ■   MS OS/2 version 1.1, local and remote
  10183.  
  10184.    ■   MS-DOS, remote only
  10185.  
  10186.  
  10187.  
  10188.  Privilege Level
  10189.  
  10190.  No special privilege level is required to successfully execute
  10191.  NetErrorLogRead.
  10192.  
  10193.  
  10194.  Syntax
  10195.  
  10196.    #define INCL_NETERRORLOG
  10197.    #define INCL_NETERRORS
  10198.    #include <lan.h>
  10199.  
  10200.    API_FUNCTION
  10201.    NetErrorLogRead (const char far *      pszServer,
  10202.                     const char far *      pszReserved1
  10203.                     HLOG far *            phErrorLog,
  10204.                     unsigned long         ulOffset,
  10205.                     unsigned short far *  pusReserved2,
  10206.                     unsigned long         ulReserved3,
  10207.                     unsigned long         flOffset,
  10208.                     char far *            pbBuffer,
  10209.                     unsigned short        cbBuffer,
  10210.                     unsigned short far *  pcbReturned,
  10211.                     unsigned short far *  pcbTotalAvail
  10212.                    );
  10213.  
  10214.  where
  10215.  
  10216.  pszServer
  10217.    Points to an ASCIIZ string that contains the name of the server on which
  10218.    to execute NetErrorLogRead. A null pointer or null string specifies the
  10219.    local computer.
  10220.  
  10221.  pszReserved1
  10222.    Reserved; must be a null pointer.
  10223.  
  10224.  phErrorLog
  10225.    Points to the error log handle. An application calling NetErrorLogRead for
  10226.    the first time must initialize the 128-bit error log handle as follows:
  10227.  
  10228.  Bits                             Value
  10229.  ────────────────────────────────────────────────────────────────────────────
  10230.  127 (MSB) - 64                   0
  10231.  63 - 0 (LSB)                     1
  10232.  ────────────────────────────────────────────────────────────────────────────
  10233.  
  10234.    The most significant bit (MSB) is the leftmost bit. The least significant
  10235.    bit (LSB) is the rightmost bit. Thereafter, each call to NetErrorLogRead
  10236.    must be given the value for the handle returned by the previous call.
  10237.  
  10238.  ulOffset
  10239.    Specifies the record offset at which to begin reading. This parameter is
  10240.    ignored unless bit 1 of flOffset is set. If used, ulOffset is taken as an
  10241.    offset of the record number (not bytes) at which to begin reading. Note
  10242.    that the record offset parameter is zero-based from both directions,
  10243.    depending upon the direction it is read. If reading backward, record 0 is
  10244.    the last record in the log. If reading forward, record 0 is the first
  10245.    record in the log.
  10246.  
  10247.  pusReserved2
  10248.    Reserved; must be a null pointer.
  10249.  
  10250.  ulReserved3
  10251.    Reserved; must be 0.
  10252.  
  10253.  flOffset
  10254.    Specifies the open flags, bitmapped as follows:
  10255.  
  10256.  Bit(s)                            Value
  10257.  ────────────────────────────────────────────────────────────────────────────
  10258.  0                                 If 0, the log is read forward. If 1, the
  10259.                                    log is read backward and records are
  10260.                                    returned in reverse chronological order.
  10261.  
  10262.  1                                 If 0, the read proceeds normally
  10263.                                    (sequentially). If 1, the read proceeds
  10264.                                    from the nth record from the start of
  10265.                                    the log, where n is the offset parameter.
  10266.  
  10267.  2-31                              Reserved; must be 0.
  10268.  
  10269.  ────────────────────────────────────────────────────────────────────────────
  10270.  
  10271.  
  10272.  pbBuffer
  10273.    Points to the buffer for returned data.
  10274.  
  10275.  cbBuffer
  10276.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  10277.  
  10278.  pcbReturned
  10279.    Points to an unsigned short integer that specifies how many bytes were
  10280.    read into the buffer. This count is valid only if NetErrorLogRead returns
  10281.    NERR_Success or NERR_BufTooSmall.
  10282.  
  10283.  pcbTotalAvail
  10284.    Points to an unsigned short integer that specifies how many bytes were
  10285.    available to be read from the log. This count is valid only if
  10286.    NetErrorLogRead returns NERR_Success or NERR_BufTooSmall.
  10287.  
  10288.  Return Codes
  10289.  
  10290. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  10291.  Code                              Value   Meaning
  10292.  Code                              Value   Meaning
  10293.  ────────────────────────────────────────────────────────────────────────────
  10294.  NERR_Success                      0       The function encountered no
  10295.                                            errors.
  10296.  
  10297.  ERROR_ACCESS_DENIED               5       The user has insufficient
  10298.                                            privilege for this operation.
  10299.  
  10300.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  10301.  
  10302.  ERROR_BAD_NETPATH                 53      The network path was not found.
  10303.  
  10304.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  10305.  
  10306.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  10307.                                            invalid.
  10308.  
  10309.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  10310.                                            is not installed.
  10311.  
  10312.  NERR_RemoteOnly                   2106    This operation can be performed
  10313.  Code                              Value   Meaning
  10314.  ────────────────────────────────────────────────────────────────────────────
  10315. NERR_RemoteOnly                   2106    This operation can be performed
  10316.                                            only on a server.
  10317.  
  10318.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  10319.  
  10320.  NERR_WkstaNotStarted              2138    The Workstation service is not
  10321.                                            started.
  10322.  
  10323.  NERR_BadTransactConfig            2141    The server is not configured for
  10324.                                            this transaction: IPC$ is not
  10325.                                            shared.
  10326.  
  10327.  NERR_InvalidAPI                   2142    The requested API is not
  10328.                                            supported on the remote server.
  10329.  
  10330.  NERR_InvalidComputer              2351    The specified computername is
  10331.                                            invalid.
  10332.  
  10333.  NERR_LogFileChanged               2378    The log file has changed since
  10334.  Code                              Value   Meaning
  10335.  ────────────────────────────────────────────────────────────────────────────
  10336. NERR_LogFileChanged               2378    The log file has changed since
  10337.                                            it was last read.
  10338.  
  10339.  NERR_LogFileCorrupt               2379    The log file is corrupt.
  10340.  
  10341.  NERR_InvalidLogSeek               2440    The log file does not contain
  10342.                                            the requested record number.
  10343.  
  10344.  ────────────────────────────────────────────────────────────────────────────
  10345.  
  10346.  
  10347.  
  10348.  
  10349.  Remarks
  10350.  
  10351.  To read the contents of an error log, an application calls NetErrorLogRead
  10352.  repeatedly until the function returns information (via the pcbTotalAvail
  10353.  parameter) that indicates there is no more data to be read. Each call to
  10354.  NetErrorLogRead returns a handle that must be provided to any subsequent
  10355.  call to NetErrorLogRead. This handle changes with each subsequent call. The
  10356.  handle is not a system file handle and should never be treated as such.
  10357.  
  10358.  Note that the error log can contain much more than 64K of data. If
  10359.  pcbTotalAvail is returned with a value of 0xFFFF, there may be 0xFFFF or
  10360.  more bytes of data available. The application should continue to read the
  10361.  log until the value returned in pcbTotalAvail is 0.
  10362.  
  10363.  NetErrorLogRead passes data back in the buffer only in whole records. The
  10364.  application never gets a partial record in the buffer. Use the value pointed
  10365.  to by pcbReturned to determine the end of valid data in the buffer.
  10366.  
  10367.  The error log is written with the newest records appended at the end. The
  10368.  flOffset parameter determines whether to read the log in forward or in
  10369.  reverse order.
  10370.  
  10371.  If the error log is partially read, and then the log is cleared or a new
  10372.  record written, a subsequent read with the handle returned from the first
  10373.  call to NetErrorLogRead will return an error. An application that finds that
  10374.  the error log has changed between calls can reread the changed log by
  10375.  reissuing the call with the error log handle initialized as if it were
  10376.  making the call for the first time.
  10377.  
  10378.  
  10379.  NetErrorLogWrite
  10380.  ────────────────────────────────────────────────────────────────────────────
  10381.  
  10382.  NetErrorLogWrite writes an entry to the error log on the local computer. It
  10383.  requires that the Workstation service be started.
  10384.  
  10385.  
  10386.  Operating Systems Supported
  10387.  
  10388.  
  10389.    ■   MS OS/2 version 1.2, local only
  10390.  
  10391.    ■   MS OS/2 version 1.1, local only
  10392.  
  10393.    ■   MS-DOS not supported
  10394.  
  10395.  
  10396.  
  10397.  Privilege Level
  10398.  
  10399.  No special privilege level is required to successfully execute
  10400.  NetErrorLogWrite.
  10401.  
  10402.  
  10403.  Syntax
  10404.  
  10405.    #define INCL_NETERRORLOG
  10406.    #define INCL_NETERRORS
  10407.    #include <lan.h>
  10408.  
  10409.    API_FUNCTION
  10410.    NetErrorLogWrite (char far *        pszReserved1,
  10411.                      unsigned short    usCode,
  10412.                      const char far *  pszComponent,
  10413.                      const char far *  pbBuffer,
  10414.                      unsigned short    cbBuffer,
  10415.                      const char far *  pszStrBuf
  10416.                      unsigned short    cStrBuf,
  10417.                      char far *        pszReserved2
  10418.                     );
  10419.  
  10420.  where
  10421.  
  10422.  pszReserved1
  10423.    Reserved; must be a null pointer.
  10424.  
  10425.  usCode
  10426.    Specifies the code of the error that occurred.
  10427.  
  10428.  pszComponent
  10429.    Points to an ASCIIZ string that specifies which component encountered the
  10430.    error.
  10431.  
  10432.  pbBuffer
  10433.    Points to the raw data associated with the error condition.
  10434.  
  10435.  cbBuffer
  10436.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  10437.  
  10438.  pszStrBuf
  10439.    Points to ASCIIZ strings that contain the error message.
  10440.  
  10441.  cStrBuf
  10442.    Specifies how many concatenated ASCIIZ strings are stored by pszStrBuf.
  10443.  
  10444.  pszReserved2
  10445.    Reserved; must be a null pointer.
  10446.  
  10447.  Return Codes
  10448.  
  10449. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  10450.  Code                              Value   Meaning
  10451.  ────────────────────────────────────────────────────────────────────────────
  10452.  NERR_Success                      0       The function encountered no
  10453.                                            errors.
  10454.  
  10455.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  10456.  
  10457.  ERROR_ACCESS_DENIED               5       The user has insufficient
  10458.                                            privilege for this operation.
  10459.  
  10460.  Code                              Value   Meaning
  10461.  ────────────────────────────────────────────────────────────────────────────
  10462. 
  10463.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  10464.  
  10465.  ERROR_NOT_SUPPORTED               50      This network request is not
  10466.                                            supported.
  10467.  
  10468.  ERROR_BAD_NETPATH                 53      The network path was not found.
  10469.  
  10470.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  10471.  
  10472.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  10473.                                            invalid.
  10474.  
  10475.  ERROR_NET_WRITE_FAULT             88      A network data fault occurred.
  10476.  
  10477.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  10478.                                            is not installed.
  10479.  
  10480.  NERR_WkstaNotStarted              2138    The Workstation service is not
  10481.  Code                              Value   Meaning
  10482.  ────────────────────────────────────────────────────────────────────────────
  10483. NERR_WkstaNotStarted              2138    The Workstation service is not
  10484.                                            started.
  10485.  
  10486.  NERR_LogOverflow                  2377    The log file is too big.
  10487.  
  10488.  ────────────────────────────────────────────────────────────────────────────
  10489.  
  10490.  
  10491.  
  10492.  
  10493.  Remarks
  10494.  
  10495.  NetErrorLogWrite internally calls the appropriate functions to open and
  10496.  close the error log.
  10497.  
  10498.  NetErrorLogWrite issues an error log alert (via NetAlertRaise) each time an
  10499.  entry is written to the error log. It also issues an admin alert by calling
  10500.  NetAlertRaise when the error log reaches 80% capacity and again when the log
  10501.  reaches 100% capacity. At 100% error log capacity, NetErrorLogWrite fails
  10502.  and returns NERR_LogOverflow. Applications should periodically clear the log
  10503.  of outdated information so that the log does not reach 100% capacity.
  10504.  
  10505.  See Also
  10506.  
  10507.  For information about             See
  10508.  ────────────────────────────────────────────────────────────────────────────
  10509.  Alerts                            Alert Category
  10510.  
  10511.  
  10512.  
  10513.  
  10514.  
  10515.  Error Logging Category Example
  10516.  
  10517.    /*
  10518.       NETERR.C -- a sample program demonstrating NetErrorLog API functions.
  10519.  
  10520.       This program requires that you have admin privilege if a servername
  10521.       parameter is supplied.
  10522.  
  10523.          usage:  neterr [-s \\server] [-b backup]
  10524.  
  10525.          where  \\server = Name of the server. A servername must be preceded
  10526.  
  10527.                            by two backslashes (\\).
  10528.                 backup   = Name of the backup file.
  10529.  
  10530.       API                  Used to...
  10531.       ================     ===========================================
  10532.       NetErrorLogClear     Back up the error log and then clear it
  10533.       NetErrorLogWrite     Write several entries into the error log
  10534.       NetErrorLogRead      Read the error log and display its contents
  10535.  
  10536.       This code sample is provided for demonstration purposes only.
  10537.       Microsoft makes no warranty, either express or implied,
  10538.       as to its usability in any given situation.
  10539.    */
  10540.  
  10541.    #define     INCL_NETERRORS
  10542.    #define     INCL_NETERRORLOG
  10543.    #include    <lan.h>        // LAN Manager header files
  10544.  
  10545.    #include    <stdio.h>      // C run-time header files
  10546.    #include    <stdlib.h>
  10547.    #include    <string.h>
  10548.    #include    <time.h>
  10549.  
  10550.    #include    "samples.h"    // Internal routine header file
  10551.  
  10552.    #define DEFAULT_BACKUP     "ERROR.BCK"
  10553.  
  10554.    void Usage (char * pszProgram);
  10555.  
  10556.    void main(int argc, char *argv[])
  10557.    {
  10558.       char * pszServer = "";                    // Servername
  10559.       char * pszBackup = DEFAULT_BACKUP;        // Backup log file
  10560.       struct error_log *pBuffer;                // Pointer to data buffer
  10561.       struct error_log *pEntry;                 // Single entry in log
  10562.       int              iCount;                  // Index counter
  10563.       unsigned short   cbBuffer;                // Count of bytes in
  10564.    buffer
  10565.       unsigned short   cbRead;                  // Count of bytes read
  10566.       unsigned short   cbAvail;                 // Count of bytes available
  10567.       unsigned short   usDataByte;              // Raw data
  10568.       API_RET_TYPE     uReturnCode;             // API return code
  10569.       HLOG             hLogHandle;              // Error log handle
  10570.       time_t           tTime;
  10571.  
  10572.       for (iCount = 1; iCount < argc; iCount++)
  10573.       {
  10574.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  10575.          {
  10576.             switch (tolower(*(argv[iCount]+1))) // Process switches
  10577.             {
  10578.                case 's':                        // -s servername
  10579.                   pszServer = argv[++iCount];
  10580.                   break;
  10581.                case 'b':                        // -b backup file
  10582.                   pszBackup = argv[++iCount];
  10583.                   break;
  10584.                case 'h':
  10585.                default:
  10586.                   Usage(argv[0]);
  10587.             }
  10588.          }
  10589.          else
  10590.             Usage(argv[0]);
  10591.       }
  10592.  
  10593.    //========================================================================
  10594.    //  NetErrorLogClear
  10595.    //
  10596.    //  This API clears the error log for the specified server. A backup
  10597.    is
  10598.    //  kept in the file specified by pszBackup. If a null pointer is
  10599.    supplied,
  10600.    //  no backup is kept.
  10601.    //========================================================================
  10602.  
  10603.       uReturnCode = NetErrorLogClear(
  10604.                         pszServer,              // Servername
  10605.                         pszBackup,              // Backup file
  10606.                         NULL);                  // Reserved; must be
  10607.    NULL
  10608.  
  10609.       printf("NetErrorLogClear returned %u\n", uReturnCode);
  10610.       printf("   backup file = %s \n\n", pszBackup);
  10611.  
  10612.  
  10613.  
  10614.    //========================================================================
  10615.    //  NetErrorLogWrite
  10616.    //
  10617.    //  This API writes a few entries to the error log. These entries
  10618.    are
  10619.    //  some typical types of errors that may be encountered. The error
  10620.    //  codes are defined in the ERRLOG.H header file.
  10621.    //  Note: Because NetErrorLogWrite has no servername parameter, the
  10622.    entry
  10623.    //  written into the local error log.
  10624.    //========================================================================
  10625.  
  10626.       /*
  10627.        * Write an entry of type NELOG_Resource_Shortage that has
  10628.        * a single text error message and no raw data.
  10629.        */
  10630.  
  10631.       uReturnCode = NetErrorLogWrite(
  10632.                         NULL,                     // Reserved; must be
  10633.    NULL
  10634.                         NELOG_Resource_Shortage,  // Error code
  10635.                         argv[0],                  // Component in error
  10636.                         NULL,                     // Pointer to raw data
  10637.                         0,                        // Length of raw data
  10638.    buffer
  10639.                         "THREADS=",               // String data
  10640.                         1,                        // Number of error
  10641.    strings
  10642.                         NULL);                    // Reserved; must be
  10643.    NULL
  10644.  
  10645.       printf("NetErrorLogWrite for NELOG_Resource_Shortage returned %u\n",
  10646.                         uReturnCode);
  10647.  
  10648.       /*
  10649.        * Write an entry of type NELOG_Init_OpenCreate_Err that has
  10650.        * a single text error message and raw data associated with it.
  10651.        */
  10652.  
  10653.       usDataByte = 3;                              // Path not found
  10654.    error
  10655.  
  10656.       uReturnCode = NetErrorLogWrite(
  10657.                         NULL,                      // Reserved; must
  10658.    be NULL
  10659.                         NELOG_Init_OpenCreate_Err, // Error code
  10660.                         argv[0],                   // Component in error
  10661.                         (char far *)&usDataByte,   // Pointer to raw
  10662.    data
  10663.                         sizeof(unsigned short),    // Length of raw data
  10664.    buffer
  10665.                         "C:\\INIT\\STARTER.CMD",   // String data
  10666.                         1,                         // Number of error
  10667.    strings
  10668.                         NULL);                     // Reserved; must
  10669.    be NULL
  10670.  
  10671.       printf("NetErrorLogWrite for NELOG_Init_OpenCreate_Err returned
  10672.    %u\n",
  10673.                         uReturnCode);
  10674.  
  10675.       /*
  10676.        * Write an entry of type NELOG_Srv_No_Mem_Grow that has
  10677.        * no text error message and no raw data associated with it.
  10678.        */
  10679.  
  10680.       uReturnCode = NetErrorLogWrite(
  10681.                         NULL,                   // Reserved; must be
  10682.    NULL
  10683.                         NELOG_Srv_No_Mem_Grow,  // Error code
  10684.                         argv[0],                // Component in error
  10685.                         NULL,                   // Pointer to raw data
  10686.                         0,                      // Length of raw data
  10687.    buffer
  10688.                         NULL,                   // String data
  10689.                         0,                      // Number of error strings
  10690.                         NULL);                  // Reserved; must be
  10691.    NULL
  10692.  
  10693.       printf("NetErrorLogWrite for NELOG_Srv_No_Mem_Grow returned %u\n\n",
  10694.                         uReturnCode);
  10695.  
  10696.    //========================================================================
  10697.    //  NetErrorLogRead
  10698.    //
  10699.    //  This API reads and displays the error log for the specified server.
  10700.    //========================================================================
  10701.  
  10702.       /*
  10703.        * Allocate a small buffer space to demonstrate reading the error
  10704.    log
  10705.        * when the log is larger than the buffer allocated to store it.
  10706.    The
  10707.        * maximum allowable buffer is 64K. If the error log is larger
  10708.    than
  10709.        * the buffer specified, the API returns as many full records as
  10710.    it
  10711.        * can and the NERR_Success return code. Subsequent reads start
  10712.    from
  10713.        * the end of the last record read. To read the whole log, the
  10714.    reads
  10715.        * must continue until the bytes available counter is 0.
  10716.        */
  10717.  
  10718.       cbBuffer = 100;
  10719.       pBuffer = SafeMalloc(cbBuffer);           // Allocate memory for
  10720.    buffer
  10721.  
  10722.       /*
  10723.        * Set the log handle for reading from the start of the error log.
  10724.        * This handle gets modified by the API. Any subsequent reads
  10725.        * for unread data should use the returned handle.
  10726.        */
  10727.  
  10728.       hLogHandle.time = 0L;
  10729.       hLogHandle.last_flags = 0L;
  10730.       hLogHandle.offset = 0xFFFFFFFF;
  10731.       hLogHandle.last_flags = 0xFFFFFFFF;
  10732.       do {
  10733.          uReturnCode = NetErrorLogRead(
  10734.                            pszServer,           // Servername
  10735.                            NULL,                // Reserved; must be
  10736.    NULL
  10737.                            &hLogHandle,         // Error log handle
  10738.                            0L,                  // Start at record 0
  10739.                            NULL,                // Reserved; must be
  10740.    NULL
  10741.                            0L,                  // Reserved; must be
  10742.    0
  10743.                            0L,                  // Read the log forward
  10744.                            (char far *)pBuffer, // Data returned here
  10745.                            cbBuffer,            // Size of buffer, in
  10746.    bytes
  10747.                            &cbRead,             // Count of bytes read
  10748.                            &cbAvail);           // Count of bytes available
  10749.  
  10750.          printf("NetErrorLogRead returned %u \n", uReturnCode);
  10751.  
  10752.          if (uReturnCode == NERR_Success)
  10753.          {
  10754.             for ( pEntry = pBuffer;
  10755.                   pEntry < (struct error_log *)((char *)pBuffer + cbRead);
  10756.    )
  10757.             {
  10758.                tTime = (time_t) pEntry->el_time;
  10759.  
  10760.                printf("   Error %hu, from %s at %s",
  10761.                    pEntry->el_error, pEntry->el_name,
  10762.                    asctime( gmtime ((const time_t *) &tTime) ) );
  10763.  
  10764.                pEntry = (struct error_log *)((char *)pEntry +
  10765.  pEntry->el_len);
  10766.             }
  10767.             printf("Bytes Read = 0x%X\n", cbRead);
  10768.  
  10769.             // To read to whole log, keep reading until cbAvail is 0.
  10770.  
  10771.             if (cbAvail)
  10772.                printf("Data still unread.\n\n");
  10773.             else
  10774.                printf("All data read.\n\n");
  10775.          }
  10776.       } while ((uReturnCode == NERR_Success) && (cbAvail != 0));
  10777.  
  10778.       free(pBuffer);
  10779.       exit(0);
  10780.    }
  10781.    void Usage (char * pszProgram)
  10782.    {
  10783.       fprintf(stderr, "Usage: %s [-s \\\\server] [-b backup]\n", pszProgram);
  10784.       exit(1);
  10785.    }
  10786.  
  10787.  
  10788.  
  10789.  
  10790.  
  10791.  
  10792.  
  10793.  File Category
  10794.  
  10795.  File API functions provide a way to monitor and close the file, device, and
  10796.  pipe resources open on a server. They require that the Workstation service
  10797.  be started and that the Server service be started on the specified server.
  10798.  
  10799.  The File category functions, datatypes, structures, and constants are
  10800.  defined in the NETCONS.H, NETERR.H, and SHARES.H header files. A source
  10801.  program can access these definitions by defining the constants
  10802.  INCL_NETERRORS and INCL_NETFILE, and including the master header file,
  10803.  LAN.H. For more information about these definitions,  see the "Example"
  10804.  section, later in this category.
  10805.  
  10806.  These are the File API functions:
  10807.  
  10808.  
  10809.    ■   NetFileClose2
  10810.  
  10811.    ■   NetFileEnum2
  10812.  
  10813.    ■   NetFileGetInfo2
  10814.  
  10815.  
  10816.  
  10817.  Description
  10818.  
  10819.  NetFileClose2 forces a server resource closed. This function can be used
  10820.  when a system error prevents normal closure (for example, when the DosClose
  10821.  function fails).
  10822.  
  10823.  NetFileEnum2 returns information about resources open on a server. A file
  10824.  can be opened one or more times by one or more applications. Each file
  10825.  opening is uniquely identified. NetFileEnum2 returns an entry for each file
  10826.  opening.
  10827.  
  10828.  NetFileGetInfo2 returns information about one particular opening of a
  10829.  resource.
  10830.  
  10831.  NetFileEnum2 and NetFileGetInfo2 can return the file identifier only, or
  10832.  they can return the file identifier and additional detailed data. Four
  10833.  levels and data structures are available. Levels 0 and 1 return short file
  10834.  identifiers. Levels 2 and 3 return long file identifiers.  Long file
  10835.  identifiers support the increased number of open files allowed on computers
  10836.  using the high-performance file system (HPFS). Levels 0 and 2 return only
  10837.  the iden- tification number that was assigned to the resource when it was
  10838.  opened. Levels 1 and 3 return the identification number, permissions, file
  10839.  locks, and the name of the user who opened the resource. You should use
  10840.  levels 2 and 3 to ensure that data is returned for all open resources.
  10841.  Levels 0 and 1 are provided only for compatibility with previous LAN Manager
  10842.  releases.
  10843.  
  10844.  NetFileEnum2 and NetFileGetInfo2 can return level 0 and level 1 data for
  10845.  only those resources that have file identifier values less than 65,536. Do
  10846.  not make assumptions about file identifiers; an open resource can have an
  10847.  identifier greater than 65,536 even if it is the only open resource.
  10848.  
  10849.  Levels 0 and 1 do not guarantee the return of all valid data. When level 0
  10850.  or level 1 is used, the value of the pcEntriesRemaining parameter returned
  10851.  by NetFileEnum2 reflects only the number of open files that have file
  10852.  identifier values less than 65,536.
  10853.  
  10854.  
  10855.  Data Structures
  10856.  
  10857.  The sLevel parameter of NetFileEnum2 and NetFileGetInfo2 specifies the level
  10858.  of information to be returned. Both functions return the file_info_X data
  10859.  structure, where X is 0, 1, 2, or 3, depending on the level of detail
  10860.  specified.
  10861.  
  10862.  
  10863.  Opened Resources (level 0)
  10864.  
  10865.  The file_info_0 data structure has this format:
  10866.  
  10867.    struct file_info_0 {
  10868.        unsigned short  fi0_id;
  10869.    };
  10870.  
  10871.  where
  10872.  
  10873.  fi0_id
  10874.    Specifies the identification number assigned to the resource when it is
  10875.    opened.
  10876.  
  10877.  
  10878.  Opened Resources (level 1)
  10879.  
  10880.  The file_info_1 data structure has this format:
  10881.  
  10882.    struct file_info_1 {
  10883.        unsigned short  fi1_id;
  10884.        unsigned short  fi1_permissions;
  10885.        unsigned short  fi1_num_locks;
  10886.        char far *      fi1_pathname;
  10887.        char far *      fi1_username;
  10888.    };
  10889.  
  10890.  where
  10891.  
  10892.  fi1_id
  10893.    Specifies the identification number assigned to the resource when it is
  10894.    opened.
  10895.  
  10896.  fi1_permissions
  10897.    Specifies the access permissions of the opening application. The bit mask
  10898.    of fi1_permissions is defined in the SHARES.H header file.
  10899.  
  10900.    The SHARES.H header file defines the following permissions:
  10901.  
  10902.  Code              Bit Mask  Meaning
  10903.  ────────────────────────────────────────────────────────────────────────────
  10904.  PERM_FILE_READ    0x1       Permission to read a resource and, by default,
  10905.                              execute the resource.
  10906.  
  10907.  PERM_FILE_WRITE   0x2       Permission to write to a resource.
  10908.  
  10909.  PERM_FILE_CREATE  0x4       Permission to create a resource; data can be
  10910.                              written when creating the resource.
  10911.  
  10912.  ────────────────────────────────────────────────────────────────────────────
  10913.  
  10914.  
  10915.  fi1_num_locks
  10916.    Specifies how many file locks are on the file, device, or pipe.
  10917.  
  10918.  fi1_pathname
  10919.    Points to an ASCIIZ string that gives the pathname of the opened resource.
  10920.  
  10921.  fi1_username
  10922.    Points to an ASCIIZ string that specifies which user (on servers with
  10923.    user-level security) or which computername (on servers with share-level
  10924.    security) opened the resource.
  10925.  
  10926.  
  10927.  Opened Resources (level 2)
  10928.  
  10929.  The file_info_2 data structure has this format:
  10930.  
  10931.    struct file_info_2 {
  10932.        unsigned long  fi2_id;
  10933.    };
  10934.  
  10935.  where
  10936.  
  10937.  fi2_id
  10938.    Specifies the identification number assigned to the resource when it is
  10939.    opened.
  10940.  
  10941.  
  10942.  Opened Resources (level 3)
  10943.  
  10944.  The file_info_3 data structure has this format:
  10945.  
  10946.    struct file_info_3 {
  10947.        unsigned long   fi3_id;
  10948.        unsigned short  fi3_permissions;
  10949.        unsigned short  fi3_num_locks;
  10950.        char far *      fi3_pathname;
  10951.        char far *      fi3_username;
  10952.    };
  10953.  
  10954.  where
  10955.  
  10956.  fi3_id
  10957.    Specifies the identification number assigned to the resource when it is
  10958.    opened.
  10959.  
  10960.  fi3_permissions
  10961.    Specifies the access permissions of the opening application. The bit mask
  10962.    of fi3_permissions is defined in the SHARES.H header file. It has the same
  10963.    definition as the fi1_permissions element of the file_info_1 data
  10964.    structure. For more information, see the description of the file_info_1
  10965.    data structure, earlier in this section.
  10966.  
  10967.  fi3_num_locks
  10968.    Specifies how many file locks are on the file, device, or pipe.
  10969.  
  10970.  fi3_pathname
  10971.    Points to an ASCIIZ string that gives the pathname of the opened resource.
  10972.  
  10973.  fi3_username
  10974.    Points to an ASCIIZ string that specifies which user (on servers that have
  10975.    user-level security) or which computer (on servers that have share-level
  10976.    security) opened the resource.
  10977.  
  10978.  See Also
  10979.  
  10980.  For information about             See
  10981.  ────────────────────────────────────────────────────────────────────────────
  10982.  Access permissions                Access Permissions Category
  10983.  
  10984.  
  10985.  NetFileClose2
  10986.  ────────────────────────────────────────────────────────────────────────────
  10987.  
  10988.  NetFileClose2 forces a resource to close. This function can be used when an
  10989.  error prevents closure by other means.
  10990.  
  10991.  
  10992.  Operating Systems Supported
  10993.  
  10994.  
  10995.    ■   MS OS/2 version 1.2, local and remote
  10996.  
  10997.    ■   MS OS/2 version 1.1, remote only
  10998.  
  10999.    ■   MS-DOS, remote only
  11000.  
  11001.  
  11002.  
  11003.  Privilege Level
  11004.  
  11005.  Admin privilege or server operator privilege is required to successfully
  11006.  execute NetFileClose2 on a remote server or on a computer that has local
  11007.  security enabled.
  11008.  
  11009.  
  11010.  Syntax
  11011.  
  11012.    #define INCL_NETFILE
  11013.    #define INCL_NETERRORS
  11014.    #include <lan.h>
  11015.  
  11016.    API_FUNCTION
  11017.    NetFileClose2 (const char far *  pszServer,
  11018.                   unsigned long     ulFileId
  11019.                  );
  11020.  
  11021.  where
  11022.  
  11023.  pszServer
  11024.    Points to an ASCIIZ string that contains the name of the server on which
  11025.    to execute NetFileClose2. A null pointer or null string specifies the
  11026.    local computer.
  11027.  
  11028.  ulFileId
  11029.    Specifies the identification number assigned to the resource when it is
  11030.    opened.
  11031.  
  11032.  Return Codes
  11033.  
  11034. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  11035.  Code                              Value   Meaning
  11036.  ────────────────────────────────────────────────────────────────────────────
  11037.  NERR_Success                      0       The function encountered no
  11038.                                            errors.
  11039.  
  11040.  ERROR_ACCESS_DENIED               5       The user has insufficient
  11041.                                            privilege for this operation.
  11042.  
  11043.  ERROR_NOT_SUPPORTED               50      This network request is not
  11044.                                            supported.
  11045.  
  11046.  ERROR_BAD_NETPATH                 53      The network path was not found.
  11047.  
  11048.  Code                              Value   Meaning
  11049.  ────────────────────────────────────────────────────────────────────────────
  11050. 
  11051.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  11052.  
  11053.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  11054.                                            is not installed.
  11055.  
  11056.  NERR_RemoteOnly                   2106    This operation can be performed
  11057.                                            only on a server.
  11058.  
  11059.  NERR_ServerNotStarted             2114    The Server service is not
  11060.                                            started.
  11061.  
  11062.  NERR_WkstaNotStarted              2138    The Workstation service is not
  11063.                                            started.
  11064.  
  11065.  NERR_BadTransactConfig            2141    The server is not configured for
  11066.                                            this transaction: IPC$ is not
  11067.                                            shared.
  11068.  
  11069.  Code                              Value   Meaning
  11070.  ────────────────────────────────────────────────────────────────────────────
  11071. 
  11072.  NERR_InvalidAPI                   2142    The requested API is not
  11073.                                            supported on the remote server.
  11074.  
  11075.  NERR_FileIdNotFound               2314    There is no open file with this
  11076.                                            ID number.
  11077.  
  11078.  NERR_InvalidComputer              2351    The specified computername is
  11079.                                            invalid.
  11080.  
  11081.  ────────────────────────────────────────────────────────────────────────────
  11082.  
  11083.  
  11084.  
  11085.  
  11086.  Remarks
  11087.  
  11088.  Ordinarily, a call to the DosClose function closes a resource opened by a
  11089.  call to the DosOpen function. Use NetFileClose2 to force a resource to
  11090.  close.
  11091.  
  11092.  NetFileClose2 supersedes NetFileClose (used in earlier versions of LAN
  11093.  Manager). NetFileClose2 is the same as NetFileClose except that
  11094.  NetFileClose2 has an unsigned long ulFileId parameter instead of an unsigned
  11095.  short usFileId parameter. For more information, see Appendix B, "Upgrading
  11096.  LAN Manager 1.0 Applications."
  11097.  
  11098.  See Also
  11099.  
  11100.  For information about             See
  11101.  ────────────────────────────────────────────────────────────────────────────
  11102.  Listing open files, devices, or   NetFileEnum2
  11103.  pipes on a server
  11104.  
  11105.  Obtaining information about a     NetFileGetInfo2
  11106.  specified open resource
  11107.  
  11108.  
  11109.  NetFileEnum2
  11110.  ────────────────────────────────────────────────────────────────────────────
  11111.  
  11112.  NetFileEnum2 supplies information about some or all open files on a server,
  11113.  allowing the user to supply a key and get required information through
  11114.  repeated calls to the function.
  11115.  
  11116.  NetFileEnum2 is slightly different from other Enum functions. NetFileEnum2
  11117.  uses a file resume key data structure that allows the application to resume
  11118.  enumeration from where it left off. NetFileEnum2 does not require all data
  11119.  to fit in a single buffer returned from a single call.
  11120.  
  11121.  
  11122.  Operating Systems Supported
  11123.  
  11124.  
  11125.    ■   MS OS/2 version 1.2, local and remote
  11126.  
  11127.    ■   MS OS/2 version 1.1, remote only
  11128.  
  11129.    ■   MS-DOS, remote only
  11130.  
  11131.  
  11132.  
  11133.  Privilege Level
  11134.  
  11135.  Admin privilege or server operator privilege is required to successfully
  11136.  execute NetFileEnum2 on a remote server or on a computer that has local
  11137.  security enabled.
  11138.  
  11139.  
  11140.  Syntax
  11141.  
  11142.    #define INCL_NETFILE
  11143.    #define INCL_NETERRORS
  11144.    #include <lan.h>
  11145.  
  11146.    API_FUNCTION
  11147.    NetFileEnum2 (const char far *      pszServer,
  11148.                  const char far *      pszBasePath,
  11149.                  const char far *      pszUserName,
  11150.                  short                 sLevel,
  11151.                  char far *            pbBuffer,
  11152.                  unsigned short        cbBuffer,
  11153.                  unsigned short far *  pcEntriesRead,
  11154.                  unsigned short far *  pcEntriesRemaining,
  11155.                  void far *            pResumeKey
  11156.                 );
  11157.  
  11158.  where
  11159.  
  11160.  pszServer
  11161.    Points to an ASCIIZ string that contains the name of the server on which
  11162.    to execute NetFileEnum2. A null pointer or null string specifies the local
  11163.    computer.
  11164.  
  11165.  pszBasePath
  11166.    Points to the base pathname for enumeration. If not NULL, pszBasePath
  11167.    serves as a qualifier to the enumeration. The entries returned are limited
  11168.    to those that have names beginning with the qualifier string pointed to by
  11169.    pszBasePath. For example, the value C:\TMP enumerates only open files that
  11170.    have pathnames beginning with C:\TMP (such as C:\TMPFILE and
  11171.    C:\TMP\DOCUMENT). If pszBasePath is NULL, no base path qualifier is used.
  11172.  
  11173.  pszUserName
  11174.    Points to an ASCIIZ string that specifies the name of the user. If not
  11175.    NULL, pszUserName serves as a qualifier to the enumeration. The files
  11176.    returned are limited to those that have usernames matching the qualifier.
  11177.    If pszUserName is NULL, no username qualifier is used.
  11178.  
  11179.  sLevel
  11180.    Specifies the level of detail (0, 1, 2, or 3) requested.
  11181.  
  11182.  pbBuffer
  11183.    Points to the buffer in which to store the returned data. On a successful
  11184.    return, the buffer contains a sequence of file_info_X data structures,
  11185.    where X is 0, 1, 2, or 3, depending on the level of detail requested.
  11186.  
  11187.  cbBuffer
  11188.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  11189.  
  11190.  pcEntriesRead
  11191.    Points to an unsigned short integer in which a count of the number of
  11192.    entries in the buffer is returned. This count is valid only if
  11193.    NetFileEnum2 returns NERR_Success or ERROR_MORE_DATA.
  11194.  
  11195.  pcEntriesRemaining
  11196.    Points to an unsigned short integer in which a count of the total number
  11197.    of entries is returned. This count is valid only if NetFileEnum2 returns
  11198.    NERR_Success or ERROR_MORE_DATA.
  11199.  
  11200.  pResumeKey
  11201.    Points to the file resume key structure, FRK. Using pResumeKey allows
  11202.    repeated calls to NetFileEnum2 to continue enumerating files when the
  11203.    return data from a preceding call did not fit within the return buffer
  11204.    supplied.
  11205.  
  11206.  Return Codes
  11207.  
  11208. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  11209.  Code                              Value   Meaning
  11210.  ────────────────────────────────────────────────────────────────────────────
  11211.  NERR_Success                      0       The function encountered no
  11212.                                            errors.
  11213.  
  11214.  ERROR_ACCESS_DENIED               5       The user has insufficient
  11215.                                            privilege for this operation.
  11216.  Code                              Value   Meaning
  11217.  ────────────────────────────────────────────────────────────────────────────
  11218.                                           privilege for this operation.
  11219.  
  11220.  ERROR_BAD_NETPATH                 53      The network path was not found.
  11221.  
  11222.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  11223.  
  11224.  ERROR_INVALID_LEVEL               124     The level for information
  11225.                                            retrieval or setting is invalid.
  11226.  
  11227.  ERROR_MORE_DATA                   234     Additional data is available.
  11228.  
  11229.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  11230.                                            is not installed.
  11231.  
  11232.  NERR_RemoteOnly                   2106    This operation can be performed
  11233.                                            only on a server.
  11234.  
  11235.  NERR_ServerNotStarted             2114    The Server service is not
  11236.                                            started.
  11237.  Code                              Value   Meaning
  11238.  ────────────────────────────────────────────────────────────────────────────
  11239.                                           started.
  11240.  
  11241.  NERR_WkstaNotStarted              2138    The Workstation service is not
  11242.                                            started.
  11243.  
  11244.  NERR_BadTransactConfig            2141    The server is not configured for
  11245.                                            this transaction: IPC$ is not
  11246.                                            shared.
  11247.  
  11248.  NERR_InvalidAPI                   2142    The requested API is not
  11249.                                            supported on the remote server.
  11250.  
  11251.  NERR_InvalidComputer              2351    The specified computername is
  11252.                                            invalid.
  11253.  
  11254.  ────────────────────────────────────────────────────────────────────────────
  11255.  
  11256.  
  11257.  
  11258.  
  11259.  Remarks
  11260.  
  11261.  NetFileEnum2 is different from other Enum functions. Other Enum functions
  11262.  supply only the fixed-length data if the buffer cannot hold the complete
  11263.  record; unlike other Enum functions, NetFileEnum2 supplies as many complete
  11264.  records as the buffer can hold.
  11265.  
  11266.  The application can use a resume key and make repeated calls to obtain the
  11267.  data. Rather than make repeated pairs of calls as with other Enum functions
  11268.  (the first to determine a buffer size, the second to obtain the data), an
  11269.  application can determine a representative buffer size, and then make
  11270.  repeated calls using this size. (If the application makes an initial call to
  11271.  NetFileEnum2 to determine the representative buffer size, the file resume
  11272.  key should be reinitialized for the first call that obtains actual data.)
  11273.  
  11274.  NetFileEnum2 allows the user to overcome the problem that arises when the
  11275.  information returned exceeds the size of the return buffer. To initialize
  11276.  pResumeKey, use the FRK_INIT macro supplied in the SHARES.H header file; the
  11277.  macro accepts an FRK structure as an argument. The following example shows
  11278.  an application code fragment:
  11279.  
  11280.    FRK f;
  11281.  
  11282.    FRK_INIT (f);
  11283.    NetFileEnum2 (..., &f, ...);
  11284.  
  11285.  If NetFileEnum2 is called with an initial pResumeKey value, and the buffer
  11286.  supplied is too small to return all the requested information, NetFileEnum2
  11287.  returns the ERROR_MORE_DATA error code and a pResumeKey value suitable for
  11288.  retrieving the remaining data.
  11289.  
  11290.  When called with a pResumeKey value from a previous call, NetFileEnum2
  11291.  resumes the enumeration at the place indicated by that value. The user must
  11292.  not attempt to set this key, other than to initialize it. Other
  11293.  user-supplied values for pResumeKey must have been returned by a preceding
  11294.  call to NetFileEnum2.
  11295.  
  11296.  On heavily loaded servers, the information returned by NetFileEnum2 can
  11297.  exceed the maximum allowed buffer size of 64K and generate ERROR_MORE_DATA
  11298.  return codes.
  11299.  
  11300.  The amount of data returned can be minimized by specifying the base path or
  11301.  username. If both the pszUserName and pszBasePath parameters are specified,
  11302.  only files that match both qualifying conditions are returned.
  11303.  
  11304.  NetFileEnum2 supports level 0, 1, 2, and 3 file_info_X data structures.
  11305.  
  11306.  NetFileEnum2 supersedes NetFileEnum (used in earlier versions of LAN
  11307.  Manager). NetFileEnum2 is the same as NetFileEnum except that NetFileEnum2
  11308.  includes the pResumeKey parameter. For more information, see Appendix B,
  11309.  "Upgrading LAN Manager 1.0 Applications."
  11310.  
  11311.  See Also
  11312.  
  11313.  For information about             See
  11314.  ────────────────────────────────────────────────────────────────────────────
  11315.  Closing open files, devices, or   NetFileClose2
  11316.  pipes
  11317.  
  11318.  Obtaining information about a     NetFileGetInfo2
  11319.  specified open resource
  11320.  
  11321.  
  11322.  NetFileGetInfo2
  11323.  ────────────────────────────────────────────────────────────────────────────
  11324.  
  11325.  NetFileGetInfo2 retrieves information about a particular opening of a server
  11326.  resource.
  11327.  
  11328.  
  11329.  Operating Systems Supported
  11330.  
  11331.  
  11332.    ■   MS OS/2 version 1.2, local and remote
  11333.  
  11334.    ■   MS OS/2 version 1.1, remote only
  11335.  
  11336.    ■   MS-DOS, remote only
  11337.  
  11338.  
  11339.  
  11340.  Privilege Level
  11341.  
  11342.  Admin privilege or server operator privilege is required to successfully
  11343.  execute NetFileGetInfo2 on a remote server or on a computer that has local
  11344.  security enabled.
  11345.  
  11346.  
  11347.  Syntax
  11348.  
  11349.    #define INCL_NETFILE
  11350.    #define INCL_NETERRORS
  11351.    #include <lan.h>
  11352.  
  11353.    API_FUNCTION
  11354.    NetFileGetInfo2 (const char far *      pszServer,
  11355.                     unsigned long         ulFileId,
  11356.                     short                 sLevel,
  11357.                     char far *            pbBuffer,
  11358.                     unsigned short        cbBuffer,
  11359.                     unsigned short far *  pcbTotalAvail
  11360.                    );
  11361.  
  11362.  where
  11363.  
  11364.  pszServer
  11365.    Points to an ASCIIZ string that contains the name of the server on which
  11366.    to execute NetFileGetInfo2. A null pointer or null string specifies the
  11367.    local computer.
  11368.  
  11369.  ulFileId
  11370.    Specifies the identification number assigned to the resource when it was
  11371.    opened.
  11372.  
  11373.  sLevel
  11374.    Specifies the level of detail (0, 1, 2, or 3) to be returned.
  11375.  
  11376.  pbBuffer
  11377.    Points to the buffer in which to store the return data. On a successful
  11378.    return, the buffer contains a sequence of file_info_X data structures,
  11379.    where X is 0, 1, 2, or 3, depending on the level of detail specified.
  11380.  
  11381.  cbBuffer
  11382.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  11383.  
  11384.  pcbTotalAvail
  11385.    Points to an unsigned short integer that specifies how many bytes of
  11386.    information were available. This count is valid only if NetFileGetInfo2
  11387.    returns NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  11388.  
  11389.  Return Codes
  11390.  
  11391. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  11392.  Code                              Value   Meaning
  11393.  ────────────────────────────────────────────────────────────────────────────
  11394.  NERR_Success                      0       The function encountered no
  11395.                                            errors.
  11396.  
  11397.  ERROR_ACCESS_DENIED               5       The user has insufficient
  11398.                                            privilege for this operation.
  11399.  
  11400.  ERROR_NOT_SUPPORTED               50      This network request is not
  11401.                                            supported.
  11402.  
  11403.  ERROR_BAD_NETPATH                 53      The network path was not found.
  11404.  
  11405.  Code                              Value   Meaning
  11406.  ────────────────────────────────────────────────────────────────────────────
  11407. 
  11408.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  11409.  
  11410.  ERROR_INVALID_LEVEL               124     The level for information
  11411.                                            retrieval or setting is invalid.
  11412.  
  11413.  ERROR_MORE_DATA                   234     Additional data is available.
  11414.  
  11415.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  11416.                                            is not installed.
  11417.  
  11418.  NERR_RemoteOnly                   2106    This operation can be performed
  11419.                                            only on a server.
  11420.  
  11421.  NERR_ServerNotStarted             2114    The Server service is not
  11422.                                            started.
  11423.  
  11424.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  11425.  
  11426.  Code                              Value   Meaning
  11427.  ────────────────────────────────────────────────────────────────────────────
  11428. 
  11429.  NERR_WkstaNotStarted              2138    The Workstation service is not
  11430.                                            started.
  11431.  
  11432.  NERR_BadTransactConfig            2141    The server is not configured for
  11433.                                            this transaction: IPC$ is not
  11434.                                            shared.
  11435.  
  11436.  NERR_InvalidAPI                   2142    The requested API is not
  11437.                                            supported on the remote server.
  11438.  
  11439.  NERR_FileIdNotFound               2314    There is no open file with this
  11440.                                            ID number.
  11441.  
  11442.  NERR_InvalidComputer              2351    The specified computername is
  11443.                                            invalid.
  11444.  
  11445.  ────────────────────────────────────────────────────────────────────────────
  11446.  
  11447.  Code                              Value   Meaning
  11448.  ────────────────────────────────────────────────────────────────────────────
  11449. 
  11450.  
  11451.  
  11452.  
  11453.  Remarks
  11454.  
  11455.  NetFileGetInfo2 supports level 0, 1, 2, and 3 file_info_X data structures.
  11456.  
  11457.  NetFileGetInfo2 supersedes NetFileGetInfo (used in earlier versions of LAN
  11458.  Manager). NetFileGetInfo2 is the same as NetFileGetInfo except that
  11459.  NetFileGetInfo2 has an unsigned long ulFileId parameter instead of an
  11460.  unsigned short usFileId parameter. For more information, see Appendix B,
  11461.  "Upgrading LAN Manager 1.0 Applications."
  11462.  
  11463.  See Also
  11464.  
  11465.  For information about             See
  11466.  ────────────────────────────────────────────────────────────────────────────
  11467.  Closing a file, device, or pipe   NetFileClose2
  11468.  
  11469.  Listing files, devices, or pipes  NetFileEnum2
  11470.  open on a server
  11471.  
  11472.  
  11473.  
  11474.  
  11475.  
  11476.  File Category Example
  11477.  
  11478.    /*
  11479.       NETFILE.C -- a sample program demonstrating NetFile API functions.
  11480.  
  11481.       This program requires that you have admin privilege on the specified
  11482.       server.
  11483.  
  11484.          usage:  netfile [-s \\server] [-b basepath] [-u username]
  11485.  
  11486.          where  \\server = Name of the server. A servername must be
  11487.                            preceded by two backslashes (\\).
  11488.                 basepath = Enumerate only open files along this path.
  11489.                 username = Enumerate only files opened by this user.
  11490.  
  11491.       API                 Used to...
  11492.       ===============     ================================================
  11493.       NetFileEnum2        List files in the base path opened by user
  11494.       NetFileGetInfo2     Get information available about each listed
  11495.    file
  11496.       NetFileClose2       Close specified files on the specified server
  11497.  
  11498.       This sample code is provided for demonstration purposes only.
  11499.       Microsoft makes no warranty, either express or implied,
  11500.       as to its usability in any given situation.
  11501.  
  11502.    */
  11503.  
  11504.    #define     INCL_NETFILE
  11505.    #define     INCL_NETERRORS
  11506.    #include    <lan.h>        // LAN Manager header files
  11507.  
  11508.    #include    <stdio.h>      // C run-time header files
  11509.    #include    <stdlib.h>
  11510.    #include    <string.h>
  11511.  
  11512.    #include    "samples.h"    // Internal routine header file
  11513.  
  11514.    void Usage(char *pszString);
  11515.  
  11516.    void main(int argc, char *argv[])
  11517.    {
  11518.       char *pszServerName = "";              // Required parameters for
  11519.    calls
  11520.       char far *pszBasePath = (char far *) NULL;
  11521.       char far *pszUserName = (char far *) NULL;
  11522.       API_RET_TYPE   uReturnCode;            // API return codes
  11523.       int            iCount;                 // Index counter
  11524.  
  11525.    unsigned short cbBuflen;               // Count of bytes
  11526.       unsigned short cEntriesRead;           // Entries read
  11527.       unsigned short cEntriesRemaining;      // Entries remaining to
  11528.    be read
  11529.       unsigned short cGetEntries = 0;        // Count of all enumerated
  11530.    IDs
  11531.       unsigned short cbTotalAvail;           // Count of bytes available
  11532.       unsigned short fTableAllocated = 0;    // Flag to build table of
  11533.    IDs
  11534.       struct file_info_3 *pBuf3, *p3;        // File IDs; use only level
  11535.    2,3
  11536.       FRK resumekey;   // File resume key, used when enum data > buffer
  11537.    size
  11538.       unsigned long *pulIds, *pulStartId;    // List of file IDs
  11539.  
  11540.       for (iCount = 1; iCount < argc; iCount++)
  11541.       {
  11542.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  11543.          {
  11544.             switch (tolower(*(argv[iCount]+1))) // Process switches
  11545.             {
  11546.                case 's':                        // -s servername
  11547.                   pszServerName = argv[++iCount];
  11548.                   break;
  11549.                case 'b':                        // -b base path
  11550.                   pszBasePath = (char far *)argv[++iCount];
  11551.                   break;
  11552.                case 'u':                        // -u username
  11553.                   pszUserName = (char far *)argv[++iCount];
  11554.                   break;
  11555.                case 'h':
  11556.                default:
  11557.                   Usage(argv[0]);
  11558.             }
  11559.          }
  11560.          else
  11561.             Usage(argv[0]);
  11562.       } // End for loop
  11563.  
  11564.       printf("\nFile Category API Examples\n");
  11565.       if (pszServerName[0] != '\0')
  11566.          printf("Server = %s\n", pszServerName);
  11567.       if (pszBasePath != NULL)
  11568.          printf("Base path = %s\n", pszBasePath);
  11569.       if (pszUserName != NULL)
  11570.          printf("User name = %s\n", pszUserName);
  11571.  
  11572.    //========================================================================
  11573.    //  NetFileEnum2
  11574.    //
  11575.    //  This API lists all open files on the server below the specified
  11576.    given
  11577.    //  base path. If no base path is given, all open files are listed.
  11578.    //========================================================================
  11579.       cbBuflen = 256;      // Small size to demonstrate use of resume
  11580.    key
  11581.       pBuf3 = (struct file_info_3 *) SafeMalloc(cbBuflen);
  11582.       p3 = pBuf3;          // Save pointer for free() cleanup at end
  11583.       FRK_INIT(resumekey); // Must init file resume key; use SHARES.H
  11584.    macro
  11585.  
  11586.       do                   // Use resume key and loop until done
  11587.       {
  11588.          uReturnCode = NetFileEnum2(pszServerName,    // NULL means local
  11589.                                   pszBasePath,        // NULL means root
  11590.                                   pszUserName,        // NULL means all
  11591.    users
  11592.                                   3,                  // Level (0 through
  11593.    3)
  11594.                                   (char far *)pBuf3,  // Return buffer
  11595.                                   cbBuflen,           // Return buffer
  11596.    length
  11597.                                   &cEntriesRead,      // Count of entries
  11598.    read
  11599.                                   &cEntriesRemaining, // Entries not
  11600.    read
  11601.                                   &resumekey);        // Resume key
  11602.  
  11603.          printf("NetFileEnum2 returned %u\n", uReturnCode);
  11604.          if (uReturnCode == NERR_Success || uReturnCode == ERROR_MORE_DATA)
  11605.          {
  11606.             printf("   Entries read = %hu, Entries remaining = %hu\n",
  11607.  
  11608.                           cEntriesRead, cEntriesRemaining);
  11609.                // Save the file IDs.
  11610.             if (cEntriesRead > 0)
  11611.             {
  11612.                // Allocate memory for file ID table first time through
  11613.    only.
  11614.                if (fTableAllocated == 0)
  11615.                {
  11616.                   cGetEntries = cEntriesRead + cEntriesRemaining;
  11617.                   pulStartId = pulIds = (unsigned long *)
  11618.                              SafeMalloc(cGetEntries * sizeof(unsigned
  11619.    long));
  11620.                   fTableAllocated = 1;         // Assure allocate only
  11621.    once
  11622.                }
  11623.  
  11624.                // Print the file information.
  11625.                printf("   Id      Perms   Locks   User            Path\n");
  11626.                for (iCount = 0; iCount < (int) cEntriesRead; iCount++)
  11627.                {
  11628.                   printf("   %-8lu%-8hu%-8hu%-16Fs%Fs\n", pBuf3->fi3_id,
  11629.                         pBuf3->fi3_permissions, pBuf3->fi3_num_locks,
  11630.                         pBuf3->fi3_username, pBuf3->fi3_pathname);
  11631.  
  11632.                   *pulIds = pBuf3->fi3_id;
  11633.                   pulIds++;
  11634.                   pBuf3++;
  11635.                } // End for loop
  11636.                pBuf3 = p3;   // Pointer was changed; restore to top of
  11637.    buffer
  11638.             } // End if cEntriesRead > 0
  11639.          } // End if successful call
  11640.       } while (uReturnCode == ERROR_MORE_DATA); // Use FRK until enum
  11641.    all
  11642.       free(p3);
  11643.  
  11644.    //========================================================================
  11645.    //  NetFileGetInfo2
  11646.    //
  11647.    //  This API retrieves all file IDs listed from the NetFileEnum2 call.
  11648.    //========================================================================
  11649.  
  11650.       if (cGetEntries != 0)
  11651.       {
  11652.          cbBuflen = 1024;
  11653.          pBuf3 = (struct file_info_3 *) SafeMalloc(cbBuflen);
  11654.          p3 = pBuf3;           // Save pointer for free() cleanup at
  11655.    end
  11656.          pulIds = pulStartId;  // Start at beginning of list
  11657.          printf("NetFileGetInfo2 results:\n");
  11658.          for (iCount = 0; iCount < (int) cGetEntries; iCount++)
  11659.          {
  11660.             uReturnCode = NetFileGetInfo2(
  11661.                                  pszServerName,      // NULL means local
  11662.                                  *pulIds,            // File ID from
  11663.    enum
  11664.                                  3,                  // Level (0 through
  11665.    3)
  11666.                                  (char far *)pBuf3,  // Return buffer
  11667.                                  cbBuflen,           // Return buffer
  11668.    length
  11669.                                  &cbTotalAvail);     // Entries not yet
  11670.    read
  11671.  
  11672.             if (uReturnCode)
  11673.                printf("NetFileGetInfo2 for file %lu returned %u\n",
  11674.                      *pulIds, uReturnCode);
  11675.             else
  11676.                printf("   File %lu: %-8hu%-8hu%-16Fs%Fs\n", *pulIds,
  11677.                      pBuf3->fi3_permissions, pBuf3->fi3_num_locks,
  11678.                      pBuf3->fi3_username, pBuf3->fi3_pathname);
  11679.             pulIds++;
  11680.          }
  11681.       }
  11682.  
  11683.    //========================================================================
  11684.    //  NetFileClose2
  11685.    //
  11686.    //  This API closes the specified open files on the specified server.
  11687.    //========================================================================
  11688.  
  11689.       if (cGetEntries != 0)
  11690.       {
  11691.          pulIds = pulStartId;
  11692.          for (iCount = 0; iCount < (int) cGetEntries; iCount++)
  11693.          {
  11694.             uReturnCode = NetFileClose2(pszServerName,    // NULL means
  11695.    local
  11696.                                  (unsigned long)*pulIds); // File ID
  11697.    from enum
  11698.  
  11699.             printf("NetFileClose2 for file %lu returned %u\n",
  11700.                            *pulIds, uReturnCode);
  11701.             pulIds++;
  11702.          }
  11703.          free(pulStartId);
  11704.       }
  11705.  
  11706.       free(p3);
  11707.       exit(0);
  11708.    }
  11709.  
  11710.    void Usage(char *pszString)
  11711.    {
  11712.       fprintf(stderr, "Usage: %s [-s \\\\server] [-b basepath] "
  11713.                       "[-u username]\n", pszString);
  11714.       exit(1);
  11715.    }
  11716.  
  11717.  
  11718.  
  11719.  
  11720.  
  11721.  
  11722.  
  11723.  Group Category
  11724.  
  11725.  Group API functions control groups of users. The Group API functions require
  11726.  that the user account subsystem (UAS) be started. On most computers the UAS
  11727.  is started when the Workstation service is started, provided a valid user
  11728.  accounts database file exists. On computers using the high-performance file
  11729.  system 386 (HPFS386) with local security enabled, the UAS is started
  11730.  automatically as part of the boot process.
  11731.  
  11732.  The Group category functions, datatypes, structures, and constants are
  11733.  defined in the NETCONS.H, NETERR.H, and ACCESS.H header files. A source
  11734.  program can access these definitions by defining the constants
  11735.  INCL_NETERRORS and INCL_NETGROUP, and including the master header file,
  11736.  LAN.H. For more information about these definitions,  see the "Example"
  11737.  section, later in this category.
  11738.  
  11739.  These are the Group API functions:
  11740.  
  11741.  
  11742.    ■   NetGroupAdd
  11743.  
  11744.    ■   NetGroupAddUser
  11745.  
  11746.    ■   NetGroupDel
  11747.  
  11748.    ■   NetGroupDelUser
  11749.  
  11750.    ■   NetGroupEnum
  11751.  
  11752.    ■   NetGroupGetInfo
  11753.  
  11754.    ■   NetGroupGetUsers
  11755.  
  11756.    ■   NetGroupSetInfo
  11757.  
  11758.    ■   NetGroupSetUsers
  11759.  
  11760.  
  11761.  
  11762.  Description
  11763.  
  11764.  A group is a set of users who share common permissions in the user accounts
  11765.  subsystem database. Group API functions create or delete groups, and review
  11766.  or adjust the membership of the groups. The group has a groupname that
  11767.  specifies the usernames of group members.
  11768.  
  11769.  An administrator can assign access permissions for all members of a group by
  11770.  supplying the groupname to NetAccessAdd instead of assigning each user an
  11771.  individual access permission record. For more information, see the Access
  11772.  Permissions category API functions.
  11773.  
  11774.  To create a group, an application calls NetGroupAdd, supplying a groupname.
  11775.  Initially, the group has no members. To assign members to the group, call
  11776.  NetGroupSetUsers. To add a user to an existing group, call NetGroupAddUser.
  11777.  To set general information about the group, call NetGroupSetInfo.
  11778.  
  11779.  
  11780.  NetGroupDelUser deletes a specified username from a group, and NetGroupDel
  11781.  disbands a group. NetGroupDel works whether or not the group has any
  11782.  members.
  11783.  
  11784.  Three Group category API functions retrieve information about the groups on
  11785.  a server: NetGroupEnum produces a list of all groups; NetGroupGetUsers lists
  11786.  all members of a specified group; and NetGroupGetInfo returns general
  11787.  information about the group.
  11788.  
  11789.  All Group API functions executed on a remote server (except
  11790.  NetGroupGetUsers) require that that server have user-level security.
  11791.  Attempting to execute one of these Group API functions on a remote server
  11792.  that has share-level security results in the return code
  11793.  ERROR_NOT_SUPPORTED.
  11794.  
  11795.  LAN Manager supports as many as 252 groups in addition to the special groups
  11796.  admins, guests, users, and local.
  11797.  
  11798.  Each user account automatically belongs to one of the special groups users,
  11799.  admins, or guests, according to the user's privilege level. Membership of
  11800.  these groups is indirectly controlled by the NetUserAdd, NetUserDel, and
  11801.  NetUserSetInfo functions. The local group has no members. For more
  11802.  information, see the User category API functions.
  11803.  
  11804.  Only NetGroupEnum and NetGroupGetUsers can operate on the special groups,
  11805.  but NetGroupEnum does not list the group local.
  11806.  
  11807.  
  11808.  Data Structures
  11809.  
  11810.  NetGroupAdd, NetGroupEnum, and NetGroupGetInfo use the group_info_0 data
  11811.  structure. These three functions and NetGroupSetInfo use the group_info_1
  11812.  data structure.
  11813.  
  11814.  NetGroupGetUsers and NetGroupSetUsers use the group_users_info_0 data
  11815.  structure.
  11816.  
  11817.  
  11818.  Group Information (level 0)
  11819.  
  11820.  The group_info_0 data structure has this format:
  11821.  
  11822.    struct group_info_0 {
  11823.        char grpi0_name[GNLEN+1];
  11824.    };
  11825.  
  11826.  where
  11827.  
  11828.  grpi0_name
  11829.    Contains an ASCIIZ string that specifies a groupname. The constant GNLEN
  11830.    is defined in the NETCONS.H header file.
  11831.  
  11832.  
  11833.  Group Information (level 1)
  11834.  
  11835.  The group_info_1 data structure has this format:
  11836.  
  11837.    struct group_info_1 {
  11838.        char       grpi1_name[GNLEN+1];
  11839.        char       grpi1_pad;
  11840.        char far * grpi1_comment;
  11841.    };
  11842.  
  11843.  where
  11844.  
  11845.  grpi1_name
  11846.    Contains an ASCIIZ string that specifies a groupname. The constant GNLEN
  11847.    is defined in the NETCONS.H header file.
  11848.  
  11849.  grpi1_pad
  11850.    Aligns the next data structure element on a word boundary.
  11851.  
  11852.  grpi1_comment
  11853.    Points to an ASCIIZ string that contains a remark for the group. This
  11854.    element can be a null string. The comment can have as many as
  11855.    MAXCOMMENTSZ+1 characters, as defined in the NETCONS.H header file.
  11856.  
  11857.  
  11858.  Group Membership Information (level 0)
  11859.  
  11860.  The group_users_info_0 data structure has this format:
  11861.  
  11862.    struct group_users_info_0 {
  11863.        char  grui0_name[UNLEN+1];
  11864.    };
  11865.  
  11866.  where
  11867.  
  11868.  grui0_name
  11869.    Contains an ASCIIZ string that specifies the name of a group member. The
  11870.    constant UNLEN is defined in the NETCONS.H header file.
  11871.  
  11872.  
  11873.  NetGroupAdd
  11874.  ────────────────────────────────────────────────────────────────────────────
  11875.  
  11876.  NetGroupAdd creates a group account in the user accounts subsystem (UAS)
  11877.  database.
  11878.  
  11879.  
  11880.  Operating Systems Supported
  11881.  
  11882.  
  11883.    ■   MS OS/2 version 1.2, local and remote
  11884.  
  11885.    ■   MS OS/2 version 1.1, remote only
  11886.  
  11887.    ■   MS-DOS, remote only
  11888.  
  11889.  
  11890.  
  11891.  Privilege Level
  11892.  
  11893.  Admin privilege or accounts operator privilege is required to successfully
  11894.  execute NetGroupAdd on a remote server or on a computer that has local
  11895.  security enabled.
  11896.  
  11897.  
  11898.  Syntax
  11899.  
  11900.    #define INCL_NETGROUP
  11901.    #define INCL_NETERRORS
  11902.    #include <lan.h>
  11903.  
  11904.    API_FUNCTION
  11905.    NetGroupAdd (const char far *  pszServer,
  11906.                 short             sLevel,
  11907.                 char far *        pbBuffer,
  11908.                 unsigned short    cbBuffer
  11909.                );
  11910.  
  11911.  where
  11912.  
  11913.  pszServer
  11914.    Points to an ASCIIZ string that contains the name of the server on which
  11915.    to execute NetGroupAdd. A null pointer or null string specifies the local
  11916.    computer.
  11917.  
  11918.  sLevel
  11919.    Specifies the level of detail (0 or 1) for the data to be set.
  11920.  
  11921.  pbBuffer
  11922.    Points to the buffer in which the data to be set is located. This buffer
  11923.    should contain a group_info_0 (level 0 call) or group_info_1 (level 1
  11924.    call) data structure.
  11925.  
  11926.  cbBuffer
  11927.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  11928.  
  11929.  Return Codes
  11930.  
  11931. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  11932.  Code                              Value   Meaning
  11933.  ────────────────────────────────────────────────────────────────────────────
  11934.  NERR_Success                      0       The function encountered no
  11935.                                            errors.
  11936.  
  11937.  ERROR_ACCESS_DENIED               5       The user has insufficient
  11938.                                            privilege for this operation.
  11939.  
  11940.  ERROR_NOT_SUPPORTED               50      This network request is not
  11941.                                            supported.
  11942.  
  11943.  ERROR_BAD_NETPATH                 53      The network path was not found.
  11944.  
  11945.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  11946.  
  11947.  ERROR_INVALID_LEVEL               124     The level for information
  11948.                                            retrieval or setting is invalid.
  11949.  
  11950.  NERR_RemoteOnly                   2106    This operation can be performed
  11951.  Code                              Value   Meaning
  11952.  ────────────────────────────────────────────────────────────────────────────
  11953. NERR_RemoteOnly                   2106    This operation can be performed
  11954.                                            only on a server.
  11955.  
  11956.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  11957.  
  11958.  NERR_WkstaNotStarted              2138    The Workstation service is not
  11959.                                            started.
  11960.  
  11961.  NERR_BadTransactConfig            2141    The server is not configured for
  11962.                                            this transaction: IPC$ is not
  11963.                                            shared.
  11964.  
  11965.  NERR_BadUsername                  2202    The username or groupname is
  11966.                                            invalid.
  11967.  
  11968.  NERR_GroupExists                  2223    The groupname already exists.
  11969.  
  11970.  NERR_UserExists                   2224    The user account already exists.
  11971.  
  11972.  Code                              Value   Meaning
  11973.  ────────────────────────────────────────────────────────────────────────────
  11974. 
  11975.  NERR_NotPrimary                   2226    The specified server is not the
  11976.                                            primary domain controller, so
  11977.                                            its UAS database cannot be
  11978.                                            updated.
  11979.  
  11980.  NERR_ACFNotLoaded                 2227    The user accounts database is
  11981.                                            not active. This database must
  11982.                                            be active for the command to run.
  11983.  
  11984.  NERR_ACFNoRoom                    2228    The user accounts database is
  11985.                                            full.
  11986.  
  11987.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  11988.  
  11989.  NERR_InvalidDatabase              2247    The user accounts database file,
  11990.                                            NET.ACC, is corrupted.
  11991.  
  11992.  NERR_InvalidComputer              2351    The specified computername is
  11993.  Code                              Value   Meaning
  11994.  ────────────────────────────────────────────────────────────────────────────
  11995. NERR_InvalidComputer              2351    The specified computername is
  11996.                                            invalid.
  11997.  
  11998.  NERR_CanNotGrowUASFile            2456    The user accounts database
  11999.                                            cannot be enlarged because the
  12000.                                            server's hard disk is full.
  12001.  
  12002.  ────────────────────────────────────────────────────────────────────────────
  12003.  
  12004.  
  12005.  
  12006.  
  12007.  Remarks
  12008.  
  12009.  NetGroupAdd returns NERR_UserExists if the groupname specified is already
  12010.  being used as a username.
  12011.  
  12012.  NetGroupAdd supports level 0 and level 1 data structures. When adding a
  12013.  group account at level 0, the comment element is set to a null string
  12014.  because the group_info_0 data structure does not provide a comment element.
  12015.  
  12016.  
  12017.  See Also
  12018.  
  12019.  For information about             See
  12020.  ────────────────────────────────────────────────────────────────────────────
  12021.  Adding a single user to a group   NetGroupAddUser
  12022.  
  12023.  Assigning group permissions       NetAccessAdd
  12024.  
  12025.  Deleting a group account from a   NetGroupDel
  12026.  server
  12027.  
  12028.  Listing all groups on a server    NetGroupEnum
  12029.  
  12030.  Remote calls                      Chapter 1, "Overview of the LAN Manager
  12031.                                    API"
  12032.  
  12033.  Setting the list of all users in  NetGroupSetUsers
  12034.  a group
  12035.  
  12036.  
  12037.  NetGroupAddUser
  12038.  ────────────────────────────────────────────────────────────────────────────
  12039.  
  12040.  NetGroupAddUser adds a user to a group in the user accounts subsystem (UAS)
  12041.  database.
  12042.  
  12043.  
  12044.  Operating Systems Supported
  12045.  
  12046.  
  12047.    ■   MS OS/2 version 1.2, local and remote
  12048.  
  12049.    ■   MS OS/2 version 1.1, remote only
  12050.  
  12051.    ■   MS-DOS, remote only
  12052.  
  12053.  
  12054.  
  12055.  Privilege Level
  12056.  
  12057.  Admin privilege or accounts operator privilege is required to successfully
  12058.  execute NetGroupAddUser on a remote server or on a computer that has local
  12059.  security enabled.
  12060.  
  12061.  
  12062.  Syntax
  12063.  
  12064.    #define INCL_NETGROUP
  12065.    #define INCL_NETERRORS
  12066.    #include <lan.h>
  12067.  
  12068.    API_FUNCTION
  12069.    NetGroupAddUser (const char far *  pszServer,
  12070.                     char far *        pszGroupName,
  12071.                     char far *        pszUserName
  12072.                    );
  12073.  
  12074.  where
  12075.  
  12076.  pszServer
  12077.    Points to an ASCIIZ string that contains the name of the server on which
  12078.    to execute NetGroupAddUser. A null pointer or null string specifies the
  12079.    local computer.
  12080.  
  12081.  pszGroupName
  12082.    Points to an ASCIIZ string that specifies which group the user will join.
  12083.  
  12084.  pszUserName
  12085.    Points to an ASCIIZ string that specifies which user to add to the group.
  12086.  
  12087.  Return Codes
  12088.  
  12089. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  12090.  Code                              Value   Meaning
  12091.  ────────────────────────────────────────────────────────────────────────────
  12092.  NERR_Success                      0       The function encountered no
  12093.                                            errors.
  12094.  
  12095.  ERROR_ACCESS_DENIED               5       The user has insufficient
  12096.                                            privilege for this operation.
  12097.  
  12098.  Code                              Value   Meaning
  12099.  ────────────────────────────────────────────────────────────────────────────
  12100. 
  12101.  ERROR_NOT_SUPPORTED               50      This network request is not
  12102.                                            supported.
  12103.  
  12104.  ERROR_BAD_NETPATH                 53      The network path was not found.
  12105.  
  12106.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  12107.  
  12108.  NERR_RemoteOnly                   2106    This operation can be performed
  12109.                                            only on a server.
  12110.  
  12111.  NERR_WkstaNotStarted              2138    The Workstation service is not
  12112.                                            started.
  12113.  
  12114.  NERR_BadTransactConfig            2141    The server is not configured for
  12115.                                            this transaction: IPC$ is not
  12116.                                            shared.
  12117.  
  12118.  NERR_BadUsername                  2202    The username or groupname is
  12119.  Code                              Value   Meaning
  12120.  ────────────────────────────────────────────────────────────────────────────
  12121. NERR_BadUsername                  2202    The username or groupname is
  12122.                                            invalid.
  12123.  
  12124.  NERR_GroupNotFound                2220    The groupname was not found.
  12125.  
  12126.  NERR_UserNotFound                 2221    The username was not found.
  12127.  
  12128.  NERR_NotPrimary                   2226    The specified server is not the
  12129.                                            primary domain controller, so
  12130.                                            its UAS database cannot be
  12131.                                            updated.
  12132.  
  12133.  NERR_ACFNotLoaded                 2227    The user accounts database is
  12134.                                            not active. This database must
  12135.                                            be active for the command to run.
  12136.  
  12137.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  12138.  
  12139.  NERR_SpeGroupOp                   2234    This operation is not allowed on
  12140.  Code                              Value   Meaning
  12141.  ────────────────────────────────────────────────────────────────────────────
  12142. NERR_SpeGroupOp                   2234    This operation is not allowed on
  12143.                                            this special group.
  12144.  
  12145.  NERR_UserInGroup                  2236    The user already belongs to this
  12146.                                            group.
  12147.  
  12148.  NERR_InvalidDatabase              2247    The user accounts database file,
  12149.                                            NET.ACC, is corrupted.
  12150.  
  12151.  NERR_InvalidComputer              2351    The specified computername is
  12152.                                            invalid.
  12153.  
  12154.  NERR_CanNotGrowUASFile            2456    The user accounts database
  12155.                                            cannot be enlarged because the
  12156.                                            server's hard disk is full.
  12157.  
  12158.  ────────────────────────────────────────────────────────────────────────────
  12159.  
  12160.  
  12161.  
  12162.  
  12163.  Remarks
  12164.  
  12165.  If an attempt is made to add a user to the users, guests, admins, or local
  12166.  special groups, NetGroupAddUser returns NERR_SpeGroupOp.
  12167.  
  12168.  See Also
  12169.  
  12170.  For information about             See
  12171.  ────────────────────────────────────────────────────────────────────────────
  12172.  Creating a new group              NetGroupAdd
  12173.  
  12174.  Defining group access             Access Permissions Category
  12175.  permissions
  12176.  
  12177.  Removing a user from a group      NetGroupDelUser
  12178.  
  12179.  Retrieving a list of group        NetGroupGetUsers
  12180.  members
  12181.  
  12182.  
  12183.  NetGroupDel
  12184.  ────────────────────────────────────────────────────────────────────────────
  12185.  
  12186.  NetGroupDel removes a group account from the user accounts subsystem (UAS)
  12187.  database.
  12188.  
  12189.  
  12190.  Operating Systems Supported
  12191.  
  12192.  
  12193.    ■   MS OS/2 version 1.2, local and remote
  12194.  
  12195.    ■   MS OS/2 version 1.1, remote only
  12196.  
  12197.    ■   MS-DOS, remote only
  12198.  
  12199.  
  12200.  
  12201.  Privilege Level
  12202.  
  12203.  Admin privilege or accounts operator privilege is required to successfully
  12204.  execute NetGroupDel on a remote server or on a computer that has local
  12205.  security enabled.
  12206.  
  12207.  
  12208.  Syntax
  12209.  
  12210.    #define INCL_NETGROUP
  12211.    #define INCL_NETERRORS
  12212.    #include <lan.h>
  12213.  
  12214.    API_FUNCTION
  12215.    NetGroupDel (const char far *  pszServer,
  12216.                 char far *        pszGroupName
  12217.                );
  12218.  
  12219.  where
  12220.  
  12221.  pszServer
  12222.    Points to an ASCIIZ string that contains the name of the server on which
  12223.    to execute NetGroupDel. A null pointer or null string specifies the local
  12224.    computer.
  12225.  
  12226.  pszGroupName
  12227.    Points to an ASCIIZ string that specifies which group to remove.
  12228.  
  12229.  Return Codes
  12230.  
  12231. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  12232.  Code                              Value   Meaning
  12233.  ────────────────────────────────────────────────────────────────────────────
  12234.  NERR_Success                      0       The function encountered no
  12235.                                            errors.
  12236.  
  12237.  ERROR_ACCESS_DENIED               5       The user has insufficient
  12238.                                            privilege for this operation.
  12239.  
  12240.  ERROR_NOT_SUPPORTED               50      This network request is not
  12241.                                            supported.
  12242.  
  12243.  ERROR_BAD_NETPATH                 53      The network path was not found.
  12244.  
  12245.  Code                              Value   Meaning
  12246.  ────────────────────────────────────────────────────────────────────────────
  12247. 
  12248.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  12249.  
  12250.  NERR_RemoteOnly                   2106    This operation can be performed
  12251.                                            only on a server.
  12252.  
  12253.  NERR_WkstaNotStarted              2138    The Workstation service is not
  12254.                                            started.
  12255.  
  12256.  NERR_BadTransactConfig            2141    The server is not configured for
  12257.                                            this transaction: IPC$ is not
  12258.                                            shared.
  12259.  
  12260.  NERR_InvalidAPI                   2142    The requested API is not
  12261.                                            supported on the remote server.
  12262.  
  12263.  NERR_GroupNotFound                2220    The groupname was not found.
  12264.  
  12265.  NERR_NotPrimary                   2226    The specified server is not the
  12266.  Code                              Value   Meaning
  12267.  ────────────────────────────────────────────────────────────────────────────
  12268. NERR_NotPrimary                   2226    The specified server is not the
  12269.                                            primary domain controller, so
  12270.                                            its UAS database cannot be
  12271.                                            updated.
  12272.  
  12273.  NERR_ACFNotLoaded                 2227    The user accounts database is
  12274.                                            not active. This database must
  12275.                                            be active for the command to run.
  12276.  
  12277.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  12278.  
  12279.  NERR_SpeGroupOp                   2234    This operation is not allowed on
  12280.                                            this special group.
  12281.  
  12282.  NERR_InvalidDatabase              2247    The user accounts database file,
  12283.                                            NET.ACC, is corrupted.
  12284.  
  12285.  NERR_InvalidComputer              2351    The specified computername is
  12286.                                            invalid.
  12287.  Code                              Value   Meaning
  12288.  ────────────────────────────────────────────────────────────────────────────
  12289.                                           invalid.
  12290.  
  12291.  ────────────────────────────────────────────────────────────────────────────
  12292.  
  12293.  
  12294.  
  12295.  
  12296.  Remarks
  12297.  
  12298.  It is not necessary to remove all members from a group before deleting the
  12299.  group account. Deleting a group deletes it from the access control profiles,
  12300.  but does not delete the individual accounts of its members.
  12301.  
  12302.  If an attempt is made to delete one of the users, guests, admins, or local
  12303.  special groups, NetGroupDel returns NERR_SpeGroupOp.
  12304.  
  12305.  See Also
  12306.  
  12307.  For information about             See
  12308.  ────────────────────────────────────────────────────────────────────────────
  12309.  Adding a group to a server        NetGroupAdd
  12310.  
  12311.  Listing all groups on a server    NetGroupEnum
  12312.  
  12313.  Removing a user from a group      NetGroupDelUser
  12314.  
  12315.  
  12316.  NetGroupDelUser
  12317.  ────────────────────────────────────────────────────────────────────────────
  12318.  
  12319.  NetGroupDelUser removes a user from a particular group in the user accounts
  12320.  subsystem (UAS) database.
  12321.  
  12322.  
  12323.  Operating Systems Supported
  12324.  
  12325.  
  12326.    ■   MS OS/2 version 1.2, local and remote
  12327.  
  12328.    ■   MS OS/2 version 1.1, remote only
  12329.  
  12330.    ■   MS-DOS, remote only
  12331.  
  12332.  
  12333.  
  12334.  Privilege Level
  12335.  
  12336.  Admin privilege or accounts operator privilege is required to successfully
  12337.  execute NetGroupDelUser on a remote server or on a computer that has local
  12338.  security enabled.
  12339.  
  12340.  
  12341.  Syntax
  12342.  
  12343.    #define INCL_NETGROUP
  12344.    #define INCL_NETERRORS
  12345.    #include <lan.h>
  12346.  
  12347.    API_FUNCTION
  12348.    NetGroupDelUser (const char far *  pszServer,
  12349.                     char far *        pszGroupName,
  12350.                     char far *        pszUserName
  12351.                    );
  12352.  
  12353.  where
  12354.  
  12355.  pszServer
  12356.    Points to an ASCIIZ string that contains the name of the remote server on
  12357.    which to execute NetGroupDelUser. A null pointer or null string specifies
  12358.    the local computer.
  12359.  
  12360.  pszGroupName
  12361.    Points to an ASCIIZ string that specifies the group from which to remove
  12362.    the user.
  12363.  
  12364.  pszUserName
  12365.    Points to an ASCIIZ string that specifies which user to remove from the
  12366.    group.
  12367.  
  12368.  Return Codes
  12369.  
  12370. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  12371.  Code                              Value   Meaning
  12372.  ────────────────────────────────────────────────────────────────────────────
  12373.  NERR_Success                      0       The function encountered no
  12374.                                            errors.
  12375.  
  12376.  ERROR_ACCESS_DENIED               5       The user has insufficient
  12377.                                            privilege for this operation.
  12378.  
  12379.  ERROR_NOT_SUPPORTED               50      This network request is not
  12380.                                            supported.
  12381.  
  12382.  ERROR_BAD_NETPATH                 53      The network path was not found.
  12383.  
  12384.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  12385.  
  12386.  NERR_RemoteOnly                   2106    This operation can be performed
  12387.                                            only on a server.
  12388.  
  12389.  NERR_WkstaNotStarted              2138    The Workstation service is not
  12390.                                            started.
  12391.  
  12392.  Code                              Value   Meaning
  12393.  ────────────────────────────────────────────────────────────────────────────
  12394. 
  12395.  NERR_BadTransactConfig            2141    The server is not configured for
  12396.                                            this transaction: IPC$ is not
  12397.                                            shared.
  12398.  
  12399.  NERR_GroupNotFound                2220    The groupname was not found.
  12400.  
  12401.  NERR_UserNotFound                 2221    The username was not found.
  12402.  
  12403.  NERR_NotPrimary                   2226    The specified server is not the
  12404.                                            primary domain controller, so
  12405.                                            its UAS database cannot be
  12406.                                            updated.
  12407.  
  12408.  NERR_ACFNotLoaded                 2227    The user accounts database is
  12409.                                            not active. This database must
  12410.                                            be active for the command to run.
  12411.  
  12412.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  12413.  Code                              Value   Meaning
  12414.  ────────────────────────────────────────────────────────────────────────────
  12415. NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  12416.  
  12417.  NERR_SpeGroupOp                   2234    This operation is not allowed on
  12418.                                            this special group.
  12419.  
  12420.  NERR_UserNotInGroup               2237    The user is not a member of this
  12421.                                            group.
  12422.  
  12423.  NERR_InvalidDatabase              2247    The user accounts database file,
  12424.                                            NET.ACC, is corrupted.
  12425.  
  12426.  NERR_InvalidComputer              2351    The specified computername is
  12427.                                            invalid.
  12428.  
  12429.  ────────────────────────────────────────────────────────────────────────────
  12430.  
  12431.  
  12432.  
  12433.  
  12434.  Remarks
  12435.  
  12436.  Removing a user from a group does not delete the user's account from the
  12437.  system.
  12438.  
  12439.  If an attempt is made to delete a user from the users, guests, admins, or
  12440.  local special groups, NetGroupDelUser returns NERR_SpeGroupOp.
  12441.  
  12442.  See Also
  12443.  
  12444.  For information about             See
  12445.  ────────────────────────────────────────────────────────────────────────────
  12446.  Adding a user to a group          NetGroupAddUser
  12447.  
  12448.  Deleting a group                  NetGroupDel
  12449.  
  12450.  
  12451.  NetGroupEnum
  12452.  ────────────────────────────────────────────────────────────────────────────
  12453.  
  12454.  NetGroupEnum lists all group accounts in the user accounts subsystem (UAS)
  12455.  database.
  12456.  
  12457.  
  12458.  Operating Systems Supported
  12459.  
  12460.  
  12461.    ■   MS OS/2 version 1.2, local and remote
  12462.  
  12463.    ■   MS OS/2 version 1.1, remote only
  12464.  
  12465.    ■   MS-DOS, remote only
  12466.  
  12467.  
  12468.  
  12469.  Privilege Level
  12470.  
  12471.  Admin privilege or accounts operator privilege is required to successfully
  12472.  execute NetGroupEnum at level 1 on a remote server or on a computer that has
  12473.  local security enabled. No special privilege is required for level 0 calls.
  12474.  
  12475.  
  12476.  
  12477.  Syntax
  12478.  
  12479.    #define INCL_NETGROUP
  12480.    #define INCL_NETERRORS
  12481.    #include <lan.h>
  12482.  
  12483.    API_FUNCTION
  12484.    NetGroupEnum (const char far *      pszServer,
  12485.                  short                 sLevel,
  12486.                  char far *            pbBuffer,
  12487.                  unsigned short        cbBuffer,
  12488.                  unsigned short far *  pcEntriesRead,
  12489.                  unsigned short far *  pcTotalAvail
  12490.                 );
  12491.  
  12492.  where
  12493.  
  12494.  pszServer
  12495.    Points to an ASCIIZ string that contains the name of the server on which
  12496.    to execute NetGroupEnum. A null pointer or null string specifies the local
  12497.    computer.
  12498.  
  12499.  sLevel
  12500.    Specifies the level of detail (0 or 1) requested.
  12501.  
  12502.  pbBuffer
  12503.    Points to the buffer in which to store the returned data. On a successful
  12504.    return, the buffer contains a sequence of group_info_X data structures,
  12505.    where X is 0 or 1, depending on the level of detail requested.
  12506.  
  12507.  cbBuffer
  12508.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  12509.  
  12510.  pcEntriesRead
  12511.    Points to an unsigned short integer in which the number of groups
  12512.    enumerated in the buffer pointed to by pbBuffer is returned. This count is
  12513.    valid only if NetGroupEnum returns NERR_Success or ERROR_MORE_DATA.
  12514.  
  12515.  pcTotalAvail
  12516.    Points to an unsigned short integer in which the total number of groups is
  12517.    returned. This count is valid only if NetGroupEnum returns NERR_Success or
  12518.    ERROR_MORE_DATA.
  12519.  
  12520.  Return Codes
  12521.  
  12522. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  12523.  Code                              Value   Meaning
  12524.  ────────────────────────────────────────────────────────────────────────────
  12525.  NERR_Success                      0       The function encountered no
  12526.                                            errors.
  12527.  
  12528.  ERROR_ACCESS_DENIED               5       The user has insufficient
  12529.                                            privilege for this operation.
  12530.  
  12531.  ERROR_NOT_SUPPORTED               50      This network request is not
  12532.                                            supported.
  12533.  
  12534.  ERROR_BAD_NETPATH                 53      The network path was not found.
  12535.  
  12536.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  12537.  
  12538.  ERROR_INVALID_LEVEL               124     The level for information
  12539.  Code                              Value   Meaning
  12540.  ────────────────────────────────────────────────────────────────────────────
  12541. ERROR_INVALID_LEVEL               124     The level for information
  12542.                                            retrieval or setting is invalid.
  12543.  
  12544.  ERROR_MORE_DATA                   234     Additional data is available.
  12545.  
  12546.  NERR_RemoteOnly                   2106    This operation can be performed
  12547.                                            only on a server.
  12548.  
  12549.  NERR_WkstaNotStarted              2138    The Workstation service is not
  12550.                                            started.
  12551.  
  12552.  NERR_BadTransactConfig            2141    The server is not configured for
  12553.                                            this transaction: IPC$ is not
  12554.                                            shared.
  12555.  
  12556.  NERR_ACFNotLoaded                 2227    The user accounts database is
  12557.                                            not active. This database must
  12558.                                            be active for the command to run.
  12559.  
  12560.  Code                              Value   Meaning
  12561.  ────────────────────────────────────────────────────────────────────────────
  12562. 
  12563.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  12564.  
  12565.  NERR_InvalidDatabase              2247    The user accounts database file,
  12566.                                            NET.ACC, is corrupted.
  12567.  
  12568.  NERR_InvalidComputer              2351    The specified computername is
  12569.                                            invalid.
  12570.  
  12571.  ────────────────────────────────────────────────────────────────────────────
  12572.  
  12573.  
  12574.  
  12575.  
  12576.  Remarks
  12577.  
  12578.  NetGroupEnum does not list the special group local.
  12579.  
  12580.  
  12581.  NetGroupGetInfo
  12582.  ────────────────────────────────────────────────────────────────────────────
  12583.  
  12584.  NetGroupGetInfo gets group-related information.
  12585.  
  12586.  
  12587.  Operating Systems Supported
  12588.  
  12589.  
  12590.    ■   MS OS/2 version 1.2, local and remote
  12591.  
  12592.    ■   MS OS/2 version 1.1, remote only
  12593.  
  12594.    ■   MS-DOS, remote only
  12595.  
  12596.  
  12597.  
  12598.  Privilege Level
  12599.  
  12600.  Admin privilege or accounts operator privilege is required to successfully
  12601.  execute NetGroupGetInfo at level 1 on a remote server or on a computer that
  12602.  has local security enabled. No special privilege is required for level 0
  12603.  calls.
  12604.  
  12605.  
  12606.  Syntax
  12607.  
  12608.    #define INCL_NETGROUP
  12609.    #define INCL_NETERRORS
  12610.    #include <lan.h>
  12611.  
  12612.    API_FUNCTION
  12613.    NetGroupGetInfo (const char far *      pszServer,
  12614.                     char far *            pszGroupName,
  12615.                     short                 sLevel,
  12616.                     char far *            pbBuffer,
  12617.                     unsigned short        cbBuffer,
  12618.                     unsigned short far *  pcbTotalAvail
  12619.                    );
  12620.  
  12621.  where
  12622.  
  12623.  pszServer
  12624.    Points to an ASCIIZ string that contains the name of the server on which
  12625.    to execute NetGroupGetInfo. A null pointer or null string specifies the
  12626.    local computer.
  12627.  
  12628.  pszGroupName
  12629.    Points to an ASCIIZ string that contains the name of the group about which
  12630.    to get information.
  12631.  
  12632.  sLevel
  12633.    Specifies the level of detail (0 or 1) requested.
  12634.  
  12635.  pbBuffer
  12636.    Points to the buffer in which to store the returned data. On a successful
  12637.    return, the buffer contains a group_info_X data structure, where X is 0 or
  12638.    1, depending on the level of detail requested.
  12639.  
  12640.  cbBuffer
  12641.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  12642.  
  12643.  pcbTotalAvail
  12644.    Points to an unsigned short integer in which the total number of bytes of
  12645.    information available is returned. This count is valid only if
  12646.    NetGroupGetInfo returns NERR_Success, ERROR_MORE_DATA, or
  12647.    NERR_BufTooSmall.
  12648.  
  12649.  Return Codes
  12650.  
  12651. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  12652.  Code                              Value   Meaning
  12653.  ────────────────────────────────────────────────────────────────────────────
  12654.  NERR_Success                      0       The function encountered no
  12655.                                            errors.
  12656.  
  12657.  ERROR_ACCESS_DENIED               5       The user has insufficient
  12658.                                            privilege for this operation.
  12659.  
  12660.  ERROR_NOT_SUPPORTED               50      This network request is not
  12661.                                            supported.
  12662.  
  12663.  ERROR_BAD_NETPATH                 53      The network path was not found.
  12664.  
  12665.  Code                              Value   Meaning
  12666.  ────────────────────────────────────────────────────────────────────────────
  12667. 
  12668.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  12669.  
  12670.  ERROR_INVALID_LEVEL               124     The level for information
  12671.                                            retrieval or setting is invalid.
  12672.  
  12673.  ERROR_MORE_DATA                   234     Additional data is available.
  12674.  
  12675.  NERR_RemoteOnly                   2106    This operation can be performed
  12676.                                            only on a server.
  12677.  
  12678.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  12679.  
  12680.  NERR_WkstaNotStarted              2138    The Workstation service is not
  12681.                                            started.
  12682.  
  12683.  NERR_BadTransactConfig            2141    The server is not configured for
  12684.                                            this transaction: IPC$ is not
  12685.                                            shared.
  12686.  Code                              Value   Meaning
  12687.  ────────────────────────────────────────────────────────────────────────────
  12688.                                           shared.
  12689.  
  12690.  NERR_InvalidAPI                   2142    The requested API is not
  12691.                                            supported on the remote server.
  12692.  
  12693.  NERR_GroupNotFound                2220    The groupname was not found.
  12694.  
  12695.  NERR_ACFNotLoaded                 2227    The user accounts database is
  12696.                                            not active. This database must
  12697.                                            be active for the command to run.
  12698.  
  12699.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  12700.  
  12701.  
  12702.  NERR_SpeGroupOp                   2234    This operation is not allowed on
  12703.                                            this special group.
  12704.  
  12705.  NERR_InvalidDatabase              2247    The user accounts database file,
  12706.                                            NET.ACC, is corrupted.
  12707.  Code                              Value   Meaning
  12708.  ────────────────────────────────────────────────────────────────────────────
  12709.                                           NET.ACC, is corrupted.
  12710.  
  12711.  NERR_InvalidComputer              2351    The specified computername is
  12712.                                            invalid.
  12713.  
  12714.  ────────────────────────────────────────────────────────────────────────────
  12715.  
  12716.  
  12717.  
  12718.  
  12719.  Remarks
  12720.  
  12721.  If an attempt is made to get information about the users, guests, admins, or
  12722.  local special groups, NetGroupGetInfo returns NERR_SpeGroupOp.
  12723.  
  12724.  
  12725.  NetGroupGetUsers
  12726.  ────────────────────────────────────────────────────────────────────────────
  12727.  
  12728.  NetGroupGetUsers returns a list of the members of a particular group in the
  12729.  user accounts subsystem (UAS) database.
  12730.  
  12731.  
  12732.  Operating Systems Supported
  12733.  
  12734.  
  12735.    ■   MS OS/2 version 1.2, local and remote
  12736.  
  12737.    ■   MS OS/2 version 1.1, remote only
  12738.  
  12739.    ■   MS-DOS, remote only
  12740.  
  12741.  
  12742.  
  12743.  Privilege Level
  12744.  
  12745.  Admin privilege or accounts operator privilege is required to successfully
  12746.  execute NetGroupGetUsers on a remote server or on a computer that has local
  12747.  security enabled, except when users request details about a group to which
  12748.  they belong. In this case, no special privilege is required.
  12749.  
  12750.  
  12751.  Syntax
  12752.  
  12753.    #define INCL_NETGROUP
  12754.    #define INCL_NETERRORS
  12755.    #include <lan.h>
  12756.  
  12757.    API_FUNCTION
  12758.    NetGroupGetUsers (const char far *      pszServer,
  12759.                      const char far *      pszGroupName,
  12760.                      short                 sLevel,
  12761.                      char far *            pbBuffer,
  12762.                      unsigned short        cbBuffer,
  12763.                      unsigned short far *  pcEntriesRead,
  12764.                      unsigned short far *  pcTotalAvail
  12765.                     );
  12766.  
  12767.  where
  12768.  
  12769.  pszServer
  12770.    Points to an ASCIIZ string that contains the name of the server on which
  12771.    to execute NetGroupGetUsers. A null pointer or null string specifies the
  12772.    local computer.
  12773.  
  12774.  pszGroupName
  12775.    Points to an ASCIIZ string that contains the name of the group whose
  12776.    members are to be listed.
  12777.  
  12778.  sLevel
  12779.    Specifies the level of detail requested; must be 0.
  12780.  
  12781.  pbBuffer
  12782.    Points to the buffer in which to store the returned data. On a successful
  12783.    return, the buffer pointed to by pbBuffer contains a sequence of
  12784.    group_users_info_0 data structures.
  12785.  
  12786.  cbBuffer
  12787.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  12788.  
  12789.  pcEntriesRead
  12790.    Points to an unsigned short integer in which the number of
  12791.    group_users_info_0 data structures in the buffer pointed to by pbBuffer is
  12792.    returned. This count is valid only if NetGroupGetUsers returns
  12793.    NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  12794.  
  12795.  pcTotalAvail
  12796.    Points to an unsigned short integer in which the total number of users in
  12797.    the group is returned. This count is valid only if NetGroupGetUsers
  12798.    returns NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  12799.  
  12800.  Return Codes
  12801.  
  12802. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  12803.  Code                              Value   Meaning
  12804.  ────────────────────────────────────────────────────────────────────────────
  12805.  NERR_Success                      0       The function encountered no
  12806.                                            errors.
  12807.  
  12808.  ERROR_ACCESS_DENIED               5       The user has insufficient
  12809.                                            privilege for this operation.
  12810.  
  12811.  ERROR_BAD_NETPATH                 53      The network path was not found.
  12812.  Code                              Value   Meaning
  12813.  ────────────────────────────────────────────────────────────────────────────
  12814. ERROR_BAD_NETPATH                 53      The network path was not found.
  12815.  
  12816.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  12817.  
  12818.  ERROR_INVALID_LEVEL               124     The level for information
  12819.                                            retrieval or setting is invalid.
  12820.  
  12821.  ERROR_MORE_DATA                   234     Additional data is available.
  12822.  
  12823.  NERR_RemoteOnly                   2106    This operation can be performed
  12824.                                            only on a server.
  12825.  
  12826.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  12827.  
  12828.  NERR_WkstaNotStarted              2138    The Workstation service is not
  12829.                                            started.
  12830.  
  12831.  NERR_BadTransactConfig            2141    The server is not configured for
  12832.                                            this transaction: IPC$ is not
  12833.  Code                              Value   Meaning
  12834.  ────────────────────────────────────────────────────────────────────────────
  12835.                                           this transaction: IPC$ is not
  12836.                                            shared.
  12837.  
  12838.  NERR_ACFNotFound                  2219    LAN Manager could not find the
  12839.                                            user accounts database file,
  12840.                                            NET.ACC. This file should be in
  12841.                                            the ACCOUNTS subdirectory of the
  12842.                                            LANMAN directory.
  12843.  
  12844.  NERR_GroupNotFound                2220    The groupname was not found.
  12845.  
  12846.  NERR_ACFNotLoaded                 2227    The user accounts database is
  12847.                                            not active. This database must
  12848.                                            be active for the command to run.
  12849.  
  12850.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  12851.  
  12852.  NERR_InvalidDatabase              2247    The user accounts database file,
  12853.                                            NET.ACC, is corrupted.
  12854.  Code                              Value   Meaning
  12855.  ────────────────────────────────────────────────────────────────────────────
  12856.                                           NET.ACC, is corrupted.
  12857.  
  12858.  NERR_InvalidComputer              2351    The specified computername is
  12859.                                            invalid.
  12860.  
  12861.  ────────────────────────────────────────────────────────────────────────────
  12862.  
  12863.  
  12864.  
  12865.  
  12866.  Remarks
  12867.  
  12868.  NetGroupGetUsers is the only function in the Group category that can operate
  12869.  on a remote server that has share-level security. All other Group category
  12870.  functions require the remote server to have user-level security.
  12871.  
  12872.  See Also
  12873.  
  12874.  For information about             See
  12875.  ────────────────────────────────────────────────────────────────────────────
  12876.  Listing all groups that contain   NetUserGetGroups
  12877.  a specific username
  12878.  
  12879.  Listing the names of groups on a  NetGroupEnum
  12880.  server
  12881.  
  12882.  
  12883.  NetGroupSetInfo
  12884.  ────────────────────────────────────────────────────────────────────────────
  12885.  
  12886.  NetGroupSetInfo sets information for a given group in the user accounts
  12887.  subsystem (UAS) database.
  12888.  
  12889.  
  12890.  Operating Systems Supported
  12891.  
  12892.  
  12893.    ■   MS OS/2 version 1.2, local and remote
  12894.  
  12895.    ■   MS OS/2 version 1.1, remote only
  12896.  
  12897.    ■   MS-DOS, remote only
  12898.  
  12899.  
  12900.  
  12901.  Privilege Level
  12902.  
  12903.  Admin privilege or accounts operator privilege is required to successfully
  12904.  execute NetGroupSetInfo on a remote server or on a computer that has local
  12905.  security enabled.
  12906.  
  12907.  
  12908.  Syntax
  12909.  
  12910.    #define INCL_NETGROUP
  12911.    #define INCL_NETERRORS
  12912.    #include <lan.h>
  12913.  
  12914.    API_FUNCTION
  12915.    NetGroupSetInfo (const char far *  pszServer,
  12916.                     char far *        pszGroupName,
  12917.                     short             sLevel,
  12918.                     char far *        pbBuffer,
  12919.                     unsigned short    cbBuffer,
  12920.                     short             sParmNum
  12921.                    );
  12922.  
  12923.  where
  12924.  
  12925.  pszServer
  12926.    Points to an ASCIIZ string that contains the name of the server on which
  12927.    to execute NetGroupSetInfo. A null pointer or null string specifies the
  12928.    local computer.
  12929.  
  12930.  pszGroupName
  12931.    Points to an ASCIIZ string that contains the name of the group for which
  12932.    the information is to be set.
  12933.  
  12934.  sLevel
  12935.    Specifies the level of detail provided; must be 1.
  12936.  
  12937.  pbBuffer
  12938.    Points to the data to be set.
  12939.  
  12940.  cbBuffer
  12941.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  12942.  
  12943.  sParmNum
  12944.    Specifies whether to reset all the group information or to change only a
  12945.    part of it. If sParmNum is PARMNUM_ALL, pbBuffer must point to a
  12946.    group_info_1 data structure, and the old group information is replaced by
  12947.    this new information. If sParmNum is any other defined value, only one
  12948.    element of the group information is changed, and pbBuffer must point to a
  12949.    valid value for that element.
  12950.  
  12951.    Not all elements can be set. Only those elements that have a specific
  12952.    PARMNUM constant value defined can be set. The ACCESS.H header file
  12953.    defines these possible values for sParmNum:
  12954.  
  12955.  Code                  Value  Element of group_info_1
  12956.  ────────────────────────────────────────────────────────────────────────────
  12957.  PARMNUM_ALL           0      All elements.
  12958.  GRP1_PARMNUM_COMMENT  2      grpi1_comment
  12959.  ────────────────────────────────────────────────────────────────────────────
  12960.  
  12961.  Return Codes
  12962.  
  12963. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  12964.  Code                              Value   Meaning
  12965.  ────────────────────────────────────────────────────────────────────────────
  12966.  NERR_Success                      0       The function encountered no
  12967.                                            errors.
  12968.  
  12969.  ERROR_ACCESS_DENIED               5       The user has insufficient
  12970.                                            privilege for this operation.
  12971.  
  12972.  ERROR_NOT_SUPPORTED               50      This network request is not
  12973.                                            supported.
  12974.  
  12975.  ERROR_BAD_NETPATH                 53      The network path was not found.
  12976.  
  12977.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  12978.  
  12979.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  12980.  Code                              Value   Meaning
  12981.  ────────────────────────────────────────────────────────────────────────────
  12982. ERROR_INVALID_PARAMETER           87      The parameter specified is
  12983.                                            invalid.
  12984.  
  12985.  ERROR_INVALID_LEVEL               124     The level for information
  12986.                                            retrieval or setting is invalid.
  12987.  
  12988.  NERR_RemoteOnly                   2106    This operation can be performed
  12989.                                            only on a server.
  12990.  
  12991.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  12992.  
  12993.  NERR_WkstaNotStarted              2138    The Workstation service is not
  12994.                                            started.
  12995.  
  12996.  NERR_BadTransactConfig            2141    The server is not configured for
  12997.                                            this transaction: IPC$ is not
  12998.                                            shared.
  12999.  
  13000.  NERR_InvalidAPI                   2142    The requested API is not
  13001.  Code                              Value   Meaning
  13002.  ────────────────────────────────────────────────────────────────────────────
  13003. NERR_InvalidAPI                   2142    The requested API is not
  13004.                                            supported on the remote server.
  13005.  
  13006.  NERR_GroupNotFound                2220    The groupname was not found.
  13007.  
  13008.  NERR_NotPrimary                   2226    The specified server is not the
  13009.                                            primary domain controller, so
  13010.                                            its UAS database cannot be
  13011.                                            updated.
  13012.  
  13013.  NERR_ACFNotLoaded                 2227    The user accounts database is
  13014.                                            not active. This database must
  13015.                                            be active for the command to run.
  13016.  
  13017.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  13018.  
  13019.  NERR_SpeGroupOp                   2234    This operation is not allowed on
  13020.                                            this special group.
  13021.  
  13022.  Code                              Value   Meaning
  13023.  ────────────────────────────────────────────────────────────────────────────
  13024. 
  13025.  NERR_InvalidDatabase              2247    The user accounts database file,
  13026.                                            NET.ACC, is corrupted.
  13027.  
  13028.  NERR_InvalidComputer              2351    The specified computername is
  13029.                                            invalid.
  13030.  
  13031.  NERR_CanNotGrowUASFile            2456    The user accounts database
  13032.                                            cannot be enlarged because the
  13033.                                            server's hard disk is full.
  13034.  
  13035.  ────────────────────────────────────────────────────────────────────────────
  13036.  
  13037.  
  13038.  
  13039.  
  13040.  Remarks
  13041.  
  13042.  If an attempt is made to set information for the users, guests, admins, or
  13043.  local special groups, NetGroupSetInfo returns NERR_SpeGroupOp.
  13044.  
  13045.  See Also
  13046.  
  13047.  For information about             See
  13048.  ────────────────────────────────────────────────────────────────────────────
  13049.  Remote calls                      Chapter 1, "Overview of the LAN Manager
  13050.                                    API"
  13051.  
  13052.  
  13053.  NetGroupSetUsers
  13054.  ────────────────────────────────────────────────────────────────────────────
  13055.  
  13056.  NetGroupSetUsers sets information about users who belong to a particular
  13057.  group.
  13058.  
  13059.  
  13060.  Operating Systems Supported
  13061.  
  13062.  
  13063.    ■   MS OS/2 version 1.2, local and remote
  13064.  
  13065.    ■   MS OS/2 version 1.1, remote only
  13066.  
  13067.    ■   MS-DOS, remote only
  13068.  
  13069.  
  13070.  
  13071.  Privilege Level
  13072.  
  13073.  Admin privilege or accounts operator privilege is required to successfully
  13074.  execute NetGroupSetUsers on a remote server or on a computer that has local
  13075.  security enabled.
  13076.  
  13077.  
  13078.  Syntax
  13079.  
  13080.    #define INCL_NETGROUP
  13081.    #define INCL_NETERRORS
  13082.    #include <lan.h>
  13083.  
  13084.    API_FUNCTION
  13085.    NetGroupSetUsers (const char far *  pszServer,
  13086.                      const char far *  pszGroupName,
  13087.                      short             sLevel,
  13088.                      char far *        pbBuffer,
  13089.                      unsigned short    cbBuffer,
  13090.                      unsigned short    cEntries
  13091.                     );
  13092.  
  13093.  where
  13094.  
  13095.  pszServer
  13096.    Points to an ASCIIZ string that contains the name of the server on which
  13097.    to execute NetGroupSetUsers. A null pointer or null string specifies the
  13098.    local computer.
  13099.  
  13100.  pszGroupName
  13101.    Points to an ASCIIZ string that contains the name of the group to which
  13102.    the specified users belong.
  13103.  
  13104.  sLevel
  13105.    Specifies the level of detail supplied; must be 0.
  13106.  
  13107.  pbBuffer
  13108.    Points to the buffer in which the data to be set is stored. This data
  13109.    consists of a sequence of group_users_info_0 data structures.
  13110.  
  13111.  cbBuffer
  13112.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  13113.  
  13114.  cEntries
  13115.    Specifies the number of group_users_info_0 data structures supplied in the
  13116.    buffer pointed to by pbBuffer.
  13117.  
  13118.  Return Codes
  13119.  
  13120. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  13121.  Code                              Value   Meaning
  13122.  ────────────────────────────────────────────────────────────────────────────
  13123.  NERR_Success                      0       The function encountered no
  13124.                                            errors.
  13125.  
  13126.  ERROR_ACCESS_DENIED               5       The user has insufficient
  13127.  Code                              Value   Meaning
  13128.  ────────────────────────────────────────────────────────────────────────────
  13129. ERROR_ACCESS_DENIED               5       The user has insufficient
  13130.                                            privilege for this operation.
  13131.  
  13132.  ERROR_NOT_SUPPORTED               50      This network request is not
  13133.                                            supported.
  13134.  
  13135.  ERROR_BAD_NETPATH                 53      The network path was not found.
  13136.  
  13137.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  13138.  
  13139.  ERROR_INVALID_LEVEL               124     The level for information
  13140.                                            retrieval or setting is invalid.
  13141.  
  13142.  NERR_RemoteOnly                   2106    This operation can be performed
  13143.                                            only on a server.
  13144.  
  13145.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  13146.  
  13147.  NERR_WkstaNotStarted              2138    The Workstation service is not
  13148.  Code                              Value   Meaning
  13149.  ────────────────────────────────────────────────────────────────────────────
  13150. NERR_WkstaNotStarted              2138    The Workstation service is not
  13151.                                            started.
  13152.  
  13153.  NERR_BadTransactConfig            2141    The server is not configured for
  13154.                                            this transaction: IPC$ is not
  13155.                                            shared.
  13156.  
  13157.  NERR_InvalidAPI                   2142    The requested API is not
  13158.                                            supported on the remote server.
  13159.  
  13160.  NERR_GroupNotFound                2220    The groupname was not found.
  13161.  
  13162.  NERR_UserNotFound                 2221    The username was not found.
  13163.  
  13164.  NERR_NotPrimary                   2226    The specified server is not the
  13165.                                            primary domain controller, so
  13166.                                            its UAS database cannot be
  13167.                                            updated.
  13168.  
  13169.  Code                              Value   Meaning
  13170.  ────────────────────────────────────────────────────────────────────────────
  13171. 
  13172.  NERR_ACFNotLoaded                 2227    The user accounts database is
  13173.                                            not active. This database must
  13174.                                            be active for the command to run.
  13175.  
  13176.  NERR_ACFNoRoom                    2228    The user accounts database is
  13177.                                            full.
  13178.  
  13179.  NERR_ACFFileIOFail                2229    A disk I/O failure occurred.
  13180.  
  13181.  NERR_SpeGroupOp                   2234    This operation is not allowed on
  13182.                                            this special group.
  13183.  
  13184.  NERR_InvalidDatabase              2247    The user accounts database file,
  13185.                                            NET.ACC, is corrupted.
  13186.  
  13187.  NERR_InvalidComputer              2351    The specified computername is
  13188.                                            invalid.
  13189.  
  13190.  Code                              Value   Meaning
  13191.  ────────────────────────────────────────────────────────────────────────────
  13192. 
  13193.  NERR_CanNotGrowUASFile            2456    The user accounts database
  13194.                                            cannot be enlarged because the
  13195.                                            server's hard disk is full.
  13196.  
  13197.  ────────────────────────────────────────────────────────────────────────────
  13198.  
  13199.  
  13200.  
  13201.  
  13202.  Remarks
  13203.  
  13204.  If an attempt is made to set a list of usernames for the users, guests,
  13205.  admins, or local special groups, NetGroupSetUsers returns NERR_SpeGroupOp.
  13206.  
  13207.  See Also
  13208.  
  13209.  For information about             See
  13210.  ────────────────────────────────────────────────────────────────────────────
  13211.  Remote calls                      Chapter 1, "Overview of the LAN Manager
  13212.                                    API"
  13213.  
  13214.  Setting a user's group            NetUserSetGroups
  13215.  membership
  13216.  
  13217.  
  13218.  
  13219.  
  13220.  
  13221.  Group Category Example
  13222.  
  13223.    /*
  13224.       NETGROUP.C -- a sample program demonstrating NetGroup API functions.
  13225.  
  13226.       This program requires that you have admin privilege or accounts
  13227.       operator privilege on the specified server.
  13228.  
  13229.          usage:  netgroup [-s \\server] [-g groupname] [-c comment]
  13230.  
  13231.          where  \\server  = Name of the server. A servername must be
  13232.  
  13233.                             preceded by two backslashes (\\).
  13234.                 groupname = Name of the group to be added.
  13235.                 comment   = Comment for the group to be added.
  13236.  
  13237.       API                  Used to...
  13238.       ================     =========================================
  13239.       NetGroupAdd          Add a new group
  13240.       NetGroupEnum         Display list of groups and group comments
  13241.       NetGroupSetInfo      Change a group's comment
  13242.       NetGroupGetInfo      Display a particular group's comment
  13243.       NetGroupSetUsers     Set the members of a group
  13244.       NetGroupAddUser      Add a new member to the group
  13245.       NetGroupDelUser      Delete a member from the group
  13246.       NetGroupGetUsers     List the members of a group
  13247.       NetGroupDel          Delete a group
  13248.  
  13249.       This code sample is provided for demonstration purposes only.
  13250.       Microsoft makes no warranty, either express or implied,
  13251.       as to its usability in any given situation.
  13252.    */
  13253.  
  13254.    #define     INCL_NETGROUP
  13255.    #define     INCL_NETERRORS
  13256.    #include    <lan.h>        // LAN Manager header files
  13257.  
  13258.    #include    <stdio.h>      // C run-time header files
  13259.    #include    <stdlib.h>
  13260.    #include    <string.h>
  13261.  
  13262.    #include    "samples.h"    // Internal routine header file
  13263.  
  13264.    #define DEFAULT_GROUP      "TESTERS"
  13265.    #define DEFAULT_COMMENT    "Default comment for new group"
  13266.    #define NEW_COMMENT        "New group comment"
  13267.    #define TRIAL_USER1        "BRUCE"
  13268.    #define TRIAL_USER2        "LIZ"
  13269.    #define TRIAL_USER3        "JOHN"
  13270.    #define BIG_BUFF           32768
  13271.  
  13272.    void Usage (char * pszProgram);
  13273.  
  13274.    void main(int argc, char *argv[])
  13275.    {
  13276.       char *         pszServer = "";
  13277.       char *         pszNewGroup = DEFAULT_GROUP;
  13278.       char *         pszComment  = DEFAULT_COMMENT;
  13279.       char *         pszNewUser1 = TRIAL_USER1;
  13280.       char *         pszNewUser2 = TRIAL_USER2;
  13281.       char *         pszNewUser3 = TRIAL_USER3;
  13282.       char *         pbBuffer;               // Pointer to data buffer
  13283.       int            iArgv;                  // Index for arguments
  13284.       unsigned short iEntries;               // Index for entries read
  13285.       unsigned short cRead;                  // Count read
  13286.       unsigned short cAvail;                 // Count available
  13287.       unsigned short cbBuffer;               // Size of buffer, in bytes
  13288.       API_RET_TYPE   uReturnCode;            // API return code
  13289.       struct group_info_1 * pGroupInfo1;     // Pointer to group info
  13290.       struct group_users_info_0 * pGroupUsersInfo0;
  13291.  
  13292.       for (iArgv = 1; iArgv < argc; iArgv++)
  13293.       {
  13294.          if ((*argv[iArgv] == '-') || (*argv[iArgv] == '/'))
  13295.          {
  13296.             switch (tolower(*(argv[iArgv]+1))) // Process switches
  13297.             {
  13298.                case 's':                       // -s servername
  13299.                   pszServer = argv[++iArgv];
  13300.                   break;
  13301.                case 'g':                       // -g groupname
  13302.                   pszNewGroup = argv[++iArgv];
  13303.                   break;
  13304.                case 'c':                       // -c comment
  13305.                   pszComment = argv[++iArgv];
  13306.                   break;
  13307.                case 'h':
  13308.                default:
  13309.                   Usage(argv[0]);
  13310.             }
  13311.          }
  13312.          else
  13313.             Usage(argv[0]);
  13314.       }
  13315.  
  13316.    //========================================================================
  13317.    //  NetGroupAdd
  13318.    //
  13319.    //  This API adds a new group with info level 1.
  13320.    //========================================================================
  13321.  
  13322.       cbBuffer = sizeof(struct group_info_1);
  13323.       pGroupInfo1 = (struct group_info_1 *) SafeMalloc(cbBuffer);
  13324.       strcpy(pGroupInfo1->grpi1_name, pszNewGroup);
  13325.       pGroupInfo1->grpi1_comment = pszComment;
  13326.  
  13327.       uReturnCode = NetGroupAdd(
  13328.                         pszServer,              // Servername
  13329.                         1,                      // Info level
  13330.                         (char far *)pGroupInfo1,// Input buffer
  13331.                         cbBuffer);              // Size of buffer
  13332.       free(pGroupInfo1);
  13333.  
  13334.       printf("NetGroupAdd of group \"%s\" returned %u\n",
  13335.                  pszNewGroup, uReturnCode);
  13336.  
  13337.    //========================================================================
  13338.    //  NetGroupEnum
  13339.    //
  13340.    //  This API displays the list of current groupnames and group comments.
  13341.    //========================================================================
  13342.  
  13343.       cbBuffer = BIG_BUFF;                      // Can be up to 64K
  13344.       pbBuffer = SafeMalloc(cbBuffer);          // Data buffer
  13345.  
  13346.       uReturnCode = NetGroupEnum(
  13347.                         pszServer,              // Servername
  13348.                         1,                      // Info level
  13349.                         pbBuffer,               // Data returned here
  13350.                         cbBuffer,               // Size of buffer, in
  13351.    bytes
  13352.                         &cRead,                 // Count of entries read
  13353.                         &cAvail);               // Count of entries available
  13354.  
  13355.       printf("NetGroupEnum returned %u\n", uReturnCode);
  13356.  
  13357.       if (uReturnCode == NERR_Success)
  13358.       {
  13359.          pGroupInfo1 = (struct group_info_1 *) pbBuffer;
  13360.          for (iEntries = 0; iEntries < cRead; iEntries++)
  13361.          {
  13362.             printf("   %-24s - %Fs\n", pGroupInfo1->grpi1_name,
  13363.                       pGroupInfo1->grpi1_comment);
  13364.             pGroupInfo1++;
  13365.          }
  13366.          printf("%hu out of %hu entries returned\n", cRead, cAvail);
  13367.       }
  13368.       free(pbBuffer);
  13369.  
  13370.    //========================================================================
  13371.    //  NetGroupSetInfo
  13372.    //
  13373.    //  This API sets information for a group.
  13374.    //
  13375.    //  There are two ways to call NetGroupSetInfo. If sParmNum is set
  13376.    to
  13377.    //  PARMNUM_ALL, you must pass it a whole structure. Otherwise, you
  13378.  
  13379.    //  can set sParmNum to the structure element you want to change.
  13380.    The
  13381.    //  whole structure is used in this example to change the group comment.
  13382.    //========================================================================
  13383.  
  13384.       cbBuffer = sizeof(struct group_info_1) + MAXCOMMENTSZ + 1;
  13385.       pbBuffer = SafeMalloc(cbBuffer);          // Info buffer
  13386.  
  13387.       pGroupInfo1 = (struct group_info_1 *) pbBuffer;
  13388.       strcpy(pGroupInfo1->grpi1_name, pszNewGroup);
  13389.  
  13390.       /*
  13391.        * Data referenced by a pointer from within the fixed-length
  13392.        * portion of the data structure must be located outside the buffer
  13393.        * passed to the API or it will be ignored in remote NetGroupSetInfo
  13394.  
  13395.        * calls.
  13396.        */
  13397.  
  13398.       pGroupInfo1->grpi1_comment = NEW_COMMENT;
  13399.  
  13400.       uReturnCode = NetGroupSetInfo(
  13401.                         pszServer,              // Servername
  13402.                         pszNewGroup,            // Groupname
  13403.                         1,                      // Info level
  13404.                         pbBuffer,               // Data buffer
  13405.                         cbBuffer,               // Size of buffer, in
  13406.    bytes
  13407.                         PARMNUM_ALL);           // Parameter number code
  13408.  
  13409.       printf("NetGroupSetInfo returned %u\n", uReturnCode);
  13410.       printf("   Changing comment for group \"%s\" %s\n", pszNewGroup,
  13411.                         uReturnCode ? "failed" : "succeeded");
  13412.  
  13413.    //========================================================================
  13414.    //  NetGroupGetInfo
  13415.    //
  13416.    //  This API gets the information available about the new group.
  13417.    //========================================================================
  13418.  
  13419.       uReturnCode = NetGroupGetInfo(
  13420.                         pszServer,              // Servername
  13421.                         pszNewGroup,            // Groupname
  13422.                         1,                      // Info level
  13423.                         pbBuffer,               // Data buffer
  13424.                         cbBuffer,               // Size of buffer, in
  13425.    bytes
  13426.                         &cAvail);               // Count of bytes available
  13427.  
  13428.       printf("NetGroupGetInfo returned %u\n", uReturnCode);
  13429.       if (uReturnCode == NERR_Success)
  13430.       {
  13431.          printf("   %-24s - %Fs\n", pGroupInfo1->grpi1_name,
  13432.                         pGroupInfo1->grpi1_comment);
  13433.       }
  13434.       free(pbBuffer);
  13435.  
  13436.    //========================================================================
  13437.    //  NetGroupSetUsers
  13438.    //
  13439.    //  This API sets the list of users who belong to the new group.
  13440.    //========================================================================
  13441.  
  13442.       cbBuffer = sizeof(struct group_users_info_0) * 2;
  13443.       pbBuffer = SafeMalloc(cbBuffer);          // Info buffer
  13444.  
  13445.       pGroupUsersInfo0 = (struct group_users_info_0 *) pbBuffer;
  13446.       strcpy(pGroupUsersInfo0->grui0_name, pszNewUser1);
  13447.       pGroupUsersInfo0++;
  13448.       strcpy(pGroupUsersInfo0->grui0_name, pszNewUser2);
  13449.  
  13450.       uReturnCode = NetGroupSetUsers(
  13451.                         pszServer,              // Servername
  13452.                         pszNewGroup,            // Groupname
  13453.                         0,                      // Info level; must be
  13454.    0
  13455.                         pbBuffer,               // Data buffer
  13456.                         cbBuffer,               // Size of buffer, in
  13457.    bytes
  13458.                         2);                     // Entries
  13459.  
  13460.       printf("NetGroupSetUsers returned %u\n", uReturnCode);
  13461.  
  13462.    //========================================================================
  13463.    //  NetGroupAddUser
  13464.    //
  13465.    //  This API adds a user to the new group.
  13466.    //========================================================================
  13467.  
  13468.       uReturnCode = NetGroupAddUser(
  13469.                         pszServer,              // Servername
  13470.                         pszNewGroup,            // Groupname
  13471.                         pszNewUser3);           // Username to add
  13472.  
  13473.       printf("NetGroupAddUser for user \"%s\" returned %u\n",
  13474.                  pszNewUser3, uReturnCode);
  13475.  
  13476.    //========================================================================
  13477.    //  NetGroupDelUser
  13478.    //
  13479.    //  This API deletes a user from the new group.
  13480.    //========================================================================
  13481.  
  13482.       uReturnCode = NetGroupDelUser(
  13483.                         pszServer,              // Servername
  13484.                         pszNewGroup,            // Groupname
  13485.                         pszNewUser2);           // Username to delete
  13486.  
  13487.       printf("NetGroupDelUser for user \"%s\" returned %u\n",
  13488.                  pszNewUser2, uReturnCode);
  13489.  
  13490.    //========================================================================
  13491.    //  NetGroupGetUsers
  13492.    //
  13493.    //  This API lists the users who belong to the new group.
  13494.    //========================================================================
  13495.  
  13496.       uReturnCode = NetGroupGetUsers(
  13497.                         pszServer,              // Servername
  13498.                         pszNewGroup,            // Groupname
  13499.                         0,                      // Info level; must be
  13500.    0
  13501.                         pbBuffer,               // Buffer
  13502.                         cbBuffer,               // Size of buffer
  13503.                         &cRead,                 // Count of entries read
  13504.                         &cAvail);               // Count of entries available
  13505.  
  13506.  
  13507.  
  13508.  
  13509.  
  13510.       printf("NetGroupGetUsers returned %u\n", uReturnCode);
  13511.  
  13512.       if (uReturnCode == NERR_Success)
  13513.       {
  13514.          pGroupUsersInfo0 = (struct group_users_info_0 *) pbBuffer;
  13515.          for (iEntries = 0; iEntries < cRead; iEntries++)
  13516.          {
  13517.             printf("   %s\n", pGroupUsersInfo0->grui0_name);
  13518.             pGroupUsersInfo0++;
  13519.          }
  13520.       }
  13521.       free(pbBuffer);
  13522.  
  13523.    //========================================================================
  13524.    //  NetGroupDel
  13525.    //
  13526.    //  This API deletes the new group.
  13527.    //========================================================================
  13528.  
  13529.       uReturnCode = NetGroupDel(pszServer,      // Servername
  13530.                                 pszNewGroup);   // Groupname to delete
  13531.       free(pGroupInfo1);
  13532.  
  13533.       printf("NetGroupDel of group \"%s\" returned %u\n",
  13534.                  pszNewGroup, uReturnCode);
  13535.  
  13536.       exit(0);
  13537.    }
  13538.  
  13539.    void Usage (char * pszProgram)
  13540.    {
  13541.       fprintf(stderr, "Usage: %s [-s \\\\server]"\
  13542.                       " [-g groupname] [-c comment]\n", pszProgram);
  13543.       exit(1);
  13544.    }
  13545.  
  13546.  
  13547.  
  13548.  
  13549.  
  13550.  Handle Category
  13551.  
  13552.  Handle API functions get and set information related to the specified
  13553.  character-device or named-pipe handle. They require that the Workstation
  13554.  service be started.
  13555.  
  13556.  The Handle category functions, datatypes, structures, and constants are
  13557.  defined in the NETCONS.H, NETERR.H, and CHARDEV.H header files. A source
  13558.  program can access these definitions by defining the constants
  13559.  INCL_NETERRORS and INCL_NETHANDLE, and including the master header file,
  13560.  LAN.H. For more information about these definitions, see the "Example"
  13561.  section, later in this category.
  13562.  
  13563.  These are the Handle API functions:
  13564.  
  13565.  
  13566.    ■   NetHandleGetInfo
  13567.  
  13568.    ■   NetHandleSetInfo
  13569.  
  13570.  
  13571.  
  13572.  Description
  13573.  
  13574.  NetHandleGetInfo and NetHandleSetInfo allow an application to examine or
  13575.  change the communications parameters for character-device handles and
  13576.  named-pipe handles, provided that the handles refer to devices or pipes
  13577.  opened on a remote server.
  13578.  
  13579.  The adjustable parameters are based on the LANMAN.INI file entries for
  13580.  chartime and charcount, which determine the workstation data structure
  13581.  elements wkiX_chartime and wkiX_charcount, where X is the level of detail
  13582.  requested. These values specify when LAN Manager sends a packet of
  13583.  information over the network. Rather than writing single bytes to the
  13584.  network, LAN Manager saves the data in a buffer until chartime milliseconds
  13585.  have elapsed or until the buffer contains charcount characters.
  13586.  
  13587.  The handle_info_1 data structure elements hdli1_chartime and hdli1_charcount
  13588.  take their initial values from the workstation data structure elements
  13589.  wkiX_chartime and wkiX_charcount. The Handle API functions allow these
  13590.  values to be inspected and modified on a handle-by-handle basis.
  13591.  
  13592.  NetHandleGetInfo can also be used to identify the user of a named pipe,
  13593.  provided that the pipe has been opened from a remote server.
  13594.  
  13595.  Handle API functions can be called only locally (there is no servername
  13596.  parameter).
  13597.  
  13598.  
  13599.  Data Structures
  13600.  
  13601.  The handle_info_1 data structure is used with both NetHandleGetInfo  and
  13602.  NetHandleSetInfo. The handle_info_2 data structure is used only with
  13603.  NetHandleGetInfo.
  13604.  
  13605.  
  13606.  Handle Information (level 1)
  13607.  
  13608.  The handle_info_1 data structure has this format:
  13609.  
  13610.    struct handle_info_1 {
  13611.        unsigned long   hdli1_chartime;
  13612.        unsigned short  hdli1_charcount;
  13613.    };
  13614.  
  13615.  where
  13616.  
  13617.  hdli1_chartime
  13618.    Specifies the amount of time (in milliseconds) that the workstation
  13619.    collects data to send to a character device or named pipe.
  13620.  
  13621.  hdli1_charcount
  13622.    Specifies the number of characters (in bytes) that the workstation stores
  13623.    before it sends data to a character device or named pipe.
  13624.  
  13625.  
  13626.  Handle Information (level 2)
  13627.  
  13628.  The handle_info_2 data structure has this format:
  13629.  
  13630.    struct handle_info_2 {
  13631.        char far *   hdli2_username;
  13632.    };
  13633.  
  13634.  where
  13635.  
  13636.  hdli2_username
  13637.    Points to the name of the user who has opened a named pipe. This username
  13638.    is available only for a handle on the serving side of a valid named pipe
  13639.    that has been opened by a remote computer. If the named pipe has been
  13640.    opened locally, the call to NetHandleGetInfo returns
  13641.    ERROR_INVALID_PARAMETER.
  13642.  
  13643.  
  13644.  NetHandleGetInfo
  13645.  ────────────────────────────────────────────────────────────────────────────
  13646.  
  13647.  NetHandleGetInfo retrieves handle-specific information for character-device
  13648.  and named-pipe handles.
  13649.  
  13650.  
  13651.  Operating Systems Supported
  13652.  
  13653.  
  13654.    ■   MS OS/2 version 1.2, local only, levels 1 and 2
  13655.  
  13656.    ■   MS OS/2 version 1.1, local only, level 1 only
  13657.  
  13658.    ■   MS-DOS, local only, level 1 with remote named pipes only
  13659.  
  13660.  
  13661.  
  13662.  Privilege Level
  13663.  
  13664.  Access privilege is determined by the access restrictions to the named pipe
  13665.  or character device being accessed.
  13666.  
  13667.  
  13668.  Syntax
  13669.  
  13670.    #define INCL_NETHANDLE
  13671.    #define INCL_NETERRORS
  13672.    #include <lan.h>
  13673.  
  13674.    API_FUNCTION
  13675.    NetHandleGetInfo (unsigned short        hHandle,
  13676.                      short                 sLevel,
  13677.                      char far *            pbBuffer,
  13678.                      unsigned short        cbBuffer,
  13679.                      unsigned short far *  pcbTotalAvail
  13680.                     );
  13681.  
  13682.  where
  13683.  
  13684.  hHandle
  13685.    Identifies a communication-device queue or a named pipe.
  13686.  
  13687.  sLevel
  13688.    Specifies the level of detail (1 or 2) requested.
  13689.  
  13690.  pbBuffer
  13691.    Points to the buffer in which to store the returned data. On a successful
  13692.    return, the buffer contains a handle_info_1 data structure (level 1 call)
  13693.    or a handle_info_2 data structure (level 2 call).
  13694.  
  13695.  cbBuffer
  13696.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  13697.  
  13698.  pcbTotalAvail
  13699.    Points to an unsigned short integer in which a count of the total number
  13700.    of bytes of information available is returned. This count is valid only if
  13701.    NetHandleGetInfo returns NERR_Success, ERROR_MORE_DATA, or
  13702.    NERR_BufTooSmall.
  13703.  
  13704.  Return Codes
  13705.  
  13706. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  13707.  Code                              Value   Meaning
  13708.  ────────────────────────────────────────────────────────────────────────────
  13709.  NERR_Success                      0       The function encountered no
  13710.                                            errors.
  13711.  
  13712.  ERROR_ACCESS_DENIED               5       The user has insufficient
  13713.                                            privilege for this operation.
  13714.  
  13715.  Code                              Value   Meaning
  13716.  ────────────────────────────────────────────────────────────────────────────
  13717. 
  13718.  ERROR_NOT_SUPPORTED               50      This network request is not
  13719.                                            supported.
  13720.  
  13721.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  13722.                                            invalid.
  13723.  
  13724.  ERROR_INVALID_LEVEL               124     The level for information
  13725.                                            retrieval or setting is invalid.
  13726.  
  13727.  ERROR_MORE_DATA                   234     Additional data is available.
  13728.  
  13729.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  13730.                                            is not installed.
  13731.  
  13732.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  13733.  
  13734.  NERR_WkstaNotStarted              2138    The Workstation service is not
  13735.                                            started.
  13736.  Code                              Value   Meaning
  13737.  ────────────────────────────────────────────────────────────────────────────
  13738.                                           started.
  13739.  
  13740.  ────────────────────────────────────────────────────────────────────────────
  13741.  
  13742.  
  13743.  
  13744.  
  13745.  Remarks
  13746.  
  13747.  NetHandleGetInfo can be called at level 1 only if the value of hHandle is a
  13748.  valid handle to a named pipe or character device that exists on a remote
  13749.  server.
  13750.  
  13751.  NetHandleGetInfo can be called at level 2 only if the value of hHandle is a
  13752.  handle to the server side of a valid named pipe opened on a remote computer.
  13753.  If the named pipe has been opened locally or if the handle is not for a
  13754.  named pipe, NetHandleGetInfo returns ERROR_INVALID_PARAMETER.
  13755.  
  13756.  
  13757.  NetHandleSetInfo
  13758.  ────────────────────────────────────────────────────────────────────────────
  13759.  
  13760.  NetHandleSetInfo sets handle-specific information for character-device and
  13761.  named-pipe handles.
  13762.  
  13763.  
  13764.  Operating Systems Supported
  13765.  
  13766.  
  13767.    ■   MS OS/2 version 1.2, local only, level 1 only
  13768.  
  13769.    ■   MS OS/2 version 1.1, local only, level 1 only
  13770.  
  13771.    ■   MS-DOS, local only, level 1 with remote named pipes only
  13772.  
  13773.  
  13774.  
  13775.  Privilege Level
  13776.  
  13777.  Access privilege is determined by the access restrictions to the named pipe
  13778.  or character device being accessed.
  13779.  
  13780.  
  13781.  Syntax
  13782.  
  13783.    #define INCL_NETHANDLE
  13784.    #define INCL_NETERRORS
  13785.    #include <lan.h>
  13786.  
  13787.    API_FUNCTION
  13788.    NetHandleSetInfo (unsigned short  hHandle,
  13789.                      short           sLevel,
  13790.                      char far *      pbBuffer,
  13791.                      unsigned short  cbBuffer,
  13792.                      unsigned short  sParmNum
  13793.                     );
  13794.  
  13795.  where
  13796.  
  13797.  hHandle
  13798.    Identifies a communication-device queue or a named pipe.
  13799.  
  13800.  sLevel
  13801.    Specifies the level of detail provided; must be 1.
  13802.  
  13803.  pbBuffer
  13804.    Points to the data to be set.
  13805.  
  13806.  cbBuffer
  13807.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  13808.  
  13809.  sParmNum
  13810.    Specifies whether to reset all handle information or to change only a part
  13811.    of it. If sParmNum is PARMNUM_ALL, pbBuffer must point to a handle_info_1
  13812.    data structure, and the previous handle information is replaced by this
  13813.    new information. If sParmNum is any other defined value, only one element
  13814.    of the handle information  is changed, and pbBuffer must point to a valid
  13815.    value for that element.
  13816.  
  13817.    Not all elements can be set. Only those elements that have a specific
  13818.    PARMNUM constant value defined can be set. The CHARDEV.H header file
  13819.    defines these possible values for sParmNum:
  13820.  
  13821.  Code                   Value  Element of handle_info_1
  13822.  ────────────────────────────────────────────────────────────────────────────
  13823.  PARMNUM_ALL            0      All elements.
  13824.  HANDLE_SET_CHAR_TIME   1      hdli1_chartime
  13825.  HANDLE_SET_CHAR_COUNT  2      hdli1_charcount
  13826.  ────────────────────────────────────────────────────────────────────────────
  13827.  
  13828.  Return Codes
  13829.  
  13830. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  13831.  Code                              Value   Meaning
  13832.  ────────────────────────────────────────────────────────────────────────────
  13833.  NERR_Success                      0       The function encountered no
  13834.                                            errors.
  13835.  
  13836.  ERROR_ACCESS_DENIED               5       The user has insufficient
  13837.                                            privilege for this operation.
  13838.  
  13839.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  13840.                                            invalid.
  13841.  Code                              Value   Meaning
  13842.  ────────────────────────────────────────────────────────────────────────────
  13843.                                           invalid.
  13844.  
  13845.  ERROR_INVALID_LEVEL               124     The level for information
  13846.                                            retrieval or setting is invalid.
  13847.  
  13848.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  13849.                                            is not installed.
  13850.  
  13851.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  13852.  
  13853.  NERR_WkstaNotStarted              2138    The Workstation service is not
  13854.                                            started.
  13855.  
  13856.  ────────────────────────────────────────────────────────────────────────────
  13857.  
  13858.  
  13859.  
  13860.  
  13861.  
  13862.  
  13863.  
  13864.  Handle Category Example
  13865.  
  13866.    /*
  13867.       NETHAND1.C -- a sample program demonstrating NetHandle API functions
  13868.                     for the server side of named pipes.
  13869.  
  13870.       This program must be run on a computer that has the Server service
  13871.       running. It is to be used in conjunction with the program NETHAND2
  13872.       running on a workstation.
  13873.  
  13874.          usage:  nethand1 [-p pipename] [-m message]
  13875.  
  13876.          where  pipename = Name of the pipe to create.
  13877.                 message  = Message to be sent through the pipe.
  13878.  
  13879.       Run NETHAND1 on the server to create a named pipe, then run
  13880.       NETHAND2 on a workstation to connect to that named pipe.
  13881.  
  13882.       API                  Used to...
  13883.       ================     ==========================================
  13884.       NetHandleGetInfo     Get the name of the user of the named pipe
  13885.  
  13886.       This code sample is provided for demonstration purposes only.
  13887.       Microsoft makes no warranty, either express or implied,
  13888.       as to its usability in any given situation.
  13889.    */
  13890.  
  13891.    #define     INCL_BASE
  13892.    #define     INCL_DOSNMPIPES
  13893.    #include    <os2.h>        // MS OS/2 base header files
  13894.  
  13895.    #define     INCL_NETERRORS
  13896.    #define     INCL_NETHANDLE
  13897.    #include    <lan.h>        // LAN Manager header files
  13898.  
  13899.    #include    <stdio.h>      // C run-time header files
  13900.    #include    <stdlib.h>
  13901.    #include    <string.h>
  13902.    #include    <chardev.h>
  13903.    #include    <io.h>
  13904.  
  13905.    #define PIPENAMELEN        128
  13906.    #define BUFFLEN            128
  13907.    #define PIPE_BUFFSIZE      2048
  13908.    #define DEFAULT_MESSAGE    "Message from server"
  13909.    #define DEFAULT_PIPE       "handtest"
  13910.    #define OPENMODE            NP_ACCESS_DUPLEX
  13911.    #define PIPEMODE            NP_READMODE_BYTE | NP_TYPE_BYTE | NP_WAIT
  13912.    | \
  13913.                                NP_UNLIMITED_INSTANCES
  13914.  
  13915.    void Usage (char * pszProgram);
  13916.  
  13917.    void main(int argc, char *argv[])
  13918.    {
  13919.       char * pszMessage  = DEFAULT_MESSAGE;  // Message to send down
  13920.    pipe
  13921.       char * pszPipeName = DEFAULT_PIPE;     // Supplied pipename
  13922.       char   achBuffer[BUFFLEN];             // Data buffer
  13923.       char   achFullPipe[PIPENAMELEN];       // Full name of pipe to
  13924.    open
  13925.       int    iArgv;                          // Index for arguments
  13926.       unsigned short hPipe;                  // Handle to named pipe
  13927.       unsigned short cbAvail;                // Bytes available from
  13928.    GetInfo
  13929.       unsigned short usReturnCode;           // MS OS/2 return code
  13930.       API_RET_TYPE uReturnCode;              // LAN Manager API return
  13931.    code
  13932.       struct handle_info_2 * pHandleInfo2;
  13933.  
  13934.       for (iArgv = 1; iArgv < argc; iArgv++)
  13935.       {
  13936.          if ((*argv[iArgv] == '-') || (*argv[iArgv] == '/'))
  13937.          {
  13938.             switch (tolower(*(argv[iArgv]+1))) // Process switches
  13939.             {
  13940.                case 'p':                       // -p pipename
  13941.                   pszPipeName = argv[++iArgv];
  13942.                   break;
  13943.                case 'm':                       // -m message
  13944.                   pszMessage = argv[++iArgv];
  13945.                   break;
  13946.                case 'h':
  13947.                default:
  13948.                   Usage(argv[0]);
  13949.             }
  13950.          }
  13951.          else
  13952.             Usage(argv[0]);
  13953.       }
  13954.  
  13955.       strcpy(achFullPipe, "\\PIPE\\");       // Set up named pipe
  13956.       strcat(achFullPipe, pszPipeName);
  13957.  
  13958.  
  13959.  
  13960.  
  13961.  
  13962.  
  13963.       printf("Creating Named Pipe %s\n", achFullPipe);
  13964.  
  13965.       if (usReturnCode = DosMakeNmPipe(
  13966.                             achFullPipe,     // Name of pipe to open
  13967.                             &hPipe,          // Handle to opened pipe
  13968.                             OPENMODE,        // Full duplex
  13969.                             PIPEMODE,        // Unlimited opens, blocked
  13970.    mode
  13971.                             PIPE_BUFFSIZE,   // Outgoing buffer size
  13972.                             PIPE_BUFFSIZE,   // Incoming buffer size
  13973.                             0L))             // Time-out value
  13974.       {
  13975.          printf( "DosMakeNmPipe failed (error %hu).\n", usReturnCode
  13976.    );
  13977.          exit(1);
  13978.       }
  13979.  
  13980.       printf("Waiting for Connect to Pipe... \n" );
  13981.  
  13982.       if (usReturnCode = DosConnectNmPipe(hPipe))
  13983.       {
  13984.          printf("DosConnectNmPipe failed (error %hu).\n", usReturnCode);
  13985.          exit(1);
  13986.       }
  13987.  
  13988.       printf("Waiting for message from pipe... \n" );
  13989.  
  13990.       if (read( hPipe, achBuffer, BUFFLEN ) == -1)
  13991.       {
  13992.          printf("   Read message failed (error %d)\n", errno);
  13993.          exit(1);
  13994.       }
  13995.       else
  13996.       {
  13997.          printf("   \"%s\"\n", achBuffer);
  13998.       }
  13999.  
  14000.       /*
  14001.        * Write message to the named pipe. Make sure that the message
  14002.        * length specified includes the terminating NUL.
  14003.        */
  14004.  
  14005.       printf("Writing message \"%s\" \n", pszMessage );
  14006.  
  14007.       if (write(hPipe, pszMessage, strlen(pszMessage) + 1) == -1)
  14008.       {
  14009.          printf("   Write message failed (error %d)\n", errno);
  14010.          exit(1);
  14011.       }
  14012.  
  14013.    //========================================================================
  14014.    //  NetHandleGetInfo
  14015.    //
  14016.    //  This API gets the name of the user who is connected to the named
  14017.    pipe.
  14018.    //  It can be called only at level 2 on the server end of a handle.
  14019.    //========================================================================
  14020.  
  14021.       uReturnCode = NetHandleGetInfo(
  14022.                         hPipe,               // Handle to named pipe
  14023.                         2,                   // Level 2
  14024.                         achBuffer,           // Data returned here
  14025.                         BUFFLEN,             // Size of buffer, in bytes
  14026.                         (unsigned short far *) &cbAvail);
  14027.  
  14028.       printf("NetHandleGetInfo returned %u\n", uReturnCode);
  14029.  
  14030.       if (uReturnCode == NERR_Success)
  14031.       {
  14032.          pHandleInfo2 = (struct handle_info_2 *) achBuffer;
  14033.          printf("   User of the named pipe is %Fs\n",
  14034.                                    pHandleInfo2->hdli2_username );
  14035.       }
  14036.  
  14037.       do                                     // Wait for disconnect
  14038.       {
  14039.       } while (DosConnectNmPipe(hPipe) == 0 );
  14040.  
  14041.       if ((usReturnCode = DosDisConnectNmPipe(hPipe)) == 0)
  14042.          printf("Pipe disconnected. \n");
  14043.       else
  14044.       {
  14045.          printf("DosDisConnectNmPipe failed (error %hu).\n", usReturnCode);
  14046.          exit(1);
  14047.       }
  14048.       exit(0);
  14049.    }
  14050.  
  14051.    void Usage (char * pszProgram)
  14052.    {
  14053.       fprintf(stderr, "Usage: %s [-p pipename] [-m message] \n", pszProgram);
  14054.       exit(1);
  14055.    }
  14056.  
  14057.    /*
  14058.       NETHAND2.C -- a sample program demonstrating NetHandle API functions
  14059.                     for the workstation side of named pipes.
  14060.  
  14061.       This program must be run on a computer that has the Workstation
  14062.    service
  14063.       running. It is to be used in conjunction with the program NETHAND1
  14064.       running on a server.
  14065.  
  14066.          usage: nethand2 -s \\server [-p pipename] [-m message]
  14067.  
  14068.          where  \\server = Name of the server. A servername
  14069.                            must be preceded by two backslashes (\\).
  14070.                 pipename = Name of the pipe to connect to.
  14071.                 message  = Message to be sent through the pipe.
  14072.  
  14073.       Run NETHAND1 on the server to create a named pipe, then run
  14074.       NETHAND2 on a workstation to connect to that named pipe.
  14075.  
  14076.       API                  Used to...
  14077.       ================     ================================================
  14078.       NetHandleGetInfo     Get the values for charcount and chartime
  14079.       NetHandleSetInfo     Set the value for charcount to half the original
  14080.  
  14081.       This code sample is provided for demonstration purposes only.
  14082.       Microsoft makes no warranty, either express or implied,
  14083.       as to its usability in any given situation.
  14084.    */
  14085.  
  14086.  
  14087.    #define     INCL_NETERRORS
  14088.    #define     INCL_NETHANDLE
  14089.    #include    <lan.h>        // LAN Manager header files
  14090.  
  14091.    #include    <stdio.h>      // C run-time header files
  14092.    #include    <stdlib.h>
  14093.    #include    <string.h>
  14094.    #include    <chardev.h>
  14095.    #include    <fcntl.h>
  14096.    #include    <sys\types.h>
  14097.    #include    <sys\stat.h>
  14098.    #include    <share.h>
  14099.    #include    <io.h>
  14100.  
  14101.    #define PIPENAMELEN        128
  14102.    #define BUFFLEN            128
  14103.    #define DEFAULT_MESSAGE    "Message from workstation"
  14104.    #define DEFAULT_PIPE       "handtest"
  14105.  
  14106.    void Usage (char * pszProgram);
  14107.  
  14108.    void main(int argc, char *argv[])
  14109.    {
  14110.       char * pszServer   = NULL;
  14111.       char * pszMessage  = DEFAULT_MESSAGE;  // Message to send down
  14112.    pipe
  14113.       char * pszPipeName = DEFAULT_PIPE;     // Supplied pipename
  14114.       char   achFullPipe[PIPENAMELEN];       // Full name of pipe
  14115.       char   achBuffer[BUFFLEN];             // Data buffer
  14116.       int    iArgv;                          // Index for arguments
  14117.       unsigned short hPipe;                  // Handle to named pipe
  14118.       unsigned short cbAvail;                // Bytes available from
  14119.    GetInfo
  14120.       unsigned short cbCharCount;            // Pipe charcount
  14121.       API_RET_TYPE uReturnCode;              // LAN Manager API return
  14122.    code
  14123.       struct handle_info_1 HandleInfo1;
  14124.  
  14125.       for (iArgv = 1; iArgv < argc; iArgv++)
  14126.       {
  14127.          if ((*argv[iArgv] == '-') || (*argv[iArgv] == '/'))
  14128.          {
  14129.             switch (tolower(*(argv[iArgv]+1))) // Process switches
  14130.             {
  14131.                case 's':                       // -s servername
  14132.                   pszServer = argv[++iArgv];
  14133.                   break;
  14134.                case 'p':                       // -p pipename
  14135.                   pszPipeName = argv[++iArgv];
  14136.                   break;
  14137.                case 'm':                       // -m message
  14138.                   pszMessage = argv[++iArgv];
  14139.                   break;
  14140.                case 'h':
  14141.                default:
  14142.                   Usage(argv[0]);
  14143.             }
  14144.          }
  14145.          else
  14146.             Usage(argv[0]);
  14147.       }
  14148.  
  14149.       if (pszServer == NULL)                 // Must specify a servername
  14150.       {
  14151.          Usage(argv[0]);
  14152.       }
  14153.  
  14154.  
  14155.  
  14156.  
  14157.                                              // Set up full name of pipe
  14158.       strcpy(achFullPipe, pszServer);
  14159.       strcat(achFullPipe, "\\PIPE\\");
  14160.       strcat(achFullPipe, pszPipeName);
  14161.  
  14162.       printf("Opening named pipe %s\n", achFullPipe);
  14163.       if ((hPipe = sopen(achFullPipe, O_BINARY | O_RDWR, SH_DENYNO))==  -1)
  14164.       {
  14165.          printf( "   Open of pipe failed (error %d).\n", errno );
  14166.          exit(1);
  14167.       }
  14168.  
  14169.  
  14170.    // NetHandleGetInfo
  14171.    //
  14172.    //  This API gets the values for chartime and charcount for the named
  14173.    pipe.
  14174.    //  These values will be the same as the default values for the
  14175.  workstation
  14176.    //  as listed in the LANMAN.INI file (unless explicitly altered).
  14177.    This API
  14178.    //  can be called only at level 1 on the workstation end of a
  14179.  serial-device
  14180.    //  handle.
  14181.  
  14182.       uReturnCode = NetHandleGetInfo(
  14183.                         hPipe,                    // Handle to named
  14184.    pipe
  14185.                         1,                        // Level 1
  14186.                         (char far *)&HandleInfo1, // Data returned here
  14187.                         sizeof(struct handle_info_1),
  14188.                         (unsigned short far *) &cbAvail);
  14189.  
  14190.       printf("NetHandleGetInfo returned %u\n", uReturnCode);
  14191.  
  14192.       if (uReturnCode == NERR_Success)
  14193.       {
  14194.          cbCharCount = HandleInfo1.hdli1_charcount;
  14195.          printf("   Chartime  = %ld\n", HandleInfo1.hdli1_chartime);
  14196.          printf("   CharCount = %hu\n", cbCharCount);
  14197.       }
  14198.  
  14199.    //========================================================================
  14200.    //  NetHandleSetInfo
  14201.    //
  14202.    //  This API sets the value for charcount to half the default value.
  14203.    //  There are two ways to call NetHandleSetInfo: If sParmNum is set
  14204.    to
  14205.    //  PARMNUM_ALL, you must pass a whole structure. Otherwise, you can
  14206.  
  14207.    //  set sParmNum to the element of the structure you want to change
  14208.    and
  14209.    //  pass a pointer to the value. The second method is shown here.
  14210.    //========================================================================
  14211.       cbCharCount /= 2;
  14212.       printf("Setting the charcount to %hu\n", cbCharCount);
  14213.  
  14214.       uReturnCode = NetHandleSetInfo(
  14215.                         hPipe,                    // Handle to named
  14216.    pipe
  14217.                         1,                        // Level; must be 1
  14218.                         (char far *)&cbCharCount, // Data to be set
  14219.                         sizeof(unsigned short),   // Size of buffer
  14220.                         HANDLE_SET_CHAR_COUNT);   // Set the charcount
  14221.    only
  14222.  
  14223.       printf("NetHandleSetInfo returned %u\n", uReturnCode);
  14224.  
  14225.                                                   // Verify the values
  14226.    set
  14227.       uReturnCode = NetHandleGetInfo(
  14228.                         hPipe,                    // Handle to named
  14229.    pipe
  14230.                         1,                        // Level 1
  14231.                         (char far *)&HandleInfo1, // Data returned here
  14232.                         sizeof(struct handle_info_1),
  14233.                         (unsigned short far *) &cbAvail);
  14234.  
  14235.       printf("NetHandleGetInfo returned %u\n", uReturnCode);
  14236.  
  14237.       if (uReturnCode == NERR_Success)
  14238.       {
  14239.          printf("   Chartime  = %lu\n", HandleInfo1.hdli1_chartime);
  14240.          printf("   CharCount = %hu\n", HandleInfo1.hdli1_charcount);
  14241.       }
  14242.  
  14243.    /*
  14244.        * Write a message to the named pipe. Make sure that the
  14245.        * message length specified includes the terminating NUL.
  14246.        */
  14247.  
  14248.       printf("Writing \"%s\" to pipe... \n", pszMessage);
  14249.  
  14250.       if (write(hPipe, pszMessage, strlen(pszMessage) + 1) == -1)
  14251.       {
  14252.          printf("   Write message failed (error %d)\n", errno);
  14253.          exit(1);
  14254.       }
  14255.  
  14256.    printf("Waiting for message from pipe... \n" );
  14257.  
  14258.       if (read(hPipe, achBuffer, BUFFLEN) == -1)
  14259.       {
  14260.          printf("   Read message failed (error %d)\n", errno);
  14261.          exit(1);
  14262.       }
  14263.       printf("    \"%s\"\n", achBuffer);
  14264.  
  14265.       printf("Closing pipe...\n");           // Close the pipe
  14266.       if (close(hPipe))
  14267.       {
  14268.          printf("   Close handle failed (error %d)\n", errno);
  14269.          exit(1);
  14270.       }
  14271.       exit(0);
  14272.    }
  14273.  
  14274.    void Usage (char * pszProgram)
  14275.    {
  14276.       fprintf(stderr, "Usage: %s -s \\\\server [-p pipename] [-m message]
  14277.    \n",
  14278.                  pszProgram);
  14279.       exit(1);
  14280.    }
  14281.  
  14282.  
  14283.  
  14284.  
  14285.  
  14286.  
  14287.  
  14288.  
  14289.  
  14290.  Mailslot Category
  14291.  
  14292.  Mailslot API functions provide one-way interprocess communication (IPC).
  14293.  They require that the NETWKSTA device driver be installed and, when trying
  14294.  to access remote resources, that the Workstation service be started.
  14295.  
  14296.  The Mailslot category functions, datatypes, structures, and constants are
  14297.  defined in the NETCONS.H, NETERR.H, and MAILSLOT.H header files. A source
  14298.  program can access these definitions by defining the constants
  14299.  INCL_NETERRORS and INCL_NETMAILSLOT, and including the master header file,
  14300.  LAN.H. For more information, see the "Example" section, later in this
  14301.  category.
  14302.  
  14303.  These are the Mailslot API functions:
  14304.  
  14305.  
  14306.    ■   DosDeleteMailslot
  14307.  
  14308.    ■   DosMailslotInfo
  14309.  
  14310.    ■   DosMakeMailslot
  14311.  
  14312.    ■   DosPeekMailslot
  14313.  
  14314.    ■   DosReadMailslot
  14315.  
  14316.    ■   DosWriteMailslot
  14317.  
  14318.  
  14319.  
  14320.  Description
  14321.  
  14322.  An application can use LAN Manager mailslots to send data to local or remote
  14323.  applications on the network. Mailslot API functions manage mailslots and
  14324.  mailslot messages.
  14325.  
  14326.  DosMakeMailslot creates a mailslot and returns its handle. DosPeekMailslot
  14327.  reads the highest-priority, most current message without removing it from
  14328.  the mailslot. DosReadMailslot reads the highest-priority, most current
  14329.  message, and then removes it from the mailslot. DosWriteMailslot writes a
  14330.  message to a mailslot. Applications can write messages to any mailslot on
  14331.  any computer or in any domain on the network. The message can be any form of
  14332.  data─it need not be an ASCIIZ string. DosMailslotInfo retrieves information
  14333.  about a particular mailslot. DosDeleteMailslot removes a mailslot,
  14334.  discarding all unread messages.
  14335.  
  14336.  There are two classes of mailslot message delivery: first-class and
  14337.  second-class. First-class messages are successfully delivered or the sender
  14338.  is notified with the appropriate error return code. If a mailslot is full
  14339.  when a first-class message arrives, DosWriteMailslot waits until a message
  14340.  is read and removed from the mailslot (using DosReadMailslot) or until the
  14341.  delivery time-out expires (controlled by the cTimeout parameter in
  14342.  DosWriteMailslot). First-class messages can be used only with mailslots on
  14343.  the local computer and remote servers.
  14344.  
  14345.  Successful delivery of second-class messages is not guaranteed. There is no
  14346.  way to determine whether a message arrived successfully. The simpler
  14347.  delivery system tends to make second-class messages faster than first-class
  14348.  messages. Second-class messages can be sent to any remote computer, not just
  14349.  to remote servers, and can be sent to multiple computers simultaneously.
  14350.  
  14351.  Each message is assigned a priority from 0 (lowest priority) through 9
  14352.  (highest priority) using the DosWriteMailslot usPriority parameter. Messages
  14353.  are stored in the mailslot sorted first by priority, then by time of
  14354.  arrival. High-priority messages are placed ahead of previously stored
  14355.  messages that have the same or lower priority. Since MS OS/2 is a
  14356.  multitasking operating system, this scheme cannot be guaranteed at any
  14357.  instant (messages could be received but not yet sorted).
  14358.  
  14359.  
  14360.  DosPeekMailslot and DosReadMailslot read the oldest message of highest
  14361.  priority. Since new messages can be placed ahead of others, a message read
  14362.  by DosReadMailslot might not be the same one read earlier by
  14363.  DosPeekMailslot.
  14364.  
  14365.  DosMailslotInfo retrieves information about a mailslot, such as its maximum
  14366.  size, the maximum size of messages it can accept, the priority and size of
  14367.  the next message, and the total number of messages waiting to be read.
  14368.  
  14369.  To write data to a mailslot on a remote computer, the name of the mailslot
  14370.  must include a computername. This enables multiple remote computers to use
  14371.  the same mailslot name locally but to use different names on the network
  14372.  (the computername must be unique).
  14373.  
  14374.  An application can write the same message to all computers in a domain that
  14375.  have a mailslot with a particular name. In this case, only second-class
  14376.  delivery is supported. Specifying an asterisk (*) as the computername when
  14377.  calling DosWriteMailslot sends the same message to the named mailslot on
  14378.  every computer in the sender's primary domain. Use this mailslot format:
  14379.  
  14380.  \\*\mailslot\mailslotname
  14381.  
  14382.  Specifying a domain name for the computername when calling DosWriteMailslot
  14383.  sends the same message to the named mailslot on every computer in the
  14384.  specified domain. Use this mailslot format:
  14385.  
  14386.  \\domainname\mailslot\mailslotname
  14387.  
  14388.  Workstations can receive only second-class messages, with as many as 400
  14389.  bytes per message. Servers can receive first-class or second-class messages
  14390.  of any size.
  14391.  
  14392.  Mailslots can be read or deleted only by the process that created them.
  14393.  Mailslots created by a process are deleted when that process ends.
  14394.  
  14395.  See Also
  14396.  
  14397.  For information about             See
  14398.  ────────────────────────────────────────────────────────────────────────────
  14399.  Interprocess communication (IPC)  Appendix F, "Network Considerations for
  14400.                                    Named Pipes"
  14401.  
  14402.  
  14403.  DosDeleteMailslot
  14404.  ────────────────────────────────────────────────────────────────────────────
  14405.  
  14406.  DosDeleteMailslot deletes a mailslot, discarding all messages whether or not
  14407.  they have been read.
  14408.  
  14409.  
  14410.  Operating Systems Supported
  14411.  
  14412.  
  14413.    ■   MS OS/2 version 1.2, local only
  14414.  
  14415.    ■   MS OS/2 version 1.1, local only
  14416.  
  14417.    ■   MS-DOS, local only
  14418.  
  14419.  
  14420.  
  14421.  Privilege Level
  14422.  
  14423.  No special privilege level is required to successfully execute
  14424.  DosDeleteMailslot.
  14425.  
  14426.  
  14427.  Syntax
  14428.  
  14429.    #define INCL_NETMAILSLOT
  14430.    #define INCL_NETERRORS
  14431.    #include <lan.h>
  14432.  
  14433.    API_FUNCTION
  14434.    DosDeleteMailslot (unsigned  hMailslot);
  14435.  
  14436.  where
  14437.  
  14438.  hMailslot
  14439.    Specifies a handle for the mailslot to be deleted. The handle must have
  14440.    been returned by a previous call to DosMakeMailslot.
  14441.  
  14442.  Return Codes
  14443.  
  14444.  Code                  Value   Meaning
  14445.  ────────────────────────────────────────────────────────────────────────────
  14446.  NERR_Success          0       The function encountered no errors.
  14447.  
  14448.  ERROR_INVALID_HANDLE  6       The handle specified is invalid.
  14449.  
  14450.  NERR_NetNotStarted    2102    The LAN Manager NETWKSTA driver is not
  14451.                                installed.
  14452.  
  14453.  ────────────────────────────────────────────────────────────────────────────
  14454.  
  14455.  
  14456.  
  14457.  Remarks
  14458.  
  14459.  Mailslots are generally deleted as the last step in a program's execution. A
  14460.  mailslot can be deleted only by the application that created it.
  14461.  
  14462.  
  14463.  DosMailslotInfo
  14464.  ────────────────────────────────────────────────────────────────────────────
  14465.  
  14466.  DosMailslotInfo retrieves information about a particular mailslot.
  14467.  
  14468.  
  14469.  Operating Systems Supported
  14470.  
  14471.  
  14472.    ■   MS OS/2 version 1.2, local only
  14473.  
  14474.    ■   MS OS/2 version 1.1, local only
  14475.  
  14476.    ■   MS-DOS, local only
  14477.  
  14478.  
  14479.  
  14480.  Privilege Level
  14481.  
  14482.  No special privilege level is required to successfully execute
  14483.  DosMailslotInfo.
  14484.  
  14485.  
  14486.  Syntax
  14487.  
  14488.    #define INCL_NETMAILSLOT
  14489.    #define INCL_NETERRORS
  14490.    #include <lan.h>
  14491.  
  14492.    API_FUNCTION
  14493.    DosMailslotInfo (unsigned              hMailslot,
  14494.                     unsigned short far *  pcbMessageSize,
  14495.                     unsigned short far *  pcbMailslotSize,
  14496.                     unsigned short far *  pcbNextSize,
  14497.                     unsigned short far *  pusNextPriority,
  14498.                     unsigned short far *  pcMessages
  14499.                    );
  14500.  
  14501.  where
  14502.  
  14503.  hMailslot
  14504.    Specifies a handle for the mailslot about which information is requested.
  14505.    The handle must have been returned by a previous call to DosMakeMailslot.
  14506.  
  14507.  pcbMessageSize
  14508.    Points to an unsigned short integer in which the maximum message size (in
  14509.    bytes) that the mailslot can accept is returned.
  14510.  
  14511.  pcbMailslotSize
  14512.    Points to an unsigned short integer in which the size (in bytes) of the
  14513.    mailslot is returned.
  14514.  
  14515.  pcbNextSize
  14516.    Points to an unsigned short integer in which the size (in bytes) of the
  14517.    next message in the mailslot is returned. If this value is 0, no message
  14518.    is available.
  14519.  
  14520.  pusNextPriority
  14521.    Points to an unsigned short integer in which the priority (0 through 9) of
  14522.    the next message in the mailslot is returned.
  14523.  
  14524.  pcMessages
  14525.    Points to an unsigned short integer in which a count of the messages in
  14526.    the mailslot is returned.
  14527.  
  14528.  Return Codes
  14529.  
  14530.  Code                  Value   Meaning
  14531.  ────────────────────────────────────────────────────────────────────────────
  14532.  NERR_Success          0       The function encountered no errors.
  14533.  
  14534.  ERROR_INVALID_HANDLE  6       The handle specified is invalid.
  14535.  
  14536.  ERROR_BROKEN_PIPE     109     The pipe has been closed or the pipe is not
  14537.                                being read.
  14538.  
  14539.  NERR_NetNotStarted    2102    The LAN Manager NETWKSTA driver is not
  14540.                                installed.
  14541.  
  14542.  ────────────────────────────────────────────────────────────────────────────
  14543.  
  14544.  
  14545.  
  14546.  Remarks
  14547.  
  14548.  DosMailslotInfo can be used before DosReadMailslot or DosPeekMailslot to
  14549.  determine the buffer size needed to read the next message. This may fail,
  14550.  because a higher-priority message can arrive after the DosMailslotInfo call
  14551.  and before the identified message is read.
  14552.  
  14553.  If the mailslot is deleted while being queried by DosMailslotInfo, the error
  14554.  code ERROR_BROKEN_PIPE is returned.
  14555.  
  14556.  See Also
  14557.  
  14558.  For information about             See
  14559.  ────────────────────────────────────────────────────────────────────────────
  14560.  Creating (and obtaining the       DosMakeMailslot
  14561.  handle for) a mailslot
  14562.  
  14563.  Retrieving the most current       DosReadMailslot
  14564.  message in a mailslot
  14565.  
  14566.  Writing a message to a mailslot   DosWriteMailslot
  14567.  
  14568.  
  14569.  DosMakeMailslot
  14570.  ────────────────────────────────────────────────────────────────────────────
  14571.  
  14572.  DosMakeMailslot creates a mailslot on a local computer and returns a handle
  14573.  to that mailslot. The other Mailslot API functions can then use this handle.
  14574.  
  14575.  
  14576.  The mailslot name supplied to the function should be in the format
  14577.  
  14578.  \mailslot\mailslotname
  14579.  
  14580.  where mailslotname is a unique set of characters that distinguish the
  14581.  mailslot from other mailslots on the computer (for example,
  14582.  \mailslot\test\slot1).
  14583.  
  14584.  
  14585.  Operating Systems Supported
  14586.  
  14587.  
  14588.    ■   MS OS/2 version 1.2, local only
  14589.  
  14590.    ■   MS OS/2 version 1.1, local only
  14591.  
  14592.    ■   MS-DOS, local only
  14593.  
  14594.  
  14595.  
  14596.  Privilege Level
  14597.  
  14598.  No special privilege level is required to successfully execute
  14599.  DosMakeMailslot.
  14600.  
  14601.  
  14602.  Syntax
  14603.  
  14604.    #define INCL_NETMAILSLOT
  14605.    #define INCL_NETERRORS
  14606.    #include <lan.h>
  14607.  
  14608.    API_FUNCTION
  14609.    DosMakeMailslot (const char far *  pszName,
  14610.                     unsigned short    cbMessageSize,
  14611.                     unsigned short    cbMailslotSize,
  14612.                     unsigned far *    phMailslot
  14613.                    );
  14614.  
  14615.  where
  14616.  
  14617.  pszName
  14618.    Points to an ASCIIZ string that contains the name of the mailslot.
  14619.  
  14620.  cbMessageSize
  14621.    Specifies the maximum message size (in bytes) that the mailslot can
  14622.    accept. Mailslots can accept messages that have as many as 65,475 bytes.
  14623.  
  14624.  cbMailslotSize
  14625.    Specifies the size (in bytes) of the mailslot. This parameter must be 0,
  14626.    or it must be equal to or exceed cbMessageSize. If this value is 0,
  14627.    DosMakeMailslot sets a value based on cbMessageSize.
  14628.  
  14629.  phMailslot
  14630.    Points to an unsigned integer that is the returned handle for the
  14631.    mailslot. This handle must be used for all subsequent operations on the
  14632.    mailslot.
  14633.  
  14634.  Return Codes
  14635.  
  14636. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  14637.  Code                              Value   Meaning
  14638.  ────────────────────────────────────────────────────────────────────────────
  14639.  Code                              Value   Meaning
  14640.  ────────────────────────────────────────────────────────────────────────────
  14641.  NERR_Success                      0       The function encountered no
  14642.                                            errors.
  14643.  
  14644.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  14645.  
  14646.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  14647.                                            invalid.
  14648.  
  14649.  ERROR_ALREADY_EXISTS              183     A loader error occurred.
  14650.  
  14651.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  14652.                                            is not installed.
  14653.  
  14654.  ────────────────────────────────────────────────────────────────────────────
  14655.  
  14656.  
  14657.  
  14658.  
  14659.  Remarks
  14660.  
  14661.  Mailslot names must be unique; no two mailslots on any one computer can have
  14662.  the same name. An attempt to create a mailslot with the name of a mailslot
  14663.  that already exists results in ERROR_ALREADY_EXISTS being returned.
  14664.  
  14665.  You cannot pass mailslot handles to other processes using the DosExecPgm
  14666.  function, but mailslot handles can be shared among threads in a single
  14667.  process. Multiple threads can use the handle to read or write data to the
  14668.  mailslot.
  14669.  
  14670.  See Also
  14671.  
  14672.  For information about             See
  14673.  ────────────────────────────────────────────────────────────────────────────
  14674.  Deleting a mailslot               DosDeleteMailslot
  14675.  
  14676.  Retrieving information about a    DosMailslotInfo
  14677.  mailslot
  14678.  
  14679.  
  14680.  DosPeekMailslot
  14681.  ────────────────────────────────────────────────────────────────────────────
  14682.  
  14683.  DosPeekMailslot reads the highest-priority, most current message in a
  14684.  mailslot without removing it.
  14685.  
  14686.  
  14687.  Operating Systems Supported
  14688.  
  14689.  
  14690.    ■   MS OS/2 version 1.2, local only
  14691.  
  14692.    ■   MS OS/2 version 1.1, local only
  14693.  
  14694.    ■   MS-DOS, local only
  14695.  
  14696.  
  14697.  
  14698.  Privilege Level
  14699.  
  14700.  No special privilege level is required to successfully execute
  14701.  DosPeekMailslot.
  14702.  
  14703.  
  14704.  Syntax
  14705.  
  14706.    #define INCL_NETMAILSLOT
  14707.    #define INCL_NETERRORS
  14708.    #include <lan.h>
  14709.  
  14710.    API_FUNCTION
  14711.    DosPeekMailslot (unsigned              hMailslot,
  14712.                     char far *            pbBuffer,
  14713.                     unsigned short far *  pcbReturned,
  14714.                     unsigned short far *  pcbNextSize,
  14715.                     unsigned short far *  pusNextPriority
  14716.                    );
  14717.  
  14718.  where
  14719.  
  14720.  hMailslot
  14721.    Specifies the handle of the mailslot to be read. The handle must have been
  14722.    returned by a previous call to DosMakeMailslot.
  14723.  
  14724.  pbBuffer
  14725.    Points to the buffer in which to store the returned message. The buffer
  14726.    should be as large as the cbMessageSize parameter passed to
  14727.    DosMakeMailslot.
  14728.  
  14729.  pcbReturned
  14730.    Points to an unsigned short integer in which the size (in bytes) of the
  14731.    new message is returned. If no message is available, pcbReturned is 0.
  14732.  
  14733.  pcbNextSize
  14734.    Points to an unsigned short integer in which the size (in bytes) of the
  14735.    next message in the mailslot is returned. If the mailslot does not contain
  14736.    another message, pcbNextSize is 0.
  14737.  
  14738.  pusNextPriority
  14739.    Points to an unsigned short integer in which the priority (0 through 9) of
  14740.    the next message in the mailslot is returned. This value is valid only if
  14741.    pcbNextSize is not 0.
  14742.  
  14743.  Return Codes
  14744.  
  14745.  Code                  Value   Meaning
  14746.  ────────────────────────────────────────────────────────────────────────────
  14747.  NERR_Success          0       The function encountered no errors.
  14748.  
  14749.  ERROR_INVALID_HANDLE  6       The handle specified is invalid.
  14750.  
  14751.  ERROR_BROKEN_PIPE     109     The pipe has been closed or the pipe is not
  14752.                                being read.
  14753.  
  14754.  NERR_NetNotStarted    2102    The LAN Manager NETWKSTA driver is not
  14755.                                installed.
  14756.  
  14757.  ────────────────────────────────────────────────────────────────────────────
  14758.  
  14759.  
  14760.  
  14761.  Remarks
  14762.  
  14763.  There is no guarantee that a message read by calling DosPeekMailslot will be
  14764.  the same message read by a subsequent call to DosReadMailslot. A
  14765.  higher-priority message can arrive between the two calls.
  14766.  
  14767.  If the mailslot is deleted while being queried by DosPeekMailslot, the error
  14768.  code ERROR_BROKEN_PIPE is returned.
  14769.  
  14770.  See Also
  14771.  
  14772.  For information about             See
  14773.  ────────────────────────────────────────────────────────────────────────────
  14774.  Creating a mailslot               DosMakeMailslot
  14775.  
  14776.  Reading and removing a message    DosReadMailslot
  14777.  
  14778.  Writing a message to a mailslot   DosWriteMailslot
  14779.  
  14780.  
  14781.  DosReadMailslot
  14782.  ────────────────────────────────────────────────────────────────────────────
  14783.  
  14784.  DosReadMailslot reads and then removes the highest-priority, most current
  14785.  message in a mailslot.
  14786.  
  14787.  
  14788.  Operating Systems Supported
  14789.  
  14790.  
  14791.    ■   MS OS/2 version 1.2, local only
  14792.  
  14793.    ■   MS OS/2 version 1.1, local only
  14794.  
  14795.    ■   MS-DOS, local only
  14796.  
  14797.  
  14798.  
  14799.  Privilege Level
  14800.  
  14801.  No special privilege level is required to successfully execute
  14802.  DosReadMailslot.
  14803.  
  14804.  
  14805.  Syntax
  14806.  
  14807.    #define INCL_NETMAILSLOT
  14808.    #define INCL_NETERRORS
  14809.    #include <lan.h>
  14810.  
  14811.    API_FUNCTION
  14812.    DosReadMailslot (unsigned              hMailslot,
  14813.                     char far *            pbBuffer,
  14814.                     unsigned short far *  pcbReturned,
  14815.                     unsigned short far *  pcbNextSize,
  14816.                     unsigned short far *  pusNextPriority,
  14817.                     long                  cTimeout
  14818.                    );
  14819.  
  14820.  where
  14821.  
  14822.  hMailslot
  14823.    Specifies the handle of the mailslot to be read. The handle must have been
  14824.    returned by a previous call to DosMakeMailslot.
  14825.  
  14826.  pbBuffer
  14827.    Points to the buffer in which to store the returned message. The buffer
  14828.    should be as large as the cbMessageSize parameter passed to
  14829.    DosMakeMailslot.
  14830.  
  14831.  pcbReturned
  14832.    Points to an unsigned short integer in which the size (in bytes) of the
  14833.    new message is returned. If no message is available, pcbReturned is 0.
  14834.  
  14835.  pcbNextSize
  14836.    Points to an unsigned short integer in which the size (in bytes) of the
  14837.    next message in the mailslot is returned. If the mailslot does not contain
  14838.    another message, pcbNextSize is 0.
  14839.  
  14840.  pusNextPriority
  14841.    Points to an unsigned short integer in which the priority (0 through 9) of
  14842.    the next message in the mailslot is returned. This value is valid only if
  14843.    pcbNextSize is not 0.
  14844.  
  14845.  cTimeout
  14846.    Specifies how many milliseconds to wait if a message is not available
  14847.    immediately. If this value is 0, DosReadMailslot does not wait; if it is
  14848.    MAILSLOT_NO_TIMEOUT, DosReadMailslot waits indefinitely.
  14849.  
  14850.  Return Codes
  14851.  
  14852. ╓┌─────────────────────┌───────┌─────────────────────────────────────────────╖
  14853.  Code                  Value   Meaning
  14854.  ────────────────────────────────────────────────────────────────────────────
  14855.  NERR_Success          0       The function encountered no errors.
  14856.  
  14857.  ERROR_INVALID_HANDLE  6       The handle specified is invalid.
  14858.  
  14859.  ERROR_INTERUPT        95      The system call was interrupted.
  14860.  
  14861.  ERROR_BROKEN_PIPE     109     The pipe has been closed or the pipe is not
  14862.                                being read.
  14863.  
  14864.  ERROR_SEM_TIMEOUT     121     A time-out occurred from the Semaphore API
  14865.                                functions.
  14866.  
  14867.  NERR_NetNotStarted    2102    The LAN Manager NETWKSTA driver is not
  14868.                                installed.
  14869.  
  14870.  Code                  Value   Meaning
  14871.  ────────────────────────────────────────────────────────────────────────────
  14872. 
  14873.  ────────────────────────────────────────────────────────────────────────────
  14874.  
  14875.  
  14876.  
  14877.  
  14878.  Remarks
  14879.  
  14880.  If the mailslot is deleted while being queried by DosReadMailslot, the error
  14881.  code ERROR_BROKEN_PIPE is returned.
  14882.  
  14883.  If no message is waiting to be read, and none arrives within the period
  14884.  specified by cTimeout, DosReadMailslot returns ERROR_SEM_TIMEOUT.
  14885.  
  14886.  See Also
  14887.  
  14888.  For information about             See
  14889.  ────────────────────────────────────────────────────────────────────────────
  14890.  Creating a mailslot               DosMakeMailslot
  14891.  
  14892.  Reading a message without         DosPeekMailslot
  14893.  removing it
  14894.  
  14895.  Writing a message to a mailslot   DosWriteMailslot
  14896.  
  14897.  
  14898.  DosWriteMailslot
  14899.  ────────────────────────────────────────────────────────────────────────────
  14900.  
  14901.  DosWriteMailslot writes a message to a particular mailslot.
  14902.  
  14903.  
  14904.  Operating Systems Supported
  14905.  
  14906.  
  14907.    ■   MS OS/2 version 1.2, local only
  14908.  
  14909.    ■   MS OS/2 version 1.1, local only
  14910.  
  14911.    ■   MS-DOS, local only
  14912.  
  14913.  
  14914.  
  14915.  Privilege Level
  14916.  
  14917.  No special privilege level is required to successfully execute
  14918.  DosWriteMailslot.
  14919.  
  14920.  
  14921.  Syntax
  14922.  
  14923.    #define INCL_NETMAILSLOT
  14924.    #define INCL_NETERRORS
  14925.    #include <lan.h>
  14926.  
  14927.    API_FUNCTION
  14928.    DosWriteMailslot (const char far *  pszName,
  14929.                      const char far *  pbBuffer,
  14930.                      unsigned short    cbBuffer,
  14931.                      unsigned short    usPriority,
  14932.                      unsigned short    usClass,
  14933.                      long              cTimeout
  14934.                     );
  14935.  
  14936.  where
  14937.  
  14938.  pszName
  14939.    Points to an ASCIIZ string that contains the name of the mailslot where
  14940.    the message is to be written.
  14941.  
  14942.  pbBuffer
  14943.    Points to the data to write to the mailslot. If the data to be written is
  14944.    an ASCIIZ string, the NUL terminator must be included in the count of
  14945.    bytes to send.
  14946.  
  14947.  cbBuffer
  14948.    Specifies the number of bytes of data to be written to the mailslot.
  14949.  
  14950.  usPriority
  14951.    Assigns a priority (0 through 9) to the message. High-priority messages
  14952.    are generally placed ahead of previously stored messages that have lower
  14953.    priority.
  14954.  
  14955.  usClass
  14956.    Specifies the class of mail service to be provided. A value of 1 specifies
  14957.    first-class service; 2 specifies second-class service.
  14958.  
  14959.  cTimeout
  14960.    Specifies the number of milliseconds to wait for space to become available
  14961.    in the mailslot for this message. If this value is 0, DosWriteMailslot
  14962.    does not wait; if it is MAILSLOT_NO_TIMEOUT, DosWriteMailslot waits
  14963.    indefinitely.
  14964.  
  14965.  Return Codes
  14966.  
  14967. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  14968.  Code                              Value   Meaning
  14969.  ────────────────────────────────────────────────────────────────────────────
  14970.  NERR_Success                      0       The function encountered no
  14971.                                            errors.
  14972.  
  14973.  ERROR_INVALID_FUNCTION            1       The function is invalid.
  14974.  
  14975.  Code                              Value   Meaning
  14976.  ────────────────────────────────────────────────────────────────────────────
  14977. 
  14978.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  14979.  
  14980.  ERROR_ACCESS_DENIED               5       The user has insufficient
  14981.                                            privilege for this operation.
  14982.  
  14983.  ERROR_BAD_NETPATH                 53      The network path was not found.
  14984.  
  14985.  ERROR_NETWORK_BUSY                54      The network is busy.
  14986.  
  14987.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  14988.                                            invalid.
  14989.  
  14990.  ERROR_INTERUPT                    95      The system call was interrupted.
  14991.  
  14992.  ERROR_BROKEN_PIPE                 109     The pipe has been closed or the
  14993.                                            pipe is not being read.
  14994.  
  14995.  ERROR_SEM_TIMEOUT                 121     A time-out occurred from the
  14996.  Code                              Value   Meaning
  14997.  ────────────────────────────────────────────────────────────────────────────
  14998. ERROR_SEM_TIMEOUT                 121     A time-out occurred from the
  14999.                                            Semaphore API functions.
  15000.  
  15001.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  15002.                                            is not installed.
  15003.  
  15004.  ────────────────────────────────────────────────────────────────────────────
  15005.  
  15006.  
  15007.  
  15008.  
  15009.  Remarks
  15010.  
  15011.  DosWriteMailslot accepts mailslot names in both a local and a remote format,
  15012.  as follows:
  15013.  
  15014.  Format                                  Type
  15015.  ────────────────────────────────────────────────────────────────────────────
  15016.  \mailslot\mailslotname                  Local mailslot.
  15017.  \\computername\mailslot\mailslotname    Remote mailslot.
  15018.  \\domainname\mailslot\mailslotname      Mailslot on another domain.
  15019.  ────────────────────────────────────────────────────────────────────────────
  15020.  
  15021.  To send a message to all computers in the primary domain that have a local
  15022.  mailslot with a particular name, an application should pass the pszName
  15023.  parameter (\\*\mailslot\mailslotname) and the usClass parameter 2 to
  15024.  DosWriteMailslot.
  15025.  
  15026.  Second-class messages have as many as 400 bytes when written to remote
  15027.  workstations or entire domains; they can be any size when written to local
  15028.  computers or remote servers.
  15029.  
  15030.  When DosWriteMailslot is called with the workstation not started and the
  15031.  name of a mailslot on a remote computer supplied, DosWriteMailslot returns
  15032.  the error code ERROR_INVALID_FUNCTION.
  15033.  
  15034.  If the mailslot is deleted while being used by DosWriteMailslot,
  15035.  ERROR_BROKEN_PIPE is returned.
  15036.  
  15037.  If a first-class message is being sent, but it is not read within the period
  15038.  specified by cTimeout, DosWriteMailslot returns ERROR_SEM_TIMEOUT.
  15039.  
  15040.  See Also
  15041.  
  15042.  For information about             See
  15043.  ────────────────────────────────────────────────────────────────────────────
  15044.  Creating a mailslot               DosMakeMailslot
  15045.  
  15046.  Reading a message                 DosReadMailslot
  15047.  
  15048.  
  15049.  
  15050.  
  15051.  
  15052.  Mailslot Category Example
  15053.  
  15054.    /*
  15055.       NETMAIL.C -- a sample program demonstrating Mailslot API functions.
  15056.  
  15057.       This program requires no special privilege.
  15058.         usage:  netmail  [-m mailslot] [-s size] [-t text] [-c class]
  15059.                          [-p priority] [-i iterations]
  15060.         where  mailslot   = Name of mailslot to be used.
  15061.                size       = Maximum message size for mailslot.
  15062.                text       = Text of message sent to mailslot.
  15063.                class      = Class of message sent to mailslot (1 or 2).
  15064.                priority   = Priority of message sent to mailslot (0 to
  15065.    9).
  15066.                iterations = Number of times to send the message.
  15067.  
  15068.       API                  Used to...
  15069.       =================    ==================================================
  15070.       DosMakeMailslot      Make a mailslot on the local computer
  15071.       DosWriteMailslot     Write a message to the created mailslot
  15072.       DosMailslotInfo      Get information about the mailslot and print
  15073.    it
  15074.       DosPeekMailslot      Read the most current message without removing
  15075.    it
  15076.       DosReadMailslot      Read and then remove the most current message
  15077.       DosDeleteMailslot    Delete the created mailslot
  15078.  
  15079.       This code sample is provided for demonstration purposes only.
  15080.       Microsoft makes no warranty, either express or implied,
  15081.       as to its usability in any given situation.
  15082.    */
  15083.  
  15084.    #define     INCL_NETERRORS
  15085.    #define     INCL_NETMAILSLOT
  15086.    #include    <lan.h>             // LAN Manager header files
  15087.  
  15088.    #include    <stdio.h>           // C run-time header files
  15089.    #include    <stdlib.h>
  15090.    #include    <string.h>
  15091.  
  15092.    #include    "samples.h"         // Internal routine header file
  15093.  
  15094.    #define     DEFAULT_MAILSLOT    "\\mailslot\\testname"
  15095.    #define     DEFAULT_MESSAGE     "message sent to mailslot"
  15096.    #define     DEFAULT_MSGSIZE     1024       // Max. message size
  15097.    #define     DEFAULT_CLASS       1          // First class
  15098.    #define     DEFAULT_PRIORITY    0          // Lowest priority
  15099.    #define     DEFAULT_ITERATIONS  1          // Send message once
  15100.    void Usage (char * pszProgram);
  15101.  
  15102.    void main(int argc, char *argv[])
  15103.    {
  15104.       char *         pszMailslot = DEFAULT_MAILSLOT;   // Mailslot to
  15105.    use
  15106.       char *         pszMessage  = DEFAULT_MESSAGE;    // Message to
  15107.    be sent
  15108.       char *         pbBuffer;                // Pointer to data buffer
  15109.       int            iCount;                  // Index counter
  15110.       int            cIterations = DEFAULT_ITERATIONS; // Iteration counter
  15111.       unsigned       hMailslot;               // Handle to mailslot
  15112.       unsigned short cbBuffer;                // Size of data buffer
  15113.  
  15114.       unsigned short cbMessageSize = DEFAULT_MSGSIZE;
  15115.       unsigned short cbMailslotSize, cMessages;
  15116.       unsigned short cbReturned, cbNextSize, usNextPriority;
  15117.       unsigned short usPriority = DEFAULT_PRIORITY;
  15118.       unsigned short usClass = DEFAULT_CLASS;
  15119.       API_RET_TYPE   uReturnCode;             // API return code
  15120.  
  15121.       for (iCount = 1; iCount < argc; iCount++)
  15122.       {
  15123.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  15124.          {
  15125.             switch (tolower(*(argv[iCount]+1))) // Process switches
  15126.             {
  15127.                case 'm':                        // -m mailslot name
  15128.                   pszMailslot = argv[++iCount];
  15129.                   break;
  15130.                case 's':                        // -s max. message size
  15131.                   cbMessageSize = atoi(argv[++iCount]);
  15132.                   break;
  15133.                case 't':                        // -t text
  15134.                   pszMessage = argv[++iCount];
  15135.                   break;
  15136.                case 'p':                        // -p priority
  15137.                   usPriority = atoi(argv[++iCount]);
  15138.                   break;
  15139.                case 'c':                        // -c class
  15140.                   usClass = atoi(argv[++iCount]);
  15141.                   break;
  15142.                case 'i':                        // -i iterations
  15143.                   cIterations = atoi(argv[++iCount]);
  15144.                   break;
  15145.                case 'h':
  15146.                default:
  15147.  
  15148.    Usage(argv[0]);
  15149.             }
  15150.          }
  15151.  
  15152.    else
  15153.             Usage(argv[0]);
  15154.       }
  15155.  
  15156.    //========================================================================
  15157.    // DosMakeMailslot
  15158.    //
  15159.    // This API creates a mailslot on the local computer. The mailslot
  15160.  
  15161.    // size is set to 0, indicating to the API to choose a value based
  15162.  
  15163.    // on the size of the message buffer.
  15164.    //========================================================================
  15165.  
  15166.       uReturnCode = DosMakeMailslot (
  15167.                            pszMailslot,       // Mailslot name
  15168.                            cbMessageSize,     // Max. message size
  15169.                            0,                 // Size of mailslot
  15170.                            &hMailslot);       // Handle to mailslot
  15171.  
  15172.       printf("DosMakeMailslot of \"%s\" returned %u \n",
  15173.                  pszMailslot, uReturnCode);
  15174.  
  15175.       if (uReturnCode != NERR_Success)
  15176.          exit(1);
  15177.  
  15178.    //========================================================================
  15179.    // DosWriteMailslot
  15180.    //
  15181.    // This API writes cIterations messages to the mailslot just created.
  15182.    // If the message being written to the mailslot is an ASCIIZ string,
  15183.    // the specified length must include the NUL terminator.
  15184.    //========================================================================
  15185.  
  15186.       for (iCount = 1; iCount <= cIterations; iCount++)
  15187.       {
  15188.          uReturnCode = DosWriteMailslot(
  15189.                            pszMailslot,       // Mailslot name
  15190.                            pszMessage,        // Message to write to
  15191.    mailslot
  15192.                            strlen(pszMessage)+1,  // Length; allow for
  15193.    NUL
  15194.                            usPriority,            // Message priority
  15195.                            usClass,               // Message class
  15196.                            0L);                   // Immediate time-out
  15197.          printf("DosWriteMailslot #%d returned %u \n",
  15198.                      iCount, uReturnCode);
  15199.       }
  15200.  
  15201.    //========================================================================
  15202.    // DosMailslotInfo
  15203.    //
  15204.    // This API gets information about the mailslot and then prints it.
  15205.    //========================================================================
  15206.  
  15207.       uReturnCode = DosMailslotInfo(
  15208.                            hMailslot,         // Handle to mailslot
  15209.                            &cbMessageSize,    // Max. message size accepted
  15210.                            &cbMailslotSize,   // Size of mailslot
  15211.                            &cbNextSize,       // Size of next message
  15212.                            &usNextPriority,   // Priority of next message
  15213.                            &cMessages);       // Count of messages in
  15214.    mailslot
  15215.  
  15216.       printf("DosMailslotInfo returned %u \n", uReturnCode);
  15217.  
  15218.       if (uReturnCode == NERR_Success)
  15219.       {
  15220.          printf("   Message buffer size : %hu \n", cbMessageSize);
  15221.          printf("   Mailslot size       : %hu \n", cbMailslotSize);
  15222.          printf("   Size of next message: %hu \n", cbNextSize);
  15223.          if (cbNextSize)
  15224.             printf("   Priority of next msg: %hu\n", usNextPriority);
  15225.          printf("   Number of messages  : %hu \n", cMessages);
  15226.       }
  15227.  
  15228.    //========================================================================
  15229.    // DosPeekMailslot
  15230.    //
  15231.    // This API reads the most current message without removing it.
  15232.    //========================================================================
  15233.  
  15234.       /*
  15235.        *  Allocate a data buffer large enough for the next message.
  15236.        *  Use the default buffer size, just in case a message of higher
  15237.        *  priority is received between the DosMailslotInfo call and
  15238.        *  the DosPeekMailslot call.
  15239.        */
  15240.  
  15241.       cbBuffer = cbMessageSize;               // Default buffer size
  15242.       pbBuffer = SafeMalloc(cbBuffer);
  15243.  
  15244.    uReturnCode = DosPeekMailslot(
  15245.                            hMailslot,         // Handle to mailslot
  15246.                            pbBuffer,          // Buffer for returned
  15247.    message
  15248.                            &cbReturned,       // Size of returned message
  15249.                            &cbNextSize,       // Size of next message
  15250.                            &usNextPriority);  // Priority of next message
  15251.  
  15252.       printf("DosPeekMailslot returned %u \n", uReturnCode);
  15253.  
  15254.       if (uReturnCode == NERR_Success)
  15255.       {
  15256.          printf("   Message received    : \"%s\" \n", pbBuffer);
  15257.          printf("   Size of message read: %hu bytes\n", cbReturned);
  15258.          printf("   Size of next message: %hu bytes\n", cbNextSize);
  15259.          if (cbNextSize)
  15260.             printf("   Priority of next msg: %hu\n", usNextPriority);
  15261.       }
  15262.  
  15263.    //========================================================================
  15264.    // DosReadMailslot
  15265.    //
  15266.    // Read and delete the most current message.
  15267.    //========================================================================
  15268.  
  15269.       uReturnCode = DosReadMailslot(
  15270.                            hMailslot,         // Handle to mailslot
  15271.                            pbBuffer,          // Buffer for returned
  15272.    message
  15273.                            &cbReturned,       // Size of returned message
  15274.                            &cbNextSize,       // Size of next message
  15275.                            &usNextPriority,   // Priority of next message
  15276.                            0L);               // Time-out value; don't
  15277.    wait
  15278.  
  15279.       printf("DosReadMailslot returned %u \n", uReturnCode);
  15280.  
  15281.       if (uReturnCode == NERR_Success)
  15282.       {
  15283.          printf("   Message received    : \"%s\" \n", pbBuffer);
  15284.          printf("   Size of message read: %hu bytes\n", cbReturned);
  15285.          printf("   Size of next message: %hu bytes\n", cbNextSize);
  15286.          if (cbNextSize)
  15287.             printf("   Priority of next msg: %hu\n", usNextPriority);
  15288.       }
  15289.       free (pbBuffer);
  15290.  
  15291.    //========================================================================
  15292.    // DosDeleteMailslot
  15293.    //
  15294.    // This API deletes the created mailslot.
  15295.    //========================================================================
  15296.  
  15297.       uReturnCode = DosDeleteMailslot(hMailslot);
  15298.  
  15299.       printf("DosDeleteMailslot of \"%s\" returned %u \n",
  15300.                  pszMailslot, uReturnCode);
  15301.  
  15302.       exit(0);
  15303.    }
  15304.  
  15305.    void Usage (char * pszProgram)
  15306.    {
  15307.       fprintf(stderr, "Usage:  %s [-m mailslot] [-s size] [-t text] "
  15308.          "[-c class]\n\t\t[-p priority] [-i iterations]\n", pszProgram);
  15309.       exit(1);
  15310.    }
  15311.  
  15312.  
  15313.  
  15314.  
  15315.  
  15316.  
  15317.  
  15318.  Message Category
  15319.  
  15320.  Message API functions send and receive messages, and manipulate message
  15321.  aliases.
  15322.  
  15323.  All Message API functions require that the local computer be running the
  15324.  Workstation service. All Message functions except NetMessageBufferSend and
  15325.  NetMessageFileSend require that the computer where the function is to be
  15326.  executed be running the Messenger service. NetMessageBufferSend and
  15327.  NetMessageFileSend require only the Messenger service to be running on the
  15328.  computer that receives the message.
  15329.  
  15330.  The Message category functions, datatypes, structures, and constants are
  15331.  defined in the NETCONS.H, NETERR.H, and MESSAGE.H header files. A source
  15332.  program can access these definitions by defining the constants
  15333.  INCL_NETERRORS and INCL_NETMESSAGE, and including the master header file,
  15334.  LAN.H. For more information, see the "Example" section, later in this
  15335.  category.
  15336.  
  15337.  These are the Message API functions:
  15338.  
  15339.  
  15340.    ■   NetMessageBufferSend
  15341.  
  15342.    ■   NetMessageFileSend
  15343.  
  15344.    ■   NetMessageLogFileGet
  15345.  
  15346.    ■   NetMessageLogFileSet
  15347.  
  15348.    ■   NetMessageNameAdd
  15349.  
  15350.    ■   NetMessageNameDel
  15351.  
  15352.    ■   NetMessageNameEnum
  15353.  
  15354.    ■   NetMessageNameFwd
  15355.  
  15356.    ■   NetMessageNameGetInfo
  15357.  
  15358.    ■   NetMessageNameUnFwd
  15359.  
  15360.  
  15361.  
  15362.  Description
  15363.  
  15364.  A message is any file or buffer of data sent to a user or application on the
  15365.  network. To receive a message, a user or application must register a message
  15366.  alias in a computer's table of message names. This can be done by using
  15367.  NetMessageNameAdd.
  15368.  
  15369.  A message name table contains a list of registered message aliases (users
  15370.  and applications) permitted to receive messages and a list of aliases to
  15371.  which a message can be forwarded.
  15372.  
  15373.  The aliases registered in the message name table are case sensitive. An
  15374.  alias added using the LAN Manager command-line or full-screen interface is
  15375.  added in uppercase. If an alias is added using NetMessageNameAdd, the case
  15376.  is unaltered. To send a message, the alias specified must match exactly the
  15377.  alias that is registered.
  15378.  
  15379.  NetMessageNameDel deletes a specific message alias from the message name
  15380.  table. NetMessageNameEnum lists all the aliases stored in the message name
  15381.  table. NetMessageNameGetInfo retrieves information about a particular
  15382.  message alias in the message name table.
  15383.  
  15384.  To send a message, an application can call either NetMessageFileSend or
  15385.  NetMessageBufferSend. NetMessageFileSend sends a file; NetMessageBufferSend
  15386.  sends a buffer of information.
  15387.  
  15388.  Applications can also send broadcast messages to all users in a domain or to
  15389.  all computers on a network by using NetMessageFileSend or
  15390.  NetMessageBufferSend.
  15391.  
  15392.  All messages sent to an alias on a particular computer can be forwarded to
  15393.  another alias on a different computer by using NetMessageNameFwd. Forwarded
  15394.  messages can be received only by the forwarded alias. They are not received
  15395.  by the alias that forwards them. NetMessageNameUnFwd ends message forwarding
  15396.  for a specified alias.
  15397.  
  15398.  Users can receive messages in one of two ways (or both at the same time):
  15399.  
  15400.  
  15401.    ■   The message is logged in a message log.
  15402.  
  15403.    ■   The message is displayed in a popup. To receive a popup message, the
  15404.        Netpopup service must be installed.
  15405.  
  15406.  
  15407.  NetMessageLogFileSet enables or disables message logging and specifies the
  15408.  name of the message log file. If message logging is enabled, all messages
  15409.  received are logged. The log file is in ASCII format.
  15410.  
  15411.  NetMessageLogFileGet returns the name of the message log file for a
  15412.  workstation or server and specifies whether or not message logging is
  15413.  enabled. The default message log file is LANMAN\LOGS\MESSAGES.LOG. The
  15414.  LANMAN directory is set during installation; the default is C:\LANMAN.
  15415.  
  15416.  The message log file contains messages in the following format:
  15417.  
  15418.  
  15419.    ■   A header specifying who sent the message, who received the message,
  15420.        and the time and date the message was received
  15421.  
  15422.    ■   A blank line
  15423.  
  15424.    ■   The contents of the message
  15425.  
  15426.    ■   A blank line
  15427.  
  15428.    ■   A line containing four asterisks (****)
  15429.  
  15430.    ■   A blank line
  15431.  
  15432.  
  15433.  The following example shows the contents of a message log file containing
  15434.  two messages:
  15435.  
  15436.    Message from JOHN to BRUCE on October 01, 1990, 14:05:20
  15437.  
  15438.    Hello, this is a BUFFER test message.
  15439.  
  15440.    ****
  15441.  
  15442.    Message from BRUCE to JOHN on October 01, 1990, 14:11:48
  15443.  
  15444.    Hello, this is a FILE test message.
  15445.  
  15446.    ****
  15447.  
  15448.  ────────────────────────────────────────────────────────────────────────────
  15449.  NOTE
  15450.  A process must open the message log in read-only/deny-none mode; otherwise,
  15451.  the Messenger service fails when trying to log incoming messages.
  15452.  ────────────────────────────────────────────────────────────────────────────
  15453.  
  15454.  
  15455.  MS-DOS Considerations
  15456.  
  15457.  By default, LAN Manager for MS-DOS accepts only two names, the name of the
  15458.  workstation and the name of the user in the message name table. To define
  15459.  more names, change the value of the nummsgnames entry in the [messenger]
  15460.  section of the LANMAN.INI file.
  15461.  
  15462.  MS OS/2 LAN Manager accepts up to 14 aliases in the message name table,
  15463.  although this may be limited to a smaller value by the network hardware
  15464.  being used.
  15465.  
  15466.  
  15467.  Data Structures
  15468.  
  15469.  NetMessageNameEnum and NetMessageNameGetInfo use the msg_info_X data
  15470.  structure, where X is 0 or 1, depending on the level of detail requested.
  15471.  
  15472.  
  15473.  Message Information (level 0)
  15474.  
  15475.  The msg_info_0 data structure has this format:
  15476.  
  15477.    struct msg_info_0 {
  15478.        char  msgi0_name[CNLEN+1];
  15479.    };
  15480.  
  15481.  where
  15482.  
  15483.  msgi0_name
  15484.    Contains an ASCIIZ string that specifies the alias to which the message is
  15485.    to be sent. The constant CNLEN is defined in the NETCONS.H header file.
  15486.  
  15487.  
  15488.  Message Information (level 1)
  15489.  
  15490.  The msg_info_1 data structure has this format:
  15491.  
  15492.    struct msg_info_1 {
  15493.        char           msgi1_name[CNLEN+1];
  15494.        unsigned char  msgi1_forward_flag;
  15495.        unsigned char  msgi1_pad1;
  15496.        char           msgi1_forward[CNLEN+1];
  15497.    };
  15498.  
  15499.  where
  15500.  
  15501.  msgi1_name
  15502.    Contains an ASCIIZ string that specifies the alias to which the message is
  15503.    to be sent. The constant CNLEN is defined in the NETCONS.H header file.
  15504.  
  15505.  msgi1_forward_flag
  15506.    Specifies whether to send messages to a message alias on the local
  15507.    computer or to forward them to a message alias on a remote computer. The
  15508.    MESSAGE.H header file defines these possible values:
  15509.  
  15510.  Code                    Value  Meaning
  15511.  ────────────────────────────────────────────────────────────────────────────
  15512.  MSGNAME_NOT_FORWARDED   0x00   Name is not forwarded.
  15513.  MSGNAME_FORWARDED_TO    0x04   Name is forwarded to a remote computer.
  15514.  MSGNAME_FORWARDED_FROM  0x10   Name is forwarded from a remote computer.
  15515.  ────────────────────────────────────────────────────────────────────────────
  15516.  
  15517.  msgi1_pad1
  15518.    Aligns the next data structure element on a word boundary.
  15519.  
  15520.  msgi1_forward
  15521.    Contains an ASCIIZ string that specifies the alias to which the message
  15522.    will be sent if forwarding is enabled. The constant CNLEN is defined in
  15523.    the NETCONS.H header file.
  15524.  
  15525.  See Also
  15526.  
  15527.  For information about             See
  15528.  ────────────────────────────────────────────────────────────────────────────
  15529.  LANMAN.INI file                   LAN Manager administrator's manual(s)
  15530.  
  15531.  Starting services, the Messenger  Appendix C, "Creating LAN Manager
  15532.  service                           Services"
  15533.  
  15534.  
  15535.  NetMessageBufferSend
  15536.  ────────────────────────────────────────────────────────────────────────────
  15537.  
  15538.  NetMessageBufferSend sends a buffer of information to a registered message
  15539.  alias.
  15540.  
  15541.  
  15542.  Operating Systems Supported
  15543.  
  15544.  
  15545.    ■   MS OS/2 version 1.2, local and remote
  15546.  
  15547.    ■   MS OS/2 version 1.1, local and remote
  15548.  
  15549.    ■   MS-DOS, local and remote
  15550.  
  15551.  
  15552.  
  15553.  Privilege Level
  15554.  
  15555.  Admin privilege or accounts, comm, print, or server operator privilege is
  15556.  required to successfully execute NetMessageBufferSend on a remote server.
  15557.  
  15558.  
  15559.  Syntax
  15560.  
  15561.    #define INCL_NETMESSAGE
  15562.    #define INCL_NETERRORS
  15563.    #include <lan.h>
  15564.  
  15565.    API_FUNCTION
  15566.    NetMessageBufferSend (const char far *  pszServer,
  15567.                          char far *        pszRecipient,
  15568.                          char far *        pbBuffer,
  15569.                          unsigned short    cbBuffer
  15570.                         );
  15571.  
  15572.  where
  15573.  
  15574.  pszServer
  15575.    Points to an ASCIIZ string that contains the name of the server on which
  15576.    to execute NetMessageBufferSend. A null pointer or null string specifies
  15577.    the local computer.
  15578.  
  15579.  pszRecipient
  15580.    Points to an ASCIIZ string that contains the registered message alias to
  15581.    receive the message buffer. To broadcast a message to all workstations on
  15582.    the network, pszRecipient should point to an asterisk (*). To broadcast to
  15583.    all members of a domain, pszRecipient should point to the domain name,
  15584.    which should be terminated with an asterisk.
  15585.  
  15586.  pbBuffer
  15587.    Points to the message buffer to be sent.
  15588.  
  15589.  cbBuffer
  15590.    Specifies the size (in bytes) of the message contained in the buffer
  15591.    pointed to by pbBuffer.
  15592.  
  15593.  Return Codes
  15594.  
  15595. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  15596.  Code                              Value   Meaning
  15597.  ────────────────────────────────────────────────────────────────────────────
  15598.  NERR_Success                      0       The function encountered no
  15599.                                            errors.
  15600.  
  15601.  ERROR_ACCESS_DENIED               5       The user has insufficient
  15602.                                            privilege for this operation.
  15603.  
  15604.  ERROR_REM_NOT_LIST                51      The remote computer is not
  15605.  Code                              Value   Meaning
  15606.  ────────────────────────────────────────────────────────────────────────────
  15607. ERROR_REM_NOT_LIST                51      The remote computer is not
  15608.                                            listening.
  15609.  
  15610.  ERROR_BAD_NETPATH                 53      The network path was not found.
  15611.  
  15612.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  15613.  
  15614.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  15615.                                            is not installed.
  15616.  
  15617.  NERR_NoNetworkResource            2105    The network hardware could not
  15618.                                            access the resources it needed.
  15619.  
  15620.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  15621.  
  15622.  NERR_WkstaNotStarted              2138    The Workstation service is not
  15623.                                            started.
  15624.  
  15625.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  15626.  Code                              Value   Meaning
  15627.  ────────────────────────────────────────────────────────────────────────────
  15628. NERR_BrowserNotStarted            2139    The mailslots entry of the
  15629.                                            workstation's LANMAN.INI file is
  15630.                                            incorrect.
  15631.  
  15632.  NERR_BadTransactConfig            2141    The server is not configured for
  15633.                                            this transaction: IPC$ is not
  15634.                                            shared.
  15635.  
  15636.  NERR_NoComputerName               2270    A computername has not been
  15637.                                            configured.
  15638.  
  15639.  NERR_NameNotFound                 2273    The message alias cannot be
  15640.                                            located.
  15641.  
  15642.  NERR_PausedRemote                 2281    The message was sent, but the
  15643.                                            recipient has paused the
  15644.                                            Messenger service, so the
  15645.                                            message cannot be received.
  15646.  
  15647.  Code                              Value   Meaning
  15648.  ────────────────────────────────────────────────────────────────────────────
  15649. 
  15650.  NERR_BadReceive                   2282    The remote workstation was
  15651.                                            unable to receive the message.
  15652.                                            The Workstation or Messenger
  15653.                                            service may not be running on
  15654.                                            that workstation, it may have
  15655.                                            been receiving another message
  15656.                                            when this message arrived, or
  15657.                                            its message buffer may be too
  15658.                                            small.
  15659.  
  15660.  NERR_NotLocalName                 2285    The message alias is not on the
  15661.                                            local computer.
  15662.  
  15663.  NERR_TruncatedBroadcast           2289    The broadcast message is too
  15664.                                            long. Only the first 128
  15665.                                            characters of the message were
  15666.                                            sent.
  15667.  
  15668.  Code                              Value   Meaning
  15669.  ────────────────────────────────────────────────────────────────────────────
  15670. 
  15671.  NERR_InvalidComputer              2351    The specified computername is
  15672.                                            invalid.
  15673.  
  15674.  ────────────────────────────────────────────────────────────────────────────
  15675.  
  15676.  
  15677.  
  15678.  
  15679.  Remarks
  15680.  
  15681.  Broadcast messages (pszRecipient points to * or domainname*) can have as
  15682.  many as 128 bytes; delivery is not guaranteed. Other messages can have as
  15683.  many as 62K, provided they do not exceed the maximum receivable message size
  15684.  for the computer that receives them. The maximum receivable size is set by
  15685.  the sizmessbuf entry in the [messenger] section of the LANMAN.INI file. The
  15686.  sizmessbuf entry cannot define a value larger than 62K. (The default value
  15687.  is 4K on a computer with MS OS/2, and 256 bytes on an MS-DOS workstation.)
  15688.  
  15689.  The total size of sizmessbuf can be divided among different messages if
  15690.  messages arrive at the same time, reducing the actual size of any one
  15691.  message that can be received. For more information about the LANMAN.INI
  15692.  file, see your LAN Manager administrator's manual(s).
  15693.  
  15694.  NetMessageBufferSend requires that the Messenger service be started on the
  15695.  computer where the message is to be received, but it need not be started on
  15696.  the computer that sends the message.
  15697.  
  15698.  See Also
  15699.  
  15700.  For information about             See
  15701.  ────────────────────────────────────────────────────────────────────────────
  15702.  Adding a message alias            NetMessageNameAdd
  15703.  
  15704.  Messenger service                 Appendix C, "Creating LAN Manager
  15705.                                    Services"
  15706.  
  15707.  Sending a message file            NetMessageFileSend
  15708.  
  15709.  Setting the LANMAN.INI            LAN Manager administrator's manual(s)
  15710.  sizmessbuf entry for a server
  15711.  
  15712.  
  15713.  NetMessageFileSend
  15714.  ────────────────────────────────────────────────────────────────────────────
  15715.  
  15716.  NetMessageFileSend sends a file to a registered message alias.
  15717.  
  15718.  It is recommended that you not use NetMessageFileSend because it is unlikely
  15719.  to be supported in future releases of LAN Manager. NetMessageBufferSend can
  15720.  be used as an alternative.
  15721.  
  15722.  
  15723.  Operating Systems Supported
  15724.  
  15725.  
  15726.    ■   MS OS/2 version 1.2, local and remote
  15727.  
  15728.    ■   MS OS/2 version 1.1, local and remote
  15729.  
  15730.    ■   MS-DOS, local and remote
  15731.  
  15732.  
  15733.  
  15734.  Privilege Level
  15735.  
  15736.  Admin privilege or accounts, comm, print, or server operator privilege is
  15737.  required to successfully execute NetMessageFileSend on a remote server.
  15738.  
  15739.  
  15740.  Syntax
  15741.  
  15742.    #define INCL_NETMESSAGE
  15743.    #define INCL_NETERRORS
  15744.    #include <lan.h>
  15745.  
  15746.    API_FUNCTION
  15747.    NetMessageFileSend (const char far *  pszServer,
  15748.                        char far *        pszRecipient,
  15749.                        char far *        pszFileSpec
  15750.                       );
  15751.  
  15752.  where
  15753.  
  15754.  pszServer
  15755.    Points to an ASCIIZ string that contains the name of the server on which
  15756.    to execute NetMessageFileSend. A null pointer or null string specifies the
  15757.    local computer.
  15758.  
  15759.  pszRecipient
  15760.    Points to an ASCIIZ string that contains the registered message alias to
  15761.    receive the message file. To broadcast a message to all workstations on
  15762.    the network, pszRecipient should point to an asterisk (*). To broadcast to
  15763.    all members of a domain, this parameter should point to the domain name,
  15764.    which should be terminated with an asterisk.
  15765.  
  15766.  pszFileSpec
  15767.    Points to an ASCIIZ string that contains the pathname of the file to send.
  15768.    This pathname must be specified relative to the computer specified by
  15769.    pszServer.
  15770.  
  15771.  Return Codes
  15772.  
  15773. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  15774.  Code                              Value   Meaning
  15775.  ────────────────────────────────────────────────────────────────────────────
  15776.  NERR_Success                      0       The function encountered no
  15777.                                            errors.
  15778.  
  15779.  ERROR_FILE_NOT_FOUND              2       The file was not found.
  15780.  
  15781.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  15782.  
  15783.  ERROR_ACCESS_DENIED               5       The user has insufficient
  15784.                                            privilege for this operation.
  15785.  
  15786.  ERROR_REM_NOT_LIST                51      The remote computer is not
  15787.                                            listening.
  15788.  
  15789.  ERROR_BAD_NETPATH                 53      The network path was not found.
  15790.  
  15791.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  15792.  
  15793.  ERROR_OPEN_FAILED                 110     An open or write operation
  15794.  Code                              Value   Meaning
  15795.  ────────────────────────────────────────────────────────────────────────────
  15796. ERROR_OPEN_FAILED                 110     An open or write operation
  15797.                                            failed.
  15798.  
  15799.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  15800.                                            is not installed.
  15801.  
  15802.  NERR_NoNetworkResource            2105    The network hardware could not
  15803.                                            access the resources it needed.
  15804.  
  15805.  NERR_WkstaNotStarted              2138    The Workstation service is not
  15806.                                            started.
  15807.  
  15808.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  15809.                                            workstation's LANMAN.INI file is
  15810.                                            incorrect.
  15811.  
  15812.  NERR_BadTransactConfig            2141    The server is not configured for
  15813.                                            this transaction: IPC$ is not
  15814.                                            shared.
  15815.  Code                              Value   Meaning
  15816.  ────────────────────────────────────────────────────────────────────────────
  15817.                                           shared.
  15818.  
  15819.  NERR_NoComputerName               2270    A computername has not been
  15820.                                            configured.
  15821.  
  15822.  NERR_NameNotFound                 2273    The message alias cannot be
  15823.                                            located.
  15824.  
  15825.  NERR_PausedRemote                 2281    The message was sent, but the
  15826.                                            recipient has paused the
  15827.                                            Messenger service, so the
  15828.                                            message cannot be received.
  15829.  
  15830.  NERR_BadReceive                   2282    The remote workstation was
  15831.                                            unable to receive the message.
  15832.                                            The Workstation or Messenger
  15833.                                            service may not be running on
  15834.                                            that workstation, it may have
  15835.                                            been receiving another message
  15836.  Code                              Value   Meaning
  15837.  ────────────────────────────────────────────────────────────────────────────
  15838.                                           been receiving another message
  15839.                                            when this message arrived, or
  15840.                                            its message buffer may be too
  15841.                                            small.
  15842.  
  15843.  NERR_NotLocalName                 2285    The message alias is not on the
  15844.                                            local computer.
  15845.  
  15846.  NERR_TruncatedBroadcast           2289    The broadcast message is too
  15847.                                            long. Only the first 128
  15848.                                            characters of the message were
  15849.                                            sent.
  15850.  
  15851.  NERR_InvalidComputer              2351    The specified computername is
  15852.                                            invalid.
  15853.  
  15854.  ────────────────────────────────────────────────────────────────────────────
  15855.  
  15856.  
  15857.  
  15858.  
  15859.  Remarks
  15860.  
  15861.  Broadcast messages (pszRecipient points to * or domainname*) can have as
  15862.  many as 128 bytes; delivery is not guaranteed. Other messages can have as
  15863.  many as 62K, provided they do not exceed the maximum receivable message size
  15864.  for the computer that receives them. The maximum receivable size is set with
  15865.  the sizmessbuf entry in the [messenger] section of the LANMAN.INI file. The
  15866.  sizmessbuf entry cannot define a value larger than 62K. (The default value
  15867.  is 4K on a computer with MS OS/2, and 256 bytes on an MS-DOS workstation.)
  15868.  
  15869.  The total size of sizmessbuf can be divided among different messages if
  15870.  messages arrive at the same time, reducing the actual size of any one
  15871.  message that can be received. For more information about the LANMAN.INI
  15872.  file, see your Microsoft LAN Manager administrator's manual(s).
  15873.  
  15874.  NetMessageFileSend requires that the Messenger service be started on the
  15875.  computer where the message is to be received, but it need not be started on
  15876.  the computer that sends the message.
  15877.  
  15878.  See Also
  15879.  
  15880.  For information about             See
  15881.  ────────────────────────────────────────────────────────────────────────────
  15882.  Adding a message alias            NetMessageNameAdd
  15883.  
  15884.  Messenger service                 Appendix C, "Creating LAN Manager
  15885.                                    Services"
  15886.  
  15887.  Sending a buffer of information   NetMessageBufferSend
  15888.  
  15889.  Setting the LANMAN.INI            LAN Manager administrator's manual(s)
  15890.  sizmessbuf entry for a server
  15891.  
  15892.  
  15893.  NetMessageLogFileGet
  15894.  ────────────────────────────────────────────────────────────────────────────
  15895.  
  15896.  NetMessageLogFileGet retrieves the name of the message log and the current
  15897.  logging status (on or off). NetMessageLogFileGet requires that the Messenger
  15898.  service be started.
  15899.  
  15900.  It is recommended that you not use NetMessageLogFileGet because it is
  15901.  unlikely to be supported in future releases of LAN Manager.
  15902.  
  15903.  
  15904.  Operating Systems Supported
  15905.  
  15906.  
  15907.    ■   MS OS/2 version 1.2, local and remote
  15908.  
  15909.    ■   MS OS/2 version 1.1, local and remote
  15910.  
  15911.    ■   MS-DOS, local and remote
  15912.  
  15913.  
  15914.  
  15915.  Privilege Level
  15916.  
  15917.  Admin privilege is required to successfully execute NetMessageLogFileGet on
  15918.  a remote server.
  15919.  
  15920.  
  15921.  Syntax
  15922.  
  15923.    #define INCL_NETMESSAGE
  15924.    #define INCL_NETERRORS
  15925.    #include <lan.h>
  15926.  
  15927.    API_FUNCTION
  15928.    NetMessageLogFileGet (const char far *  pszServer,
  15929.                          char far *        pbBuffer,
  15930.                          unsigned short    cbBuffer,
  15931.                          short far *       pfsEnabled
  15932.                         );
  15933.  
  15934.  where
  15935.  
  15936.  pszServer
  15937.    Points to an ASCIIZ string that contains the name of the server on which
  15938.    to execute NetMessageLogFileGet. A null pointer or null string specifies
  15939.    the local computer.
  15940.  
  15941.  pbBuffer
  15942.    Points to the buffer in which to store the returned data. On a successful
  15943.    return, the buffer contains the pathname of the message log file.
  15944.  
  15945.  cbBuffer
  15946.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  15947.  
  15948.  pfsEnabled
  15949.    Points to a short integer in which the status of message logging is
  15950.    returned. If pfsEnabled is 1, message logging is enabled. If it is 0,
  15951.    message logging is not enabled.
  15952.  
  15953.  Return Codes
  15954.  
  15955. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  15956.  Code                              Value   Meaning
  15957.  ────────────────────────────────────────────────────────────────────────────
  15958.  NERR_Success                      0       The function encountered no
  15959.                                            errors.
  15960.  
  15961.  ERROR_ACCESS_DENIED               5       The user has insufficient
  15962.  Code                              Value   Meaning
  15963.  ────────────────────────────────────────────────────────────────────────────
  15964. ERROR_ACCESS_DENIED               5       The user has insufficient
  15965.                                            privilege for this operation.
  15966.  
  15967.  ERROR_BAD_NETPATH                 53      The network path was not found.
  15968.  
  15969.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  15970.  
  15971.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  15972.                                            is not installed.
  15973.  
  15974.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  15975.  
  15976.  NERR_WkstaNotStarted              2138    The Workstation service is not
  15977.                                            started.
  15978.  
  15979.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  15980.                                            workstation's LANMAN.INI file is
  15981.                                            incorrect.
  15982.  
  15983.  Code                              Value   Meaning
  15984.  ────────────────────────────────────────────────────────────────────────────
  15985. 
  15986.  NERR_BadTransactConfig            2141    The server is not configured for
  15987.                                            this transaction: IPC$ is not
  15988.                                            shared.
  15989.  
  15990.  NERR_MsgNotStarted                2284    The Messenger service has not
  15991.                                            been started.
  15992.  
  15993.  NERR_InvalidComputer              2351    The specified computername is
  15994.                                            invalid.
  15995.  
  15996.  ────────────────────────────────────────────────────────────────────────────
  15997.  
  15998.  
  15999.  
  16000.  See Also
  16001.  
  16002.  For information about             See
  16003.  ────────────────────────────────────────────────────────────────────────────
  16004.  Messenger service                 Appendix C, "Creating LAN Manager
  16005.                                    Services"
  16006.  
  16007.  Modifying the name and status of  NetMessageLogFileSet
  16008.  the message log
  16009.  
  16010.  
  16011.  NetMessageLogFileSet
  16012.  ────────────────────────────────────────────────────────────────────────────
  16013.  
  16014.  NetMessageLogFileSet specifies the name of a file in which to log messages
  16015.  received by registered message aliases, and enables or disables logging.
  16016.  NetMessageLogFileSet requires that the Messenger service be started.
  16017.  
  16018.  It is recommended that you not use NetMessageLogFileSet because it is
  16019.  unlikely to be supported in future releases of LAN Manager.
  16020.  
  16021.  
  16022.  Operating Systems Supported
  16023.  
  16024.  
  16025.    ■   MS OS/2 version 1.2, local and remote
  16026.  
  16027.    ■   MS OS/2 version 1.1, local and remote
  16028.  
  16029.    ■   MS-DOS, local and remote
  16030.  
  16031.  
  16032.  
  16033.  Privilege Level
  16034.  
  16035.  Admin privilege is required to successfully execute NetMessageLogFileSet on
  16036.  a remote server.
  16037.  
  16038.  
  16039.  Syntax
  16040.  
  16041.    #define INCL_NETMESSAGE
  16042.    #define INCL_NETERRORS
  16043.    #include <lan.h>
  16044.  
  16045.    API_FUNCTION
  16046.    NetMessageLogFileSet (const char far *  pszServer,
  16047.                          char far *        pszFileSpec,
  16048.                          short             pfsEnabled
  16049.                         );
  16050.  
  16051.  where
  16052.  
  16053.  pszServer
  16054.    Points to an ASCIIZ string that contains the name of the server on which
  16055.    to execute NetMessageLogFileSet. A null pointer or null string specifies
  16056.    the local computer.
  16057.  
  16058.  pszFileSpec
  16059.    Points to an ASCIIZ string that contains the pathname of the file or
  16060.    device (LPT: or COM:) where the messages are logged.
  16061.  
  16062.    If pszFileSpec is passed as a null pointer, the name of the current
  16063.    message log file does not change. If pszFileSpec points to a null string,
  16064.    no message file is used; in this case, pfsEnabled must be 0.
  16065.  
  16066.    If pszFileSpec points to a relative path, the path must be relative to the
  16067.    LAN Manager LOGS directory. All other pathnames must be fully qualified.
  16068.    If a filename extension is not provided, the file extension .LOG is
  16069.    appended.
  16070.  
  16071.  pfsEnabled
  16072.    Points to a short integer that specifies whether logging is enabled. If
  16073.    pfsEnabled is 0, message logging is disabled. If it is 1, message logging
  16074.    is enabled.
  16075.  
  16076.  Return Codes
  16077.  
  16078. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  16079.  Code                              Value   Meaning
  16080.  ────────────────────────────────────────────────────────────────────────────
  16081.  NERR_Success                      0       The function encountered no
  16082.                                            errors.
  16083.  
  16084.  ERROR_ACCESS_DENIED               5       The user has insufficient
  16085.                                            privilege for this operation.
  16086.  
  16087.  ERROR_BAD_NETPATH                 53      The network path was not found.
  16088.  Code                              Value   Meaning
  16089.  ────────────────────────────────────────────────────────────────────────────
  16090. ERROR_BAD_NETPATH                 53      The network path was not found.
  16091.  
  16092.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  16093.  
  16094.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  16095.                                            invalid.
  16096.  
  16097.  ERROR_INVALID_NAME                123     The character or file system
  16098.                                            name is invalid.
  16099.  
  16100.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  16101.                                            is not installed.
  16102.  
  16103.  NERR_RedirectedPath               2117    The operation is invalid for a
  16104.                                            redirected resource. The
  16105.                                            devicename specified is assigned
  16106.                                            to a shared resource.
  16107.  
  16108.  NERR_WkstaNotStarted              2138    The Workstation service is not
  16109.  Code                              Value   Meaning
  16110.  ────────────────────────────────────────────────────────────────────────────
  16111. NERR_WkstaNotStarted              2138    The Workstation service is not
  16112.                                            started.
  16113.  
  16114.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  16115.                                            workstation's LANMAN.INI file is
  16116.                                            incorrect.
  16117.  
  16118.  NERR_BadTransactConfig            2141    The server is not configured for
  16119.                                            this transaction: IPC$ is not
  16120.                                            shared.
  16121.  
  16122.  NERR_MsgNotStarted                2284    The Messenger service has not
  16123.                                            been started.
  16124.  
  16125.  NERR_InvalidDevice                2294    The devicename is invalid.
  16126.  
  16127.  NERR_InvalidComputer              2351    The specified computername is
  16128.                                            invalid.
  16129.  
  16130.  Code                              Value   Meaning
  16131.  ────────────────────────────────────────────────────────────────────────────
  16132. 
  16133.  ────────────────────────────────────────────────────────────────────────────
  16134.  
  16135.  
  16136.  
  16137.  See Also
  16138.  
  16139.  For information about             See
  16140.  ────────────────────────────────────────────────────────────────────────────
  16141.  Messenger service                 Appendix C, "Creating LAN Manager
  16142.                                    Services"
  16143.  
  16144.  Retrieving the name and status    NetMessageLogFileGet
  16145.  of the message log
  16146.  
  16147.  
  16148.  NetMessageNameAdd
  16149.  ────────────────────────────────────────────────────────────────────────────
  16150.  
  16151.  NetMessageNameAdd registers a message alias in the message name table.
  16152.  NetMessageNameAdd requires that the Messenger service be started.
  16153.  
  16154.  It is recommended that you not use NetMessageNameAdd because it is unlikely
  16155.  to be supported in future releases of LAN Manager.
  16156.  
  16157.  
  16158.  Operating Systems Supported
  16159.  
  16160.  
  16161.    ■   MS OS/2 version 1.2, local and remote
  16162.  
  16163.    ■   MS OS/2 version 1.1, local and remote
  16164.  
  16165.    ■   MS-DOS, local and remote
  16166.  
  16167.  
  16168.  
  16169.  Privilege Level
  16170.  
  16171.  Admin privilege is required to successfully execute NetMessageNameAdd on a
  16172.  remote server.
  16173.  
  16174.  
  16175.  Syntax
  16176.  
  16177.    #define INCL_NETMESSAGE
  16178.    #define INCL_NETERRORS
  16179.    #include <lan.h>
  16180.  
  16181.    API_FUNCTION
  16182.    NetMessageNameAdd (const char far *  pszServer,
  16183.                       const char far *  pszMessageName,
  16184.                       short             fsFwdAction
  16185.                      );
  16186.  
  16187.  where
  16188.  
  16189.  pszServer
  16190.    Points to an ASCIIZ string that contains the name of the server on which
  16191.    to execute NetMessageNameAdd. A null pointer or null string specifies the
  16192.    local computer.
  16193.  
  16194.  pszMessageName
  16195.    Points to an ASCIIZ string that contains a message alias to add to the
  16196.    message name table. The message alias can have as many as CNLEN+1 bytes,
  16197.    including the terminating NUL character. The constant CNLEN is defined in
  16198.    the NETCONS.H header file.
  16199.  
  16200.  fsFwdAction
  16201.    Specifies the action to take if the message alias pointed to by
  16202.    pszMessageName is already forwarded. If fsFwdAction is 0, an error is
  16203.    returned. If it is any other value, the name is added to the message name
  16204.    table.
  16205.  
  16206.  Return Codes
  16207.  
  16208. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  16209.  Code                              Value   Meaning
  16210.  ────────────────────────────────────────────────────────────────────────────
  16211.  NERR_Success                      0       The function encountered no
  16212.                                            errors.
  16213.  
  16214.  Code                              Value   Meaning
  16215.  ────────────────────────────────────────────────────────────────────────────
  16216. 
  16217.  ERROR_ACCESS_DENIED               5       The user has insufficient
  16218.                                            privilege for this operation.
  16219.  
  16220.  ERROR_REM_NOT_LIST                51      The remote computer is not
  16221.                                            listening.
  16222.  
  16223.  ERROR_BAD_NETPATH                 53      The network path was not found.
  16224.  
  16225.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  16226.  
  16227.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  16228.                                            is not installed.
  16229.  
  16230.  NERR_NoNetworkResource            2105    The network hardware could not
  16231.                                            access the resources it needed.
  16232.  
  16233.  NERR_WkstaNotStarted              2138    The Workstation service is not
  16234.                                            started.
  16235.  Code                              Value   Meaning
  16236.  ────────────────────────────────────────────────────────────────────────────
  16237.                                           started.
  16238.  
  16239.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  16240.                                            workstation's LANMAN.INI file is
  16241.                                            incorrect.
  16242.  
  16243.  NERR_BadTransactConfig            2141    The server is not configured for
  16244.                                            this transaction: IPC$ is not
  16245.                                            shared.
  16246.  
  16247.  NERR_AlreadyForwarded             2274    Messages for this alias are
  16248.                                            already being forwarded to
  16249.                                            another alias.
  16250.  
  16251.  NERR_AddForwarded                 2275    Messages for this alias are
  16252.                                            being forwarded to another
  16253.                                            computer.
  16254.  
  16255.  NERR_AlreadyExists                2276    The message alias already exists
  16256.  Code                              Value   Meaning
  16257.  ────────────────────────────────────────────────────────────────────────────
  16258. NERR_AlreadyExists                2276    The message alias already exists
  16259.                                            on this computer.
  16260.  
  16261.  NERR_TooManyNames                 2277    The maximum number of message
  16262.                                            aliases has been exceeded.
  16263.  
  16264.  NERR_MsgNotStarted                2284    The Messenger service has not
  16265.                                            been started.
  16266.  
  16267.  NERR_DuplicateName                2297    The name specified is already in
  16268.                                            use as a message alias on the
  16269.                                            network.
  16270.  
  16271.  NERR_InvalidComputer              2351    The specified computername is
  16272.                                            invalid.
  16273.  
  16274.  ────────────────────────────────────────────────────────────────────────────
  16275.  
  16276.  
  16277.  
  16278.  See Also
  16279.  
  16280.  For information about             See
  16281.  ────────────────────────────────────────────────────────────────────────────
  16282.  Deleting a message alias          NetMessageNameDel
  16283.  
  16284.  Forwarding messages               NetMessageNameFwd
  16285.  
  16286.  Messenger service                 Appendix C, "Creating LAN Manager
  16287.                                    Services"
  16288.  
  16289.  
  16290.  NetMessageNameDel
  16291.  ────────────────────────────────────────────────────────────────────────────
  16292.  
  16293.  NetMessageNameDel deletes a message alias from the table of message aliases
  16294.  on a computer. NetMessageNameDel requires that the Messenger service be
  16295.  started.
  16296.  
  16297.  It is recommended that you not use NetMessageNameDel because it is unlikely
  16298.  to be supported in future releases of LAN Manager.
  16299.  
  16300.  
  16301.  Operating Systems Supported
  16302.  
  16303.  
  16304.    ■   MS OS/2 version 1.2, local and remote
  16305.  
  16306.    ■   MS OS/2 version 1.1, local and remote
  16307.  
  16308.    ■   MS-DOS, local and remote
  16309.  
  16310.  
  16311.  
  16312.  Privilege Level
  16313.  
  16314.  Admin privilege is required to successfully execute NetMessageNameDel on a
  16315.  remote server.
  16316.  
  16317.  
  16318.  Syntax
  16319.  
  16320.    #define INCL_NETMESSAGE
  16321.    #define INCL_NETERRORS
  16322.    #include <lan.h>
  16323.  
  16324.    API_FUNCTION
  16325.    NetMessageNameDel (const char far *  pszServer,
  16326.                       const char far *  pszMessageName,
  16327.                       short             fsFwdAction
  16328.                      );
  16329.  
  16330.  where
  16331.  
  16332.  pszServer
  16333.    Points to an ASCIIZ string that contains the name of the server on which
  16334.    to execute NetMessageNameDel. A null pointer or null string specifies the
  16335.    local computer.
  16336.  
  16337.  pszMessageName
  16338.    Points to an ASCIIZ string that contains the message alias to be removed.
  16339.  
  16340.  fsFwdAction
  16341.    Specifies what action to take if the messages for the message alias
  16342.    pointed to by pszMessageName are being forwarded to another message alias.
  16343.    If fsFwdAction is 0, an error is returned. If it is any other value, the
  16344.    message alias is deleted from the message name table.
  16345.  
  16346.  Return Codes
  16347.  
  16348. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  16349.  Code                              Value   Meaning
  16350.  ────────────────────────────────────────────────────────────────────────────
  16351.  NERR_Success                      0       The function encountered no
  16352.                                            errors.
  16353.  
  16354.  ERROR_ACCESS_DENIED               5       The user has insufficient
  16355.                                            privilege for this operation.
  16356.  
  16357.  ERROR_REM_NOT_LIST                51      The remote computer is not
  16358.                                            listening.
  16359.  
  16360.  ERROR_BAD_NETPATH                 53      The network path was not found.
  16361.  Code                              Value   Meaning
  16362.  ────────────────────────────────────────────────────────────────────────────
  16363. ERROR_BAD_NETPATH                 53      The network path was not found.
  16364.  
  16365.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  16366.  
  16367.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  16368.                                            is not installed.
  16369.  
  16370.  NERR_WkstaNotStarted              2138    The Workstation service is not
  16371.                                            started.
  16372.  
  16373.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  16374.                                            workstation's LANMAN.INI file is
  16375.                                            incorrect.
  16376.  
  16377.  NERR_BadTransactConfig            2141    The server is not configured for
  16378.                                            this transaction: IPC$ is not
  16379.                                            shared.
  16380.  
  16381.  NERR_NameNotFound                 2273    The message alias cannot be
  16382.  Code                              Value   Meaning
  16383.  ────────────────────────────────────────────────────────────────────────────
  16384. NERR_NameNotFound                 2273    The message alias cannot be
  16385.                                            located.
  16386.  
  16387.  NERR_DelComputerName              2278    A message alias that is also a
  16388.                                            computername cannot be deleted.
  16389.  
  16390.  NERR_NameInUse                    2283    The message alias is currently
  16391.                                            in use. Try again later.
  16392.  
  16393.  NERR_MsgNotStarted                2284    The Messenger service has not
  16394.                                            been started.
  16395.  
  16396.  NERR_NotLocalName                 2285    The message alias is not on the
  16397.                                            local computer.
  16398.  
  16399.  NERR_DeleteLater                  2298    The message alias will be
  16400.                                            deleted later.
  16401.  
  16402.  NERR_IncompleteDel                2299    The message alias was not
  16403.  Code                              Value   Meaning
  16404.  ────────────────────────────────────────────────────────────────────────────
  16405. NERR_IncompleteDel                2299    The message alias was not
  16406.                                            successfully deleted from all
  16407.                                            networks.
  16408.  
  16409.  NERR_InvalidComputer              2351    The specified computername is
  16410.                                            invalid.
  16411.  
  16412.  ────────────────────────────────────────────────────────────────────────────
  16413.  
  16414.  
  16415.  
  16416.  See Also
  16417.  
  16418.  For information about             See
  16419.  ────────────────────────────────────────────────────────────────────────────
  16420.  Adding a message alias            NetMessageNameAdd
  16421.  
  16422.  Listing all message aliases       NetMessageNameEnum
  16423.  
  16424.  Messenger service                 Appendix C, "Creating LAN Manager
  16425.                                    Services"
  16426.  
  16427.  
  16428.  NetMessageNameEnum
  16429.  ────────────────────────────────────────────────────────────────────────────
  16430.  
  16431.  NetMessageNameEnum lists the message aliases that will receive messages on a
  16432.  specified computer. NetMessageNameEnum requires that the Messenger service
  16433.  be started.
  16434.  
  16435.  It is recommended that you not use NetMessageNameEnum because it is unlikely
  16436.  to be supported in future releases of LAN Manager.
  16437.  
  16438.  
  16439.  Operating Systems Supported
  16440.  
  16441.  
  16442.    ■   MS OS/2 version 1.2, local and remote
  16443.  
  16444.    ■   MS OS/2 version 1.1, local and remote
  16445.  
  16446.    ■   MS-DOS, local and remote
  16447.  
  16448.  
  16449.  
  16450.  Privilege Level
  16451.  
  16452.  Admin privilege is required to successfully execute NetMessageNameEnum on a
  16453.  remote server.
  16454.  
  16455.  
  16456.  Syntax
  16457.  
  16458.    #define INCL_NETMESSAGE
  16459.    #define INCL_NETERRORS
  16460.    #include <lan.h>
  16461.  
  16462.    API_FUNCTION
  16463.    NetMessageNameEnum (const char far *      pszServer,
  16464.                        short                 sLevel,
  16465.                        char far *            pbBuffer,
  16466.                        unsigned short        cbBuffer,
  16467.                        unsigned short far *  pcEntriesRead,
  16468.                        unsigned short far *  pcTotalAvail
  16469.                       );
  16470.  
  16471.  where
  16472.  
  16473.  pszServer
  16474.    Points to an ASCIIZ string that contains the name of the server on which
  16475.    to execute NetMessageNameEnum. A null pointer or null string specifies the
  16476.    local computer.
  16477.  
  16478.  sLevel
  16479.    Specifies the level of detail (0 or 1) requested.
  16480.  
  16481.  pbBuffer
  16482.    Points to the buffer in which to store the returned data. On a successful
  16483.    return, the buffer contains a sequence of msg_info_X data structures,
  16484.    where X is 0 or 1, depending on the level of detail requested.
  16485.  
  16486.  cbBuffer
  16487.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  16488.  
  16489.  pcEntriesRead
  16490.    Points to an unsigned short integer in which a count of the message
  16491.    aliases enumerated in the buffer is returned. This count is valid only if
  16492.    NetMessageNameEnum returns NERR_Success or ERROR_MORE_DATA.
  16493.  
  16494.  pcTotalAvail
  16495.    Points to an unsigned short integer in which a count of the total number
  16496.    of message aliases is returned. This count is valid only if
  16497.    NetMessageNameEnum returns NERR_Success or ERROR_MORE_DATA.
  16498.  
  16499.  Return Codes
  16500.  
  16501. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  16502.  Code                              Value   Meaning
  16503.  ────────────────────────────────────────────────────────────────────────────
  16504.  NERR_Success                      0       The function encountered no
  16505.                                            errors.
  16506.  
  16507.  ERROR_ACCESS_DENIED               5       The user has insufficient
  16508.  Code                              Value   Meaning
  16509.  ────────────────────────────────────────────────────────────────────────────
  16510. ERROR_ACCESS_DENIED               5       The user has insufficient
  16511.                                            privilege for this operation.
  16512.  
  16513.  ERROR_BAD_NETPATH                 53      The network path was not found.
  16514.  
  16515.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  16516.  
  16517.  ERROR_INVALID_LEVEL               124     The level for information
  16518.                                            retrieval or setting is invalid.
  16519.  
  16520.  ERROR_MORE_DATA                   234     Additional data is available.
  16521.  
  16522.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  16523.                                            is not installed.
  16524.  
  16525.  NERR_WkstaNotStarted              2138    The Workstation service is not
  16526.                                            started.
  16527.  
  16528.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  16529.  Code                              Value   Meaning
  16530.  ────────────────────────────────────────────────────────────────────────────
  16531. NERR_BrowserNotStarted            2139    The mailslots entry of the
  16532.                                            workstation's LANMAN.INI file is
  16533.                                            incorrect.
  16534.  
  16535.  NERR_BadTransactConfig            2141    The server is not configured for
  16536.                                            this transaction: IPC$ is not
  16537.                                            shared.
  16538.  
  16539.  NERR_MsgNotStarted                2284    The Messenger service has not
  16540.                                            been started.
  16541.  
  16542.  NERR_InvalidComputer              2351    The specified computername is
  16543.                                            invalid.
  16544.  
  16545.  ────────────────────────────────────────────────────────────────────────────
  16546.  
  16547.  
  16548.  
  16549.  See Also
  16550.  
  16551.  For information about             See
  16552.  ────────────────────────────────────────────────────────────────────────────
  16553.  Adding a message alias            NetMessageNameAdd
  16554.  
  16555.  Deleting a message alias          NetMessageNameDel
  16556.  
  16557.  Messenger service                 Appendix C, "Creating LAN Manager
  16558.                                    Services"
  16559.  
  16560.  Retrieving information about a    NetMessageNameGetInfo
  16561.  particular message alias
  16562.  
  16563.  
  16564.  NetMessageNameFwd
  16565.  ────────────────────────────────────────────────────────────────────────────
  16566.  
  16567.  NetMessageNameFwd modifies the message name table to forward messages
  16568.  addressed to one alias on to another alias. The original recipient of the
  16569.  message does not receive the message. NetMessageNameFwd requires that the
  16570.  Messenger service be started.
  16571.  
  16572.  It is recommended that you not use NetMessageNameFwd because it is unlikely
  16573.  to be supported in future releases of LAN Manager.
  16574.  
  16575.  
  16576.  Operating Systems Supported
  16577.  
  16578.  
  16579.    ■   MS OS/2 version 1.2, local and remote
  16580.  
  16581.    ■   MS OS/2 version 1.1, local and remote
  16582.  
  16583.    ■   MS-DOS, remote only
  16584.  
  16585.  
  16586.  
  16587.  Privilege Level
  16588.  
  16589.  Admin privilege is required to successfully execute NetMessageNameFwd on a
  16590.  remote server.
  16591.  
  16592.  
  16593.  Syntax
  16594.  
  16595.    #define INCL_NETMESSAGE
  16596.    #define INCL_NETERRORS
  16597.    #include <lan.h>
  16598.  
  16599.    API_FUNCTION
  16600.    NetMessageNameFwd (const char far *  pszServer,
  16601.                       const char far *  pszMessageName,
  16602.                       const char far *  pszForwardName,
  16603.                       short             fsDelFwdName
  16604.                      );
  16605.  
  16606.  where
  16607.  
  16608.  pszServer
  16609.    Points to an ASCIIZ string that contains the name of the server on which
  16610.    to execute NetMessageNameFwd. A null pointer or null string specifies the
  16611.    local computer.
  16612.  
  16613.  pszMessageName
  16614.    Points to an ASCIIZ string that contains the alias to which the messages
  16615.    are originally sent.
  16616.  
  16617.  pszForwardName
  16618.    Points to an ASCIIZ string that contains the alias to which messages are
  16619.    forwarded. The message aliases can have as many as CNLEN+1 bytes,
  16620.    including the terminating  NUL character. The constant CNLEN is defined in
  16621.    the NETCONS.H header file.
  16622.  
  16623.  fsDelFwdName
  16624.    Specifies the action to take if the alias pointed to by pszMessageName
  16625.    already forwards messages to another alias. If fsDelFwdName is 0, an error
  16626.    is returned. If it is any other value, any previous forwarded alias is
  16627.    deleted.
  16628.  
  16629.  Return Codes
  16630.  
  16631. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  16632.  Code                              Value   Meaning
  16633.  ────────────────────────────────────────────────────────────────────────────
  16634.  Code                              Value   Meaning
  16635.  ────────────────────────────────────────────────────────────────────────────
  16636.  NERR_Success                      0       The function encountered no
  16637.                                            errors.
  16638.  
  16639.  ERROR_ACCESS_DENIED               5       The user has insufficient
  16640.                                            privilege for this operation.
  16641.  
  16642.  ERROR_REM_NOT_LIST                51      The remote computer is not
  16643.                                            listening.
  16644.  
  16645.  ERROR_BAD_NETPATH                 53      The network path was not found.
  16646.  
  16647.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  16648.  
  16649.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  16650.                                            is not installed.
  16651.  
  16652.  NERR_NoNetworkResource            2105    The network hardware could not
  16653.                                            access the resources it needed.
  16654.  
  16655.  Code                              Value   Meaning
  16656.  ────────────────────────────────────────────────────────────────────────────
  16657. 
  16658.  NERR_RemoteOnly                   2106    This operation can be performed
  16659.                                            only on a server.
  16660.  
  16661.  NERR_WkstaNotStarted              2138    The Workstation service is not
  16662.                                            started.
  16663.  
  16664.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  16665.                                            workstation's LANMAN.INI file is
  16666.                                            incorrect.
  16667.  
  16668.  NERR_BadTransactConfig            2141    The server is not configured for
  16669.                                            this transaction: IPC$ is not
  16670.                                            shared.
  16671.  
  16672.  NERR_NameNotFound                 2273    The message alias cannot be
  16673.                                            located.
  16674.  
  16675.  NERR_AlreadyForwarded             2274    Messages for this alias are
  16676.  Code                              Value   Meaning
  16677.  ────────────────────────────────────────────────────────────────────────────
  16678. NERR_AlreadyForwarded             2274    Messages for this alias are
  16679.                                            already being forwarded to
  16680.                                            another alias.
  16681.  
  16682.  NERR_AlreadyExists                2276    The message alias already exists
  16683.                                            on this computer.
  16684.  
  16685.  NERR_TooManyNames                 2277    The maximum number of message
  16686.                                            aliases has been exceeded.
  16687.  
  16688.  NERR_LocalForward                 2279    Messages cannot be forwarded
  16689.                                            back to the same workstation.
  16690.  
  16691.  NERR_NameInUse                    2283    The message alias is currently
  16692.                                            in use. Try again later.
  16693.  
  16694.  NERR_MsgNotStarted                2284    The Messenger service has not
  16695.                                            been started.
  16696.  
  16697.  Code                              Value   Meaning
  16698.  ────────────────────────────────────────────────────────────────────────────
  16699. 
  16700.  NERR_NotLocalName                 2285    The message alias is not on the
  16701.                                            local computer.
  16702.  
  16703.  NERR_RemoteFull                   2287    The message alias table on the
  16704.                                            remote workstation is full.
  16705.  
  16706.  NERR_DuplicateName                2297    The name specified is already in
  16707.                                            use as a message alias on the
  16708.                                            network.
  16709.  
  16710.  NERR_DeleteLater                  2298    The message alias will be
  16711.                                            deleted later.
  16712.  
  16713.  NERR_MultipleNets                 2300    This operation is not supported
  16714.                                            on a computer that is on
  16715.                                            multiple networks.
  16716.  
  16717.  NERR_InvalidComputer              2351    The specified computername is
  16718.  Code                              Value   Meaning
  16719.  ────────────────────────────────────────────────────────────────────────────
  16720. NERR_InvalidComputer              2351    The specified computername is
  16721.                                            invalid.
  16722.  
  16723.  ────────────────────────────────────────────────────────────────────────────
  16724.  
  16725.  
  16726.  
  16727.  See Also
  16728.  
  16729.  For information about             See
  16730.  ────────────────────────────────────────────────────────────────────────────
  16731.  Listing all message aliases       NetMessageNameEnum
  16732.  
  16733.  Messenger service                 Appendix C, "Creating LAN Manager
  16734.                                    Services"
  16735.  
  16736.  Setting the LANMAN.INI            LAN Manager administrator's manual(s)
  16737.  sizmessbuf entry for a server
  16738.  
  16739.  Stopping the forwarding of        NetMessageNameUnFwd
  16740.  messages
  16741.  
  16742.  
  16743.  NetMessageNameGetInfo
  16744.  ────────────────────────────────────────────────────────────────────────────
  16745.  
  16746.  NetMessageNameGetInfo retrieves information about a particular message alias
  16747.  in the message name table. NetMessageNameGetInfo requires that the Messenger
  16748.  service be started.
  16749.  
  16750.  It is recommended that you not use NetMessageNameGetInfo because it is
  16751.  unlikely to be supported in future releases of LAN Manager.
  16752.  
  16753.  
  16754.  Operating Systems Supported
  16755.  
  16756.  
  16757.    ■   MS OS/2 version 1.2, local and remote
  16758.  
  16759.    ■   MS OS/2 version 1.1, local and remote
  16760.  
  16761.    ■   MS-DOS, local and remote
  16762.  
  16763.  
  16764.  
  16765.  Privilege Level
  16766.  
  16767.  Admin privilege is required to successfully execute NetMessageNameGetInfo on
  16768.  a remote server.
  16769.  
  16770.  
  16771.  Syntax
  16772.  
  16773.    #define INCL_NETMESSAGE
  16774.    #define INCL_NETERRORS
  16775.    #include <lan.h>
  16776.  
  16777.    API_FUNCTION
  16778.    NetMessageNameGetInfo (const char far *      pszServer,
  16779.                           const char far *      pszMessageName,
  16780.                           short                 sLevel,
  16781.                           char far *            pbBuffer,
  16782.                           unsigned short        cbBuffer,
  16783.                           unsigned short far *  pcbTotalAvail
  16784.                          );
  16785.  
  16786.  where
  16787.  
  16788.  pszServer
  16789.    Points to an ASCIIZ string that contains the name of the server on which
  16790.    to execute NetMessageNameGetInfo. A null pointer or null string specifies
  16791.    the local computer.
  16792.  
  16793.  pszMessageName
  16794.    Points to an ASCIIZ string that contains the message alias of interest.
  16795.  
  16796.  sLevel
  16797.    Specifies the level of detail (0 or 1) requested.
  16798.  
  16799.  pbBuffer
  16800.    Points to the buffer in which to store the returned data. On a successful
  16801.    return, the buffer contains a msg_info_X data structure, where X is 0 or
  16802.    1, depending on the level of detail requested.
  16803.  
  16804.  cbBuffer
  16805.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  16806.  
  16807.  pcbTotalAvail
  16808.    Points to an unsigned short integer in which a count of the total number
  16809.    of bytes of information available is returned. This count is valid only if
  16810.    NetMessageNameGetInfo returns NERR_Success or NERR_BufTooSmall.
  16811.  
  16812.  Return Codes
  16813.  
  16814. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  16815.  Code                              Value   Meaning
  16816.  ────────────────────────────────────────────────────────────────────────────
  16817.  NERR_Success                      0       The function encountered no
  16818.                                            errors.
  16819.  
  16820.  ERROR_ACCESS_DENIED               5       The user has insufficient
  16821.                                            privilege for this operation.
  16822.  
  16823.  Code                              Value   Meaning
  16824.  ────────────────────────────────────────────────────────────────────────────
  16825. 
  16826.  ERROR_BAD_NETPATH                 53      The network path was not found.
  16827.  
  16828.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  16829.  
  16830.  ERROR_INVALID_LEVEL               124     The level for information
  16831.                                            retrieval or setting is invalid.
  16832.  
  16833.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  16834.                                            is not installed.
  16835.  
  16836.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  16837.  
  16838.  NERR_WkstaNotStarted              2138    The Workstation service is not
  16839.                                            started.
  16840.  
  16841.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  16842.                                            workstation's LANMAN.INI file is
  16843.                                            incorrect.
  16844.  Code                              Value   Meaning
  16845.  ────────────────────────────────────────────────────────────────────────────
  16846.                                           incorrect.
  16847.  
  16848.  NERR_BadTransactConfig            2141    The server is not configured for
  16849.                                            this transaction: IPC$ is not
  16850.                                            shared.
  16851.  
  16852.  NERR_MsgNotStarted                2284    The Messenger service has not
  16853.                                            been started.
  16854.  
  16855.  NERR_NotLocalName                 2285    The message alias is not on the
  16856.                                            local computer.
  16857.  
  16858.  NERR_InvalidComputer              2351    The specified computername is
  16859.                                            invalid.
  16860.  
  16861.  ────────────────────────────────────────────────────────────────────────────
  16862.  
  16863.  
  16864.  
  16865.  See Also
  16866.  
  16867.  For information about             See
  16868.  ────────────────────────────────────────────────────────────────────────────
  16869.  Listing all message aliases       NetMessageNameEnum
  16870.  
  16871.  Messenger Service                 Appendix C, "Creating LAN Manager
  16872.                                    Services"
  16873.  
  16874.  
  16875.  NetMessageNameUnFwd
  16876.  ────────────────────────────────────────────────────────────────────────────
  16877.  
  16878.  NetMessageNameUnFwd stops the forwarding of messages from one message alias
  16879.  to another. NetMessageNameUnFwd requires that the Messenger service be
  16880.  started.
  16881.  
  16882.  It is recommended that you not use NetMessageNameUnFwd because it is
  16883.  unlikely to be supported in future releases of LAN Manager.
  16884.  
  16885.  
  16886.  Operating Systems Supported
  16887.  
  16888.  
  16889.    ■   MS OS/2 version 1.2, local and remote
  16890.  
  16891.    ■   MS OS/2 version 1.1, local and remote
  16892.  
  16893.    ■   MS-DOS, remote only
  16894.  
  16895.  
  16896.  
  16897.  Privilege Level
  16898.  
  16899.  Admin privilege is required to successfully execute NetMessageNameUnFwd on a
  16900.  remote server.
  16901.  
  16902.  
  16903.  Syntax
  16904.  
  16905.    #define INCL_NETMESSAGE
  16906.    #define INCL_NETERRORS
  16907.    #include <lan.h>
  16908.  
  16909.    API_FUNCTION
  16910.    NetMessageNameUnFwd (const char far *  pszServer,
  16911.                         const char far *  pszMessageName
  16912.                        );
  16913.  
  16914.  where
  16915.  
  16916.  pszServer
  16917.    Points to an ASCIIZ string that contains the name of a server on which to
  16918.    execute NetMessageNameUnFwd. A null pointer or null string specifies the
  16919.    local computer.
  16920.  
  16921.  pszMessageName
  16922.    Points to an ASCIIZ string that contains the alias whose message
  16923.    forwarding is to be canceled.
  16924.  
  16925.  Return Codes
  16926.  
  16927. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  16928.  Code                              Value   Meaning
  16929.  ────────────────────────────────────────────────────────────────────────────
  16930.  NERR_Success                      0       The function encountered no
  16931.                                            errors.
  16932.  
  16933.  ERROR_ACCESS_DENIED               5       The user has insufficient
  16934.                                            privilege for this operation.
  16935.  
  16936.  ERROR_REM_NOT_LIST                51      The remote computer is not
  16937.                                            listening.
  16938.  
  16939.  ERROR_BAD_NETPATH                 53      The network path was not found.
  16940.  
  16941.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  16942.  
  16943.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  16944.                                            is not installed.
  16945.  
  16946.  NERR_RemoteOnly                   2106    This operation can be performed
  16947.                                            only on a server.
  16948.  
  16949.  Code                              Value   Meaning
  16950.  ────────────────────────────────────────────────────────────────────────────
  16951. 
  16952.  NERR_WkstaNotStarted              2138    The Workstation service is not
  16953.                                            started.
  16954.  
  16955.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  16956.                                            workstation's LANMAN.INI file is
  16957.                                            incorrect.
  16958.  
  16959.  NERR_BadTransactConfig            2141    The server is not configured for
  16960.                                            this transaction: IPC$ is not
  16961.                                            shared.
  16962.  
  16963.  NERR_NameNotFound                 2273    The message alias cannot be
  16964.                                            located.
  16965.  
  16966.  NERR_NameInUse                    2283    The message alias is currently
  16967.                                            in use. Try again later.
  16968.  
  16969.  NERR_MsgNotStarted                2284    The Messenger service has not
  16970.  Code                              Value   Meaning
  16971.  ────────────────────────────────────────────────────────────────────────────
  16972. NERR_MsgNotStarted                2284    The Messenger service has not
  16973.                                            been started.
  16974.  
  16975.  NERR_NotLocalName                 2285    The message alias is not on the
  16976.                                            local computer.
  16977.  
  16978.  NERR_NameNotForwarded             2288    Messages for this alias are not
  16979.                                            being forwarded.
  16980.  
  16981.  NERR_InvalidComputer              2351    The specified computername is
  16982.                                            invalid.
  16983.  
  16984.  ────────────────────────────────────────────────────────────────────────────
  16985.  
  16986.  
  16987.  
  16988.  See Also
  16989.  
  16990.  For information about             See
  16991.  ────────────────────────────────────────────────────────────────────────────
  16992.  Forwarding messages to another    NetMessageNameFwd
  16993.  alias
  16994.  
  16995.  Messenger service                 Appendix C, "Creating LAN Manager
  16996.                                    Services"
  16997.  
  16998.  
  16999.  
  17000.  
  17001.  
  17002.  Message Category Example
  17003.  
  17004.    /*
  17005.        NETMSG.C -- a sample program demonstrating NetMessageBufferSend.
  17006.  
  17007.        This program requires that the Messenger service be running on
  17008.        the specified server, and that you have admin privileges or
  17009.        accounts, server, print, or comm operator privilege on that server.
  17010.  
  17011.        usage:  netmsg [-s \\server] [-r recipient] [-m message]
  17012.  
  17013.        where  \\server  = Name of the server. A servername must be
  17014.                           preceded by two backslashes (\\).
  17015.               recipient = Name of the message recipient.
  17016.               message   = Message to be sent.
  17017.  
  17018.        Note: When supplying a username as the name of the recipient,
  17019.    the name
  17020.        is case-sensitive. If the name has been added from the command
  17021.    line
  17022.        or from the full-screen interface, it will be uppercase. If the
  17023.        name has been added using NetMessageNameAdd, the case will be
  17024.  
  17025.        unaltered.
  17026.  
  17027.        API                      Used to...
  17028.        ====================     ==========================================
  17029.        NetMessageBufferSend     Send a buffer (message) of information
  17030.    to
  17031.                                 a registered message alias
  17032.  
  17033.       This code sample is provided for demonstration purposes only.
  17034.       Microsoft makes no warranty, either express or implied,
  17035.       as to its usability in any given situation.
  17036.    */
  17037.  
  17038.    #define   INCL_NETERRORS
  17039.    #define   INCL_NETMESSAGE
  17040.    #define   INCL_NETWKSTA
  17041.    #include  <lan.h>          // LAN Manager header files
  17042.  
  17043.    #include  <stdio.h>        // C run-time header files
  17044.    #include  <stdlib.h>
  17045.    #include  <string.h>
  17046.  
  17047.    #include  "samples.h"      // Internal routine header file
  17048.  
  17049.    #define DEFAULT_MESSAGE    "Hi there!"
  17050.    #define TRUE               1
  17051.    #define FALSE              0
  17052.  
  17053.    void Usage (char * pszProgram);
  17054.    void main(int argc, char * argv[])
  17055.    {
  17056.       char * pszServer = NULL;                // NULL means local machine
  17057.       char * pszRecipient;                    // Message recipient
  17058.       char * pszMessage = DEFAULT_MESSAGE;    // Message to send
  17059.       char * pbBuffer;                        // Data buffer
  17060.       char   achDomain[DNLEN + 1];            // Domain, allow for *
  17061.    at end
  17062.       int    iCount;                          // Index counter
  17063.       short  fRecipient = FALSE;              // Flag if recipient specified
  17064.       unsigned short cbAvail;                 // Count of bytes available
  17065.       struct wksta_info_10 * pWksta10;        // Pointer to workstation
  17066.    info
  17067.       API_RET_TYPE uReturnCode;               // API return code
  17068.  
  17069.       for (iCount = 1; iCount < argc; iCount++)
  17070.       {
  17071.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  17072.          {
  17073.             switch (tolower(*(argv[iCount]+1)))   // Process switches
  17074.             {
  17075.                case 's':                          // -s servername
  17076.                   pszServer = argv[++iCount];
  17077.                   break;
  17078.                case 'r':                          // -r recipient
  17079.                   pszRecipient = argv[++iCount];
  17080.                   fRecipient = TRUE;
  17081.                   break;
  17082.                case 'm':                          // -m message
  17083.                   pszMessage = argv[++iCount];
  17084.                   break;
  17085.                case 'h':
  17086.                default:
  17087.                   Usage(argv[0]);
  17088.             }
  17089.          }
  17090.          else
  17091.             Usage(argv[0]);
  17092.       }
  17093.  
  17094.  
  17095.    //  NetMessageBufferSend
  17096.    //
  17097.    //  This API sends a message to another user/computer. If no message
  17098.  
  17099.    //  recipient is specified, this example calls NetWkstaGetInfo to
  17100.    determine
  17101.    //  the primary domain for the workstation, then sends a broadcast
  17102.    message
  17103.    //  to all computers in that domain. First, NetWkstaGetInfo is called
  17104.  
  17105.    //  with a NULL buffer to determine the amount of data available,
  17106.    then
  17107.    //  NetWkstaGetInfo is called again with the returned buffer size.
  17108.  
  17109.       if (fRecipient == FALSE)
  17110.       {
  17111.          uReturnCode = NetWkstaGetInfo(
  17112.                            pszServer,         // Servername
  17113.                            10,                // Level of detail
  17114.                            NULL,              // Data buffer
  17115.                            0,                 // Size of buffer
  17116.                            &cbAvail);         // Count of bytes available
  17117.  
  17118.          if (uReturnCode != NERR_BufTooSmall)
  17119.          {
  17120.            printf("NetWkstaGetInfo for \"%s\" failed with %u\n",
  17121.                    pszServer, uReturnCode);
  17122.            exit(1);
  17123.          }
  17124.  
  17125.          // Allocate a data buffer large enough for workstation information.
  17126.          pbBuffer = SafeMalloc(cbAvail);
  17127.  
  17128.          uReturnCode = NetWkstaGetInfo(
  17129.                            pszServer,         // Servername
  17130.                            10,                // Level of detail
  17131.                            pbBuffer,          // Data buffer
  17132.                            cbAvail,           // Size of buffer
  17133.                            &cbAvail);         // Count of bytes available
  17134.  
  17135.          if (uReturnCode != NERR_Success)
  17136.          {
  17137.            printf("NetWkstaGetInfo for \"%s\" failed with %u\n",
  17138.                    pszServer, uReturnCode);
  17139.            exit(1);
  17140.          }
  17141.  
  17142.  
  17143.  
  17144.    // Add * to domain name so that the message is broadcast.
  17145.  
  17146.          pWksta10 = (struct wksta_info_10 *) pbBuffer;
  17147.          FarStrcpy((char far *)achDomain, pWksta10->wki10_logon_domain);
  17148.          strcat(achDomain, "*");
  17149.          pszRecipient = achDomain;
  17150.       }
  17151.  
  17152.       uReturnCode = NetMessageBufferSend(
  17153.                            pszServer,            // Servername
  17154.                            pszRecipient,         // Message recipient
  17155.                            pszMessage,           // Message to send
  17156.                            strlen(pszMessage));  // Length of message
  17157.  
  17158.       printf("NetMessageBufferSend returned %u\n", uReturnCode);
  17159.       printf("   Sending message to \"%s\"\n", pszRecipient);
  17160.       exit(0);
  17161.    }
  17162.  
  17163.    void Usage (char * pszProgram)
  17164.    {
  17165.       fprintf(stderr, "Usage: %s [-s \\\\server] [-r recipient]"
  17166.                       " [-m message]\n", pszProgram);
  17167.       exit(1);
  17168.    }
  17169.  
  17170.  
  17171.  
  17172.  
  17173.  
  17174.  
  17175.  
  17176.  Print Destination Category
  17177.  
  17178.  Print Destination API functions control printers that receive spooled print
  17179.  jobs. When executed locally, Print Destination functions do not require that
  17180.  the NETWKSTA device driver be installed. When a servername is supplied, they
  17181.  require that the Workstation service be started.
  17182.  
  17183.  The Print Destination category functions, datatypes, structures, and
  17184.  constants are defined in the PMSPL.H header file. A source program can
  17185.  access error codes by defining the constant INCL_NETERRORS and including the
  17186.  LAN.H header file. For an example, see the "Example" section, later in this
  17187.  category.
  17188.  
  17189.  These are the Print Destination API functions:
  17190.  
  17191.  
  17192.    ■   DosPrintDestAdd
  17193.  
  17194.    ■   DosPrintDestControl
  17195.  
  17196.    ■   DosPrintDestDel
  17197.  
  17198.    ■   DosPrintDestEnum
  17199.  
  17200.    ■   DosPrintDestGetInfo
  17201.  
  17202.    ■   DosPrintDestSetInfo
  17203.  
  17204.  
  17205.  
  17206.  Description
  17207.  
  17208.  A print destination is a print device that can be associated with a printer
  17209.  queue. Print jobs submitted to a printer queue are directed to the print
  17210.  destination for the queue. A print destination can be physically connected
  17211.  to the computer, or it can be a redirected device that is physically
  17212.  connected to another computer. The Print Destination API functions allow
  17213.  operations on these printers and on the job they are currently printing.
  17214.  
  17215.  DosPrintDestAdd establishes a print destination on the specified computer.
  17216.  DosPrintDestDel deletes a print destination from the specified computer.
  17217.  
  17218.  DosPrintDestControl pauses or continues the print destination. If a job is
  17219.  currently printing, this function also affects that job.
  17220.  
  17221.  DosPrintDestEnum lists all print destinations on a computer.
  17222.  DosPrintDestGetInfo provides information about a particular print
  17223.  destination. DosPrintDestSetInfo can change the parameter values for a print
  17224.  destination.
  17225.  
  17226.  The Print Destination data structures and the Print Destination API
  17227.  functions use MS OS/2 conventions for names and type definitions. The
  17228.  OS2DEF.H header file defines these types:
  17229.  
  17230. ╓┌─────────────────────────────────┌─────────────────────────────────────────╖
  17231.  MS OS/2 Type Definition           C-Language Type
  17232.  ────────────────────────────────────────────────────────────────────────────
  17233.  CHAR                              char
  17234.  PBYTE                             unsigned char far *
  17235.  PSZ                               unsigned char far *
  17236.  PUSHORT                           unsigned short *
  17237.  SPLENTRY                          pascal far
  17238.  SPLERR                            unsigned
  17239.  USHORT                            unsigned short
  17240.  ────────────────────────────────────────────────────────────────────────────
  17241.  
  17242.  
  17243.  
  17244.  Data Structures
  17245.  
  17246.  Level 0 and level 1 data structures are provided for compatibility with
  17247.  existing LAN Manager 1.0 applications. LAN Manager 2.0 applications should
  17248.  use level 2 and level 3 data structures.
  17249.  
  17250.  One of the important enhancements of LAN Manager 2.0 is the ability to treat
  17251.  a print destination as a virtual device, independent of a printer queue or a
  17252.  specific logical address.
  17253.  
  17254.  To illustrate this change, consider the definition of print destination
  17255.  names. The LAN Manager 1.0-compatible names must be names of logical
  17256.  addresses, such as LPT1, LPT2, or COM1. The new level 2 and level 3 data
  17257.  structures allow the use of more general names for print destinations.
  17258.  
  17259.  The API functions also demonstrate this enhancement. DosPrintDestGetInfo and
  17260.  DosPrintDestEnum return level 0 and level 1 data only if print destinations
  17261.  are associated with a printer queue. At level 2 and level 3, these functions
  17262.  return data for all print destinations.
  17263.  
  17264.  Existing LAN Manager 1.0 applications (that use the level 0 and level 1
  17265.  Print Destination data structures) can be compiled and linked using the 1.0
  17266.  header file NETSPOOL.H and the 1.0-compatible libraries NETSPOOL.LIB and
  17267.  NETSPOOL.DLL.
  17268.  
  17269.  Applications designed to run with both MS OS/2 1.1 and MS OS/2 1.2 should
  17270.  use the new level 0 and level 1 data structure names, include the PMSPL.H
  17271.  header file, and link with the NETSPOOL libraries.
  17272.  
  17273.  Applications designed to run only with MS OS/2 1.2 should use the PMSPL.LIB
  17274.  and PMSPL.DLL libraries. The PMSPL libraries provide faster performance than
  17275.  the corresponding functions in the NETSPOOL library.
  17276.  
  17277.  Applications that run only with MS OS/2 1.2 can be built from existing
  17278.  applications by changing the data structure and element names. The
  17279.  prdest_info data structure and element names can be changed to the
  17280.  corresponding PRDINFO data structure and element names. There is a
  17281.  one-to-one mapping from the prdest_info elements to the PRDINFO elements, as
  17282.  shown in the following table:
  17283.  
  17284. ╓┌───────────────────────────────────┌───────────────────────────────────────╖
  17285.  LAN Manager 1.0                     LAN Manager 2.0
  17286.  prdest_info Element                 PRDINFO Element
  17287.  ────────────────────────────────────────────────────────────────────────────
  17288.  prdest_name                         szName
  17289.  
  17290.  prdest_username                     szUserName
  17291.  
  17292.  prdest_jobid                        uJobId
  17293.  
  17294.  prdest_status                       fsStatus
  17295.  
  17296.  prdest_status_string                pszStatus
  17297.  
  17298.  prdest_time                         time
  17299.  
  17300.  ────────────────────────────────────────────────────────────────────────────
  17301.  
  17302.  
  17303.  
  17304.  DosPrintDestAdd and DosPrintDestSetInfo accept the level 3 data structure
  17305.  PRDINFO3.
  17306.  
  17307.  DosPrintDestEnum and DosPrintDestGetInfo accept levels 0, 1, 2, and 3. These
  17308.  functions accept or return the logical address at level 0, the PRDINFO data
  17309.  structure at level 1, the printer name at level 2, and the PRDINFO3 data
  17310.  structure at level 3. New applications should use levels 2 and 3 only.
  17311.  
  17312.  DosPrintDestControl and DosPrintDestDel do not use these data structures.
  17313.  The required data is defined within the API function definition.
  17314.  
  17315.  
  17316.  Print Destination Name (level 0)
  17317.  
  17318.  At level 0, data is returned in this format:
  17319.  
  17320.    CHAR szName[PDLEN+1];
  17321.  
  17322.  where
  17323.  
  17324.  szName
  17325.    Specifies an ASCIIZ string that contains the name of a print destination.
  17326.    The constant PDLEN is defined in the PMSPL.H header file.
  17327.  
  17328.  
  17329.  Print Destination Information (level 1)
  17330.  
  17331.  The PRDINFO data structure has this format:
  17332.  
  17333.    typedef struct _PRDINFO {
  17334.        CHAR    szName[PDLEN+1];
  17335.        CHAR    szUserName[UNLEN+1];
  17336.        USHORT  uJobId;
  17337.        USHORT  fsStatus;
  17338.        PSZ     pszStatus;
  17339.        USHORT  time;
  17340.    } PRDINFO;
  17341.  
  17342.  where
  17343.  
  17344.  szName
  17345.    Specifies an ASCIIZ string that contains the name of the print
  17346.    destination. The constant PDLEN is defined in the PMSPL.H header file.
  17347.  
  17348.  szUserName
  17349.    Specifies an ASCIIZ string that contains the name of the user who
  17350.    submitted a print job. This component is valid only during printing. A
  17351.    null string indicates that the job was submitted from the local computer.
  17352.    The constant UNLEN is defined in the PMSPL.H header file.
  17353.  
  17354.  uJobId
  17355.    Contains an unsigned short integer that specifies the identification
  17356.    number of the current print job. If no job is printing, uJobId is 0.
  17357.  
  17358.  fsStatus
  17359.    Contains a short integer that specifies the status of the print
  17360.    destination. The bits of fsStatus are defined in PMSPL.H.
  17361.  
  17362.    Bits 0-1 have the code PRD_STATUS_MASK and the value 0x0003. This bit mask
  17363.    isolates the print destination status, as follows:
  17364.  
  17365.  Bits  Code        Value  Meaning
  17366.  ────────────────────────────────────────────────────────────────────────────
  17367.  0-1   PRD_ACTIVE  0      The print job is processing.
  17368.  0-1   PRD_PAUSED  1      The print job is paused.
  17369.  ────────────────────────────────────────────────────────────────────────────
  17370.  
  17371.    Bits 2-11 indicate the print job and print destination status. Bits 2-11
  17372.    can be isolated using the constants PRJ_DEVSTATUS and PRD_DEVSTATUS, which
  17373.    have the value 0x0FFC. Bit 15 signals whether an alert indicated that the
  17374.    print job was deleted. These are the meanings for individual bits:
  17375.  
  17376. ╓┌────┌────────────────┌───────┌─────────────────────────────────────────────╖
  17377.  Bit  Code             Value   Meaning
  17378.  ────────────────────────────────────────────────────────────────────────────
  17379.  2    PRJ_COMPLETE     0x0004  If 1, the print job is complete.
  17380.  
  17381.  3    PRJ_INTERV       0x0008  If 1, intervention is required.
  17382.  
  17383.  4    PRJ_ERROR        0x0010  If 1, an error occurred (pszStatus can
  17384.                                contain a comment explaining the error).
  17385.  
  17386.  5    PRJ_DESTOFFLINE  0x0020  If 1, the print destination is offline.
  17387.  
  17388.  6    PRJ_DESTPAUSED   0x0040  If 1, the print destination is paused.
  17389.  
  17390.  Bit  Code             Value   Meaning
  17391.  ────────────────────────────────────────────────────────────────────────────
  17392. 
  17393.  7    PRJ_NOTIFY       0x0080  If 1, an alert is raised.
  17394.  
  17395.  8    PRJ_DESTNOPAPER  0x0100  If 1, the print destination is out of paper.
  17396.  
  17397.  9    PRJ_DESTFORMCHG  0x0200  If 1, the printer is waiting for a form
  17398.                                change.
  17399.  
  17400.  10   PRJ_DESTCRTCHG   0x0400  If 1, the printer is waiting for a cartridge
  17401.                                change.
  17402.  
  17403.  11   PRJ_DESTPENCHG   0x0800  If 1, the printer is waiting for a pen
  17404.                                change.
  17405.  
  17406.  15   PRJ_DELETED      0x8000  If 1, an alert indicates the print job was
  17407.                                deleted.
  17408.  
  17409.  ────────────────────────────────────────────────────────────────────────────
  17410.  
  17411.  Bit  Code             Value   Meaning
  17412.  ────────────────────────────────────────────────────────────────────────────
  17413. 
  17414.  
  17415.  
  17416.  pszStatus
  17417.    Points to an ASCIIZ string that contains a comment about the print
  17418.    destination error status, posted by the print destination's print
  17419.    processor. This element contains valid data only while the job is printing
  17420.    and an error occurs.
  17421.  
  17422.  time
  17423.    Contains an unsigned short integer that specifies the number of minutes
  17424.    the current job has been printing. This value is valid only while the job
  17425.    is printing.
  17426.  
  17427.  
  17428.  Print Destination Information (level 2)
  17429.  
  17430.  At level 2, the pszPrinterName element of the PRDINFO3 data structure is
  17431.  returned in this format:
  17432.  
  17433.    PSZ pszPrinterName;
  17434.  
  17435.  where
  17436.  
  17437.  pszPrinterName
  17438.    Points to an ASCIIZ string that specifies the name of a print destination.
  17439.    The name can contain blanks. The string can have as many as CCHMAXPATHCOMP
  17440.    bytes, as defined in the MS OS/2 header file BSEDOS.H.
  17441.  
  17442.  
  17443.  Print Destination Information (level 3)
  17444.  
  17445.  The PRDINFO3 data structure has this format:
  17446.  
  17447.    typedef struct _PRDINFO3 {
  17448.        PSZ     pszPrinterName;
  17449.        PSZ     pszUserName;
  17450.        PSZ     pszLogAddr;
  17451.        USHORT  uJobId;
  17452.        USHORT  fsStatus;
  17453.        PSZ     pszStatus;
  17454.        PSZ     pszComment;
  17455.        PSZ     pszDrivers;
  17456.        USHORT  time;
  17457.        USHORT  pad1;
  17458.    } PRDINFO3;
  17459.  
  17460.  where
  17461.  
  17462.  pszPrinterName
  17463.    Points to an ASCIIZ string that specifies the name of the printer. The
  17464.    name can contain blanks. The string can have as many as CCHMAXPATHCOMP
  17465.    bytes, as defined in the MS OS/2 header file BSEDOS.H.
  17466.  
  17467.  pszUserName
  17468.    Points to an ASCIIZ string that specifies the name of the user who
  17469.    submitted the currently active print job. This variable is valid only
  17470.    during printing. A null string or null pointer indicates the job was
  17471.    submitted from the local computer.
  17472.  
  17473.  pszLogAddr
  17474.    Points to an ASCIIZ string that specifies the name of the logical address
  17475.    where this printer prints, such as LPT1. If the printer is not connected
  17476.    to a logical address, pszLogAddr is a null pointer.
  17477.  
  17478.  uJobId
  17479.    Contains an unsigned short integer that specifies the identification
  17480.    number of a job currently being printed. If no job is printing, uJobId is
  17481.    0.
  17482.  
  17483.  fsStatus
  17484.    Contains a short integer that specifies the status of the print
  17485.    destination. The bits of fsStatus are identical to the fsStatus element of
  17486.    the PRDINFO data structure. For a full description, see the preceding
  17487.    section.
  17488.  
  17489.  pszStatus
  17490.    Points to an ASCIIZ string that contains a comment about the print
  17491.    destination error status, posted by the print destination's print
  17492.    processor. This value is valid only while the job is printing and an error
  17493.    occurs.
  17494.  
  17495.  pszComment
  17496.    Points to an ASCIIZ string that contains a printer description.
  17497.  
  17498.  pszDrivers
  17499.    Points to an ASCIIZ string that contains a list of drivers that are
  17500.    supported by this printer (the drivernames are separated by commas). If
  17501.    the devicename contains blanks, the name should be enclosed in quotation
  17502.    marks (" "). Each driver can consist of a drivername and a devicename
  17503.    separated by a period (.) For example:
  17504.  
  17505.    IBM 4201, "PSCRIPT. Apple Laserwriter"
  17506.  
  17507.    indicates that this printer supports two drivers.
  17508.  
  17509.  time
  17510.    Contains an unsigned short integer that specifies the number of minutes
  17511.    the current job has been printing. This value is valid only during
  17512.    printing.
  17513.  
  17514.  pad1
  17515.    Aligns the next data structure element on a word boundary.
  17516.  
  17517.  
  17518.  DosPrintDestAdd
  17519.  ────────────────────────────────────────────────────────────────────────────
  17520.  
  17521.  DosPrintDestAdd adds a print destination to the specified computer.
  17522.  
  17523.  
  17524.  Operating Systems Supported
  17525.  
  17526.  
  17527.    ■   MS OS/2 version 1.2, local and remote
  17528.  
  17529.    ■   MS OS/2 version 1.1, remote and levels 0 and 1 only
  17530.  
  17531.    ■   MS-DOS, remote only
  17532.  
  17533.  
  17534.  
  17535.  Privilege Level
  17536.  
  17537.  Admin privilege or print operator privilege is required to successfully
  17538.  execute DosPrintDestAdd on a remote server or on a computer that has local
  17539.  security enabled.
  17540.  
  17541.  
  17542.  Syntax
  17543.  
  17544.    #define INCL_BASE
  17545.    #include <os2.h>
  17546.  
  17547.    #include <pmspl.h>
  17548.  
  17549.    #define INCL_NETERRORS
  17550.    #include <lan.h>
  17551.  
  17552.    SPLERR SPLENTRY
  17553.    DosPrintDestAdd (PSZ     pszServer,
  17554.                     USHORT  uLevel,
  17555.                     PBYTE   pbBuf,
  17556.                     USHORT  cbBuf
  17557.                    );
  17558.  
  17559.  where
  17560.  
  17561.  pszServer
  17562.    Points to an ASCIIZ string that contains the name of a server on which to
  17563.    execute DosPrintDestAdd. A null pointer or null string specifies the local
  17564.    computer.
  17565.  
  17566.  uLevel
  17567.    Specifies the level of detail requested; must be 3.
  17568.  
  17569.  pbBuf
  17570.    Points to the buffer in which to store the returned data. On a successful
  17571.    return, the buffer contains records of the PRDINFO3 data structure.
  17572.  
  17573.  cbBuf
  17574.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  17575.  
  17576.  Return Codes
  17577.  
  17578. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  17579.  Code                              Value   Meaning
  17580.  ────────────────────────────────────────────────────────────────────────────
  17581.  NERR_Success                      0       The function encountered no
  17582.                                            errors.
  17583.  
  17584.  ERROR_ACCESS_DENIED               5       The user has insufficient
  17585.                                            privilege for this operation.
  17586.  
  17587.  ERROR_BAD_NETPATH                 53      The network path was not found.
  17588.  
  17589.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  17590.  
  17591.  ERROR_REQ_NOT_ACCEP               71      The network request cannot be
  17592.                                            accepted at this time. There may
  17593.                                            be a lack of resources on the
  17594.                                            specified server or the local
  17595.                                            workstation.
  17596.  
  17597.  ERROR_INVALID_LEVEL               124     The level for information
  17598.                                            retrieval or setting is invalid.
  17599.  
  17600.  Code                              Value   Meaning
  17601.  ────────────────────────────────────────────────────────────────────────────
  17602. 
  17603.  NERR_RemoteOnly                   2106    This operation can be performed
  17604.                                            only on a server.
  17605.  
  17606.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  17607.  
  17608.  NERR_BadTransactConfig            2141    The server is not configured for
  17609.                                            this transaction: IPC$ is not
  17610.                                            shared.
  17611.  
  17612.  NERR_DestExists                   2153    The print destination already
  17613.                                            exists.
  17614.  
  17615.  NERR_DestNoRoom                   2157    The server does not have enough
  17616.                                            memory available to add another
  17617.                                            printer.
  17618.  
  17619.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  17620.  
  17621.  Code                              Value   Meaning
  17622.  ────────────────────────────────────────────────────────────────────────────
  17623. 
  17624.  NERR_DestInvalidState             2162    This operation cannot be
  17625.                                            performed on the print
  17626.                                            destination in its current state.
  17627.  
  17628.  NERR_SpoolNoMemory                2165    A spooler memory allocation
  17629.                                            failure occurred.
  17630.  
  17631.  NERR_DriverNotFound               2166    The device driver specified has
  17632.                                            not been installed on the
  17633.                                            computer.
  17634.  
  17635.  NERR_BadDev                       2341    The devicename is invalid
  17636.                                            because it does not represent a
  17637.                                            physical device, or because the
  17638.                                            device hardware is faulty.
  17639.  
  17640.  NERR_InvalidComputer              2351    The specified computername is
  17641.                                            invalid.
  17642.  Code                              Value   Meaning
  17643.  ────────────────────────────────────────────────────────────────────────────
  17644.                                           invalid.
  17645.  
  17646.  ────────────────────────────────────────────────────────────────────────────
  17647.  
  17648.  
  17649.  
  17650.  
  17651.  Remarks
  17652.  
  17653.  DosPrintDestAdd creates a new print destination to the specified computer.
  17654.  The printer is set to print at the logical address specified by the
  17655.  pszLogAddr element of the PRDINFO3 data structure. If pszLogAddr is a null
  17656.  pointer or null string, the print destination is created but not connected
  17657.  to any logical address. This means that printing cannot occur on that
  17658.  printer or from any printer queue connected only to that printer.
  17659.  
  17660.  A print destination can be successfully added on an MS OS/2 1.2 workstation
  17661.  even if the workstation is not connected to a printer.
  17662.  
  17663.  All device drivers specified for the printer must be installed before
  17664.  calling DosPrintDestAdd.
  17665.  
  17666.  See Also
  17667.  
  17668.  For information about             See
  17669.  ────────────────────────────────────────────────────────────────────────────
  17670.  Changing the connection between   DosPrintDestSetInfo
  17671.  a printer and a port
  17672.  
  17673.  
  17674.  DosPrintDestControl
  17675.  ────────────────────────────────────────────────────────────────────────────
  17676.  
  17677.  DosPrintDestControl pauses or continues printing on the specified print
  17678.  destination. If a job is currently printing on that destination, its status
  17679.  is changed along with that of the print destination. This function can also
  17680.  cancel or restart a job that is printing on the specified destination.
  17681.  
  17682.  
  17683.  Operating Systems Supported
  17684.  
  17685.  
  17686.    ■   MS OS/2 version 1.2, local and remote
  17687.  
  17688.    ■   MS OS/2 version 1.1, remote and levels 0 and 1 only
  17689.  
  17690.    ■   MS-DOS, remote only
  17691.  
  17692.  
  17693.  
  17694.  Privilege Level
  17695.  
  17696.  Admin privilege or print operator privilege is required to successfully
  17697.  execute DosPrintDestControl on a remote server or on a computer that has
  17698.  local security enabled.
  17699.  
  17700.  
  17701.  Syntax
  17702.  
  17703.    #define INCL_BASE
  17704.    #include <os2.h>
  17705.  
  17706.    #include <pmspl.h>
  17707.  
  17708.    #define INCL_NETERRORS
  17709.    #include <lan.h>
  17710.  
  17711.    SPLERR SPLENTRY
  17712.    DosPrintDestControl (PSZ     pszServer,
  17713.                         PSZ     pszDestName,
  17714.                         USHORT  uControl
  17715.                        );
  17716.  
  17717.  where
  17718.  
  17719.  pszServer
  17720.    Points to an ASCIIZ string that contains the name of the server on which
  17721.    to execute DosPrintDestControl. A null pointer or null string specifies
  17722.    the local computer.
  17723.  
  17724.  pszDestName
  17725.    Points to an ASCIIZ string that contains the name of the print
  17726.    destination.
  17727.  
  17728.  uControl
  17729.    Contains an unsigned short integer that specifies the operation to be
  17730.    performed. The PMSPL.H header file defines these possible values:
  17731.  
  17732. ╓┌────────────┌──────┌───────────────────────────────────────────────────────╖
  17733.  Code         Value  Meaning
  17734.  ────────────────────────────────────────────────────────────────────────────
  17735.  PRD_DELETE   0      Delete the current print job.
  17736.  PRD_PAUSE    1      Pause printing.
  17737.  PRD_CONT     2      Continue the paused print job.
  17738.  PRD_RESTART  3      Restart the print job.
  17739.  ─            4-255  Reserved.
  17740.  ────────────────────────────────────────────────────────────────────────────
  17741.  
  17742.  
  17743.  Return Codes
  17744.  
  17745. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  17746.  Code                              Value   Meaning
  17747.  Code                              Value   Meaning
  17748.  ────────────────────────────────────────────────────────────────────────────
  17749.  NERR_Success                      0       The function encountered no
  17750.                                            errors.
  17751.  
  17752.  ERROR_ACCESS_DENIED               5       The user has insufficient
  17753.                                            privilege for this operation.
  17754.  
  17755.  ERROR_BAD_NETPATH                 53      The network path was not found.
  17756.  
  17757.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  17758.  
  17759.  NERR_RemoteOnly                   2106    This operation can be performed
  17760.                                            only on a server.
  17761.  
  17762.  NERR_BadTransactConfig            2141    The server is not configured for
  17763.                                            this transaction: IPC$ is not
  17764.                                            shared.
  17765.  
  17766.  NERR_DestNotFound                 2152    The print destination was not
  17767.                                            found.
  17768.  Code                              Value   Meaning
  17769.  ────────────────────────────────────────────────────────────────────────────
  17770.                                           found.
  17771.  
  17772.  NERR_DestIdle                     2158    The print destination is idle
  17773.                                            and cannot accept control
  17774.                                            operations.
  17775.  
  17776.  NERR_DestInvalidOp                2159    The print destination request
  17777.                                            contains an invalid control
  17778.                                            function.
  17779.  
  17780.  NERR_ProcNoRespond                2160    The print processor is not
  17781.                                            responding.
  17782.  
  17783.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  17784.  
  17785.  NERR_InvalidComputer              2351    The specified computername is
  17786.                                            invalid.
  17787.  
  17788.  ────────────────────────────────────────────────────────────────────────────
  17789.  Code                              Value   Meaning
  17790.  ────────────────────────────────────────────────────────────────────────────
  17791. ────────────────────────────────────────────────────────────────────────────
  17792.  
  17793.  
  17794.  
  17795.  
  17796.  Remarks
  17797.  
  17798.  While paused, a print destination cannot accept new print jobs.
  17799.  
  17800.  To maintain compatibility with LAN Manager 1.0 applications,
  17801.  DosPrintDestControl uses logical addresses to refer to the destination
  17802.  printer.
  17803.  
  17804.  If the print destination is idle when the application attempts to restart or
  17805.  delete a print job (that is, the uControl parameter has the value PRD_DELETE
  17806.  or PRD_RESTART), DosPrintDestControl returns the error code NERR_DestIdle.
  17807.  These operations can succeed only if a job is printing.
  17808.  
  17809.  See Also
  17810.  
  17811.  For information about             See
  17812.  ────────────────────────────────────────────────────────────────────────────
  17813.  Listing the print destinations    DosPrintDestEnum
  17814.  on a computer
  17815.  
  17816.  Retrieving the status of the      DosPrintJobGetInfo
  17817.  current print job spooled to a
  17818.  printer
  17819.  
  17820.  
  17821.  DosPrintDestDel
  17822.  ────────────────────────────────────────────────────────────────────────────
  17823.  
  17824.  DosPrintDestDel deletes a print destination from a computer.
  17825.  
  17826.  
  17827.  Operating Systems Supported
  17828.  
  17829.  
  17830.    ■   MS OS/2 version 1.2, local and remote
  17831.  
  17832.    ■   MS OS/2 version 1.1, remote and levels 0 and 1 only
  17833.  
  17834.    ■   MS-DOS, remote only
  17835.  
  17836.  
  17837.  
  17838.  Privilege Level
  17839.  
  17840.  Admin privilege or print operator privilege is required to successfully
  17841.  execute DosPrintDestDel on a remote server or on a computer that has local
  17842.  security enabled.
  17843.  
  17844.  
  17845.  Syntax
  17846.  
  17847.    #define INCL_BASE
  17848.    #include <os2.h>
  17849.  
  17850.    #include <pmspl.h>
  17851.  
  17852.    #define INCL_NETERRORS
  17853.    #include <lan.h>
  17854.  
  17855.    SPLERR SPLENTRY
  17856.    DosPrintDestDel (PSZ pszServer,
  17857.                     PSZ pszPrinterName
  17858.                    );
  17859.  
  17860.  where
  17861.  
  17862.  pszServer
  17863.    Points to an ASCIIZ string that contains the name of the server on which
  17864.    to execute DosPrintDestDel. A null pointer or null string specifies the
  17865.    local computer.
  17866.  
  17867.  pszPrinterName
  17868.    Points to the name of the printer to be deleted. The printer name should
  17869.    be a general name as defined in the level 2 and level 3 data structures,
  17870.    rather than a logical address as defined in the level 0 and level 1 data
  17871.    structures.
  17872.  
  17873.  Return Codes
  17874.  
  17875. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  17876.  Code                              Value   Meaning
  17877.  ────────────────────────────────────────────────────────────────────────────
  17878.  NERR_Success                      0       The function encountered no
  17879.                                            errors.
  17880.  
  17881.  ERROR_ACCESS_DENIED               5       The user has insufficient
  17882.                                            privilege for this operation.
  17883.  
  17884.  ERROR_BAD_NETPATH                 53      The network path was not found.
  17885.  
  17886.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  17887.  
  17888.  NERR_RemoteOnly                   2106    This operation can be performed
  17889.                                            only on a server.
  17890.  
  17891.  NERR_BadTransactConfig            2141    The server is not configured for
  17892.                                            this transaction: IPC$ is not
  17893.                                            shared.
  17894.  Code                              Value   Meaning
  17895.  ────────────────────────────────────────────────────────────────────────────
  17896.                                           shared.
  17897.  
  17898.  NERR_DestNotFound                 2152    The print destination was not
  17899.                                            found.
  17900.  
  17901.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  17902.  
  17903.  NERR_DestInvalidState             2162    This operation cannot be
  17904.                                            performed on the print
  17905.                                            destination in its current state.
  17906.  
  17907.  NERR_InvalidComputer              2351    The specified computername is
  17908.                                            invalid.
  17909.  
  17910.  ────────────────────────────────────────────────────────────────────────────
  17911.  
  17912.  
  17913.  
  17914.  
  17915.  Remarks
  17916.  
  17917.  If the print destination is currently printing a job, DosPrintDestDel
  17918.  returns the error code NERR_DestInvalidState.
  17919.  
  17920.  
  17921.  DosPrintDestEnum
  17922.  ────────────────────────────────────────────────────────────────────────────
  17923.  
  17924.  DosPrintDestEnum lists all print destinations on a computer and gives status
  17925.  information about the print destinations.
  17926.  
  17927.  
  17928.  Operating Systems Supported
  17929.  
  17930.  
  17931.    ■   MS OS/2 version 1.2, local and remote
  17932.  
  17933.    ■   MS OS/2 version 1.1, remote and levels 0 and 1 only
  17934.  
  17935.    ■   MS-DOS, remote only
  17936.  
  17937.  
  17938.  
  17939.  Privilege Level
  17940.  
  17941.  No special privilege level is required to successfully execute
  17942.  DosPrintDestEnum.
  17943.  
  17944.  
  17945.  Syntax
  17946.  
  17947.    #define INCL_BASE
  17948.    #include <os2.h>
  17949.  
  17950.    #include <pmspl.h>
  17951.  
  17952.    #define INCL_NETERRORS
  17953.    #include <lan.h>
  17954.  
  17955.    SPLERR SPLENTRY
  17956.    DosPrintDestEnum (PSZ      pszServer,
  17957.                      USHORT   uLevel,
  17958.                      PBYTE    pbBuf,
  17959.                      USHORT   cbBuf,
  17960.                      PUSHORT  pcReturned,
  17961.                      PUSHORT  pcTotal
  17962.                     );
  17963.  
  17964.  where
  17965.  
  17966.  pszServer
  17967.    Points to an ASCIIZ string that contains the name of the server on which
  17968.    to execute DosPrintDestEnum. A null pointer or null string specifies the
  17969.    local computer.
  17970.  
  17971.  uLevel
  17972.    Specifies the level of detail (0, 1, 2, or 3) requested.
  17973.  
  17974.  pbBuf
  17975.    Points to the buffer in which to store the returned data. On a successful
  17976.    return, the buffer contains a PRDINFOX data structure, where X is 0, 1, 2,
  17977.    or 3, depending on the level of detail requested.
  17978.  
  17979.  cbBuf
  17980.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  17981.  
  17982.  pcReturned
  17983.    Points to an unsigned short integer that indicates the number of entries
  17984.    returned in the buffer pointed to by pbBuf. This count is valid only if
  17985.    DosPrintDestEnum returns NERR_Success or ERROR_MORE_DATA.
  17986.  
  17987.  pcTotal
  17988.    Points to an unsigned short integer that indicates how many entries were
  17989.    available. This count is valid only if DosPrintDestEnum returns
  17990.    NERR_Success or ERROR_MORE_DATA.
  17991.  
  17992.  Return Codes
  17993.  
  17994. ╓┌──────────────────────┌───────┌────────────────────────────────────────────╖
  17995.  Code                   Value   Meaning
  17996.  ────────────────────────────────────────────────────────────────────────────
  17997.  NERR_Success           0       The function encountered no errors.
  17998.  
  17999.  Code                   Value   Meaning
  18000.  ────────────────────────────────────────────────────────────────────────────
  18001. 
  18002.  ERROR_BAD_NETPATH      53      The network path was not found.
  18003.  
  18004.  ERROR_INVALID_LEVEL    124     The level for information retrieval or
  18005.                                 setting is invalid.
  18006.  
  18007.  ERROR_MORE_DATA        234     Additional data is available.
  18008.  
  18009.  NERR_RemoteOnly        2106    This operation can be performed only on a
  18010.                                 server.
  18011.  
  18012.  NERR_DestNotFound      2152    The print destination was not found.
  18013.  
  18014.  NERR_SpoolerNotLoaded  2161    The spooler is not started.
  18015.  
  18016.  NERR_InvalidComputer   2351    The specified computername is invalid.
  18017.  
  18018.  ────────────────────────────────────────────────────────────────────────────
  18019.  
  18020.  Code                   Value   Meaning
  18021.  ────────────────────────────────────────────────────────────────────────────
  18022. 
  18023.  
  18024.  
  18025.  
  18026.  Remarks
  18027.  
  18028.  At levels 0 and 1, DosPrintDestEnum returns print destination names only if
  18029.  they are associated with printer queues. At levels 2 and 3, DosPrintDestEnum
  18030.  returns all print destinations.
  18031.  
  18032.  See Also
  18033.  
  18034.  For information about             See
  18035.  ────────────────────────────────────────────────────────────────────────────
  18036.  Pausing or continuing printing    DosPrintDestControl
  18037.  on a particular print
  18038.  destination
  18039.  
  18040.  Retrieving the status of a        DosPrintDestGetInfo
  18041.  particular print destination
  18042.  
  18043.  
  18044.  DosPrintDestGetInfo
  18045.  ────────────────────────────────────────────────────────────────────────────
  18046.  
  18047.  DosPrintDestGetInfo retrieves information about a print destination on a
  18048.  computer.
  18049.  
  18050.  
  18051.  Operating Systems Supported
  18052.  
  18053.  
  18054.    ■   MS OS/2 version 1.2, local and remote
  18055.  
  18056.    ■   MS OS/2 version 1.1, remote and levels 0 and 1 only
  18057.  
  18058.    ■   MS-DOS, remote only
  18059.  
  18060.  
  18061.  
  18062.  Privilege Level
  18063.  
  18064.  No special privilege level is required to successfully execute
  18065.  DosPrintDestGetInfo.
  18066.  
  18067.  
  18068.  Syntax
  18069.  
  18070.    #define INCL_BASE
  18071.    #include <os2.h>
  18072.  
  18073.    #include <pmspl.h>
  18074.  
  18075.    #define INCL_NETERRORS
  18076.    #include <lan.h>
  18077.  
  18078.    SPLERR SPLENTRY
  18079.    DosPrintDestGetInfo (PSZ      pszServer,
  18080.                         PSZ      pszName,
  18081.                         USHORT   uLevel,
  18082.                         PBYTE    pbBuf,
  18083.                         USHORT   cbBuf,
  18084.                         PUSHORT  pcbNeeded
  18085.                        );
  18086.  
  18087.  where
  18088.  
  18089.  pszServer
  18090.    Points to an ASCIIZ string that contains the name of the server on which
  18091.    to execute DosPrintDestGetInfo. A null pointer or null string specifies
  18092.    the local computer.
  18093.  
  18094.  pszName
  18095.    Points to an ASCIIZ string that contains the name of the specific print
  18096.    destination.
  18097.  
  18098.  uLevel
  18099.    Specifies the level of detail (0, 1, 2, or 3) requested.  The level
  18100.    parameter works in conjunction with pszName and pbBuf, as follows:
  18101.  
  18102.  uLevel  pszName          Data returned in pbBuf
  18103.  ────────────────────────────────────────────────────────────────────────────
  18104.  0       Logical address  pszLogAddr element of PRDINFO3
  18105.                           data structure.
  18106.  
  18107.  1       Logical address  PRDINFO data structure.
  18108.  
  18109.  2       Printer name     Pointer to a printer name.
  18110.  
  18111.  3       Printer name     PRDINFO3 data structure.
  18112.  
  18113.  ────────────────────────────────────────────────────────────────────────────
  18114.  
  18115.  
  18116.  pbBuf
  18117.    Points to the buffer in which to store the returned data. On a successful
  18118.    return, the buffer contains the data structure that corresponds to the
  18119.    uLevel and pszName parameters, as described in the preceding table.
  18120.  
  18121.  cbBuf
  18122.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  18123.  
  18124.  pcbNeeded
  18125.    Points to an unsigned short integer that specifies the number of bytes of
  18126.    information available. This count is valid only if DosPrintDestGetInfo
  18127.    returns NERR_Success,  ERROR_MORE_DATA, or NERR_BufTooSmall.
  18128.  
  18129.  Return Codes
  18130.  
  18131. ╓┌──────────────────────┌───────┌────────────────────────────────────────────╖
  18132.  Code                   Value   Meaning
  18133.  ────────────────────────────────────────────────────────────────────────────
  18134.  NERR_Success           0       The function encountered no errors.
  18135.  
  18136.  ERROR_BAD_NETPATH      53      The network path was not found.
  18137.  
  18138.  ERROR_INVALID_LEVEL    124     The level for information retrieval or
  18139.                                 setting is invalid.
  18140.  
  18141.  ERROR_MORE_DATA        234     Additional data is available.
  18142.  
  18143.  NERR_RemoteOnly        2106    This operation can be performed only on a
  18144.                                 server.
  18145.  
  18146.  Code                   Value   Meaning
  18147.  ────────────────────────────────────────────────────────────────────────────
  18148. 
  18149.  NERR_BufTooSmall       2123    The supplied buffer is too small.
  18150.  
  18151.  NERR_DestNotFound      2152    The print destination was not found.
  18152.  
  18153.  NERR_SpoolerNotLoaded  2161    The spooler is not started.
  18154.  
  18155.  NERR_InvalidComputer   2351    The specified computername is invalid.
  18156.  
  18157.  ────────────────────────────────────────────────────────────────────────────
  18158.  
  18159.  
  18160.  
  18161.  
  18162.  Remarks
  18163.  
  18164.  At levels 0 and 1, DosPrintDestGetInfo returns print destination names only
  18165.  if they are associated with printer queues. At levels 2 and 3,
  18166.  DosPrintDestGetInfo returns all print destinations.
  18167.  
  18168.  See Also
  18169.  
  18170.  For information about             See
  18171.  ────────────────────────────────────────────────────────────────────────────
  18172.  Listing the print destinations    DosPrintDestEnum
  18173.  on a computer
  18174.  
  18175.  Pausing or continuing printing    DosPrintDestControl
  18176.  on a particular print
  18177.  destination
  18178.  
  18179.  
  18180.  DosPrintDestSetInfo
  18181.  ────────────────────────────────────────────────────────────────────────────
  18182.  
  18183.  DosPrintDestSetInfo modifies the configuration of a print destination.
  18184.  
  18185.  
  18186.  Operating Systems Supported
  18187.  
  18188.  
  18189.    ■   MS OS/2 version 1.2, local and remote
  18190.  
  18191.    ■   MS OS/2 version 1.1, remote and levels 0 and 1 only
  18192.  
  18193.    ■   MS-DOS, remote only
  18194.  
  18195.  
  18196.  
  18197.  Privilege Level
  18198.  
  18199.  Admin privilege or print operator privilege is required to successfully
  18200.  execute DosPrintDestSetInfo on a remote server or on a computer that has
  18201.  local security enabled.
  18202.  
  18203.  
  18204.  Syntax
  18205.  
  18206.    #define INCL_BASE
  18207.    #include <os2.h>
  18208.  
  18209.    #include <pmspl.h>
  18210.  
  18211.    #define INCL_NETERRORS
  18212.    #include <lan.h>
  18213.  
  18214.    SPLERR SPLENTRY
  18215.    DosPrintDestSetInfo (PSZ     pszServer,
  18216.                         PSZ     pszName,
  18217.                         USHORT  uLevel,
  18218.                         PBYTE   pbBuf,
  18219.                         USHORT  cbBuf,
  18220.                         USHORT  uParmNum
  18221.                        );
  18222.  
  18223.  where
  18224.  
  18225.  pszServer
  18226.    Points to an ASCIIZ string that contains the name of the server on which
  18227.    to execute DosPrintDestSetInfo. A null pointer or null string specifies
  18228.    the local computer.
  18229.  
  18230.  pszName
  18231.    Points to an ASCIIZ string that contains the name of the printer or
  18232.    parallel port.
  18233.  
  18234.  uLevel
  18235.    Specifies the level of detail; must be 3.
  18236.  
  18237.  pbBuf
  18238.    Points to the data to be set.
  18239.  
  18240.  cbBuf
  18241.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  18242.  
  18243.  uParmNum
  18244.    Specifies whether to set one or all elements of the entire PRDINFO3 data
  18245.    structure. If uParmNum is PARMNUM_ALL, the entire structure is set, and
  18246.    pbBuf must point to a PRDINFO3 data structure. If uParmNum is any other
  18247.    defined value, only one element of the print destination information is
  18248.    changed, and pbBuf must point to a valid value for that element.
  18249.  
  18250.    Not all elements can be set. Only those that have a specific PARMNUM
  18251.    constant value defined can be set. The PMSPL.H and NETCONS.H header files
  18252.    define these possible values for sParmNum:
  18253.  
  18254.  Code                 Value  Element of PRDINFO3
  18255.  ────────────────────────────────────────────────────────────────────────────
  18256.  PARMNUM_ALL          0      All elements.
  18257.  PRD_LOGADDR_PARMNUM  3      pszLogAddr
  18258.  PRD_COMMENT_PARMNUM  7      pszComment
  18259.  PRD_DRIVERS_PARMNUM  8      pszDrivers
  18260.  ────────────────────────────────────────────────────────────────────────────
  18261.  
  18262.  Return Codes
  18263.  
  18264. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  18265.  Code                              Value   Meaning
  18266.  ────────────────────────────────────────────────────────────────────────────
  18267.  NERR_Success                      0       The function encountered no
  18268.                                            errors.
  18269.  
  18270.  ERROR_ACCESS_DENIED               5       The user has insufficient
  18271.                                            privilege for this operation.
  18272.  Code                              Value   Meaning
  18273.  ────────────────────────────────────────────────────────────────────────────
  18274.                                           privilege for this operation.
  18275.  
  18276.  ERROR_BAD_NETPATH                 53      The network path was not found.
  18277.  
  18278.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  18279.  
  18280.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  18281.                                            invalid.
  18282.  
  18283.  ERROR_INVALID_LEVEL               124     The level for information
  18284.                                            retrieval or setting is invalid.
  18285.  
  18286.  NERR_RemoteOnly                   2106    This operation can be performed
  18287.                                            only on a server.
  18288.  
  18289.  NERR_BadTransactConfig            2141    The server is not configured for
  18290.                                            this transaction: IPC$ is not
  18291.                                            shared.
  18292.  
  18293.  Code                              Value   Meaning
  18294.  ────────────────────────────────────────────────────────────────────────────
  18295. 
  18296.  NERR_DestNotFound                 2152    The print destination was not
  18297.                                            found.
  18298.  
  18299.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  18300.  
  18301.  NERR_SpoolNoMemory                2165    A spooler memory allocation
  18302.                                            failure occurred.
  18303.  
  18304.  NERR_DriverNotFound               2166    The device driver specified has
  18305.                                            not been installed on the
  18306.                                            computer.
  18307.  
  18308.  NERR_BadDev                       2341    The devicename is invalid
  18309.                                            because it does not represent a
  18310.                                            physical device, or because the
  18311.                                            device hardware is faulty.
  18312.  
  18313.  NERR_InvalidComputer              2351    The specified computername is
  18314.  Code                              Value   Meaning
  18315.  ────────────────────────────────────────────────────────────────────────────
  18316. NERR_InvalidComputer              2351    The specified computername is
  18317.                                            invalid.
  18318.  
  18319.  ────────────────────────────────────────────────────────────────────────────
  18320.  
  18321.  
  18322.  
  18323.  
  18324.  Remarks
  18325.  
  18326.  DosPrintDestSetInfocan be used to disconnect a printer from a port by
  18327.  supplying a null string for the pszLogAddrelement of the PRDINFO3data
  18328.  structure.
  18329.  
  18330.  
  18331.  
  18332.  Print Destination Category Example
  18333.  
  18334.    /*
  18335.       NETPRD.C -- a program demonstrating the DosPrintDest API functions.
  18336.  
  18337.       Admin or print operator privilege is required to successfully
  18338.       execute the Print Destination API functions on a remote server.
  18339.  
  18340.       This program calls DosPrintDestAdd to add a printer to the specified
  18341.       server, then manipulates that printer using DosPrintDestControl.
  18342.       DosPrintDestGetInfo displays status information about the printer.
  18343.       DosPrintDestSetInfo is called to disconnect the printer from the
  18344.       computer. DosPrintDestEnum lists all printers on the computer.
  18345.       DosPrintDestDel then deletes the print destination.
  18346.  
  18347.       usage:  netprd [-s \\server] [-p printername] [-a address]
  18348.                      [-l level] [-o operation] [-d driver] [-f flag]
  18349.       where  \\server    = Name of the server. A servername must be preceded
  18350.                            by two backslashes (\\).
  18351.              printername = Name of the printer.
  18352.              address     = Logical address, such as LPT1.
  18353.              level       = Level of detail.
  18354.              operation   = Integer code for DosPrintDestControl.
  18355.              driver      = Name of the print driver.
  18356.              flag        = Flag whether to delete the printer (0 or 1).
  18357.  
  18358.       API                     Used to...
  18359.       ===================     ===============================================
  18360.       DosPrintDestAdd         Add a new print destination
  18361.       DosPrintDestControl     Control the status of the printer
  18362.       DosPrintDestGetInfo     Get specific information about a single
  18363.    printer
  18364.       DosPrintDestSetInfo     Set specific information for a single printer
  18365.       DosPrintDestEnum        List all printers available
  18366.       DosPrintDestDel         Delete the print destination
  18367.  
  18368.       This code sample is provided for demonstration purposes only.
  18369.       Microsoft makes no warranty, either express or implied,
  18370.       as to its usability in any given situation.
  18371.    */
  18372.  
  18373.    #define  INCL_BASE
  18374.    #include <os2.h>           // MS OS/2 base header files
  18375.    #include <pmspl.h>         // Print definitions
  18376.  
  18377.    #define  INCL_NETERRORS
  18378.    #include <lan.h>           // LAN Manager header files
  18379.  
  18380.    #include <stdio.h>         // C run-time header files
  18381.    #include <stdlib.h>
  18382.    #include <string.h>
  18383.  
  18384.    #include "samples.h"       // Internal routine header file
  18385.  
  18386.    #define  NEWPORTNAME       "LPT1"
  18387.    #define  NEWPRINTERNAME    "PrntDestTest"
  18388.    #define  NEWDRIVER         "IBM4201"
  18389.    #define  DEFAULT_BUF_SIZE  512
  18390.    #define  MAX_BUFFER_SIZE   65535
  18391.    #define  MAX_PDEST         10     // Limit for this program only
  18392.  
  18393.    void DisplayInfo(short sLevel, char *pbBuffer, unsigned short cEntries);
  18394.    void Usage(char *pszProgram);
  18395.  
  18396.    void main(int argc, char *argv[])
  18397.    {
  18398.       char *         pbBuffer;            // Return data
  18399.       char *         pszServer = "";      // Server; default to local
  18400.    computer
  18401.       char *         szNull = "";         // Null string
  18402.       char far *     pszPrinterName = NEWPRINTERNAME;
  18403.       char far *     pszLogAddr = NEWPORTNAME;
  18404.       char far *     pszDriver = NEWDRIVER;
  18405.       int            iCount;              // Index counter
  18406.       PRDINFO3       prd3;                // Level 3 data structure
  18407.       short          sLevel = 3;          // Level of detail
  18408.       unsigned       uRet;                // Return code
  18409.       unsigned short fDone;               // Flag successful call
  18410.       unsigned short fDelete = TRUE;      // Delete flag
  18411.       unsigned short cEntriesRead;        // Count of entries read
  18412.       unsigned short cTotal;              // Count of entries available
  18413.       unsigned short cbBuffer = 0;        // Count of bytes in data buffer
  18414.       unsigned short cbBufferNeeded = 0;  // Bytes needed for GetInfo
  18415.    call
  18416.       unsigned short uControl = PRD_CONT; // DosPrintDestControl operation
  18417.  
  18418.    for (iCount = 1; iCount < argc; iCount++) // Get cmd-line
  18419.    switches
  18420.       {
  18421.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  18422.          {
  18423.             switch (tolower(*(argv[iCount]+1))) // Process switches
  18424.             {
  18425.                case 's':                        // -s servername
  18426.                   pszServer = argv[++iCount];
  18427.                   break;
  18428.                case 'l':                        // -l level
  18429.                   sLevel = atoi(argv[++iCount]);
  18430.                   break;
  18431.                case 'p':                        // -p printername
  18432.                   pszPrinterName = argv[++iCount];
  18433.                   break;
  18434.                case 'd':                        // -d drivername
  18435.                   pszDriver = argv[++iCount];
  18436.                   break;
  18437.                case 'f':                        // -f flag deletion
  18438.                   fDelete = atoi(argv[++iCount]);
  18439.                   break;
  18440.                case 'a':                        // -a address
  18441.                   pszLogAddr = argv[++iCount];
  18442.                   break;
  18443.                case 'o':                        // -o operation
  18444.                   uControl = atoi(argv[++iCount]);
  18445.                   break;
  18446.                case 'h':
  18447.                default:
  18448.                   Usage(argv[0]);
  18449.             }
  18450.          }
  18451.          else
  18452.             Usage(argv[0]);
  18453.       }
  18454.       printf("\nPrint Destination Category API Examples\n");
  18455.  
  18456.    //=======================================================================
  18457.    //  DosPrintDestAdd
  18458.    //
  18459.    //  This API adds the specified printer to the specified server.
  18460.    //=======================================================================
  18461.  
  18462.       memset(&prd3, 0, sizeof(PRDINFO3));       // Initialize memory
  18463.  
  18464.       prd3.pszPrinterName = pszPrinterName;     // Set names
  18465.       prd3.pszLogAddr = pszLogAddr;
  18466.       prd3.pszDrivers = pszDriver;
  18467.  
  18468.       uRet = DosPrintDestAdd(pszServer,         // Servername
  18469.                      3,                         // Level; must be 3
  18470.                      (char far *)&prd3,         // New printer struct
  18471.                      sizeof(PRDINFO3));         // Size of buffer
  18472.  
  18473.       printf("DosPrintDestAdd returned %u\n", uRet);
  18474.       if (uRet == NERR_Success)
  18475.       {
  18476.          printf("   %Fs added to ", prd3.pszPrinterName);
  18477.          if ((pszServer == NULL) || (*pszServer == '\0'))
  18478.             printf("the local computer\n");
  18479.          else
  18480.             printf("   %s\n", pszServer);
  18481.          printf("   Printer port set to %Fs\n", prd3.pszLogAddr);
  18482.       }
  18483.  
  18484.    //=======================================================================
  18485.    //  DosPrintDestControl
  18486.    //
  18487.    //  This API controls a printer destination. It can delete, pause,
  18488.  
  18489.    //  continue, or restart the printer. If a job is printing at the
  18490.  
  18491.    //  time the API is executed, that print job receives the new printer
  18492.  
  18493.    //  status. The print destination name must be a logical address.
  18494.    //=======================================================================
  18495.  
  18496.       uRet = DosPrintDestControl(pszServer,     // Computername
  18497.                      pszLogAddr,                // Print destination
  18498.    name
  18499.                      uControl);                 // Operation
  18500.  
  18501.       printf("DosPrintDestControl returned %u\n", uRet);
  18502.  
  18503.    //=======================================================================
  18504.    //  DosPrintDestGetInfo
  18505.    //
  18506.    //  This API returns information about the specified print destination.
  18507.    //=======================================================================
  18508.  
  18509.    // Call with zero-length buffer, expect NERR_BufTooSmall.
  18510.  
  18511.       uRet = DosPrintDestGetInfo(pszServer,     // Servername
  18512.                      pszPrinterName,            // Printername
  18513.                      sLevel,                    // Call level
  18514.                      NULL,                      // Data buffer
  18515.                      0,                         // Size of buffer
  18516.                      &cbBufferNeeded);          // Returns required size
  18517.  
  18518.       if (uRet == NERR_BufTooSmall)
  18519.       {
  18520.          cbBuffer = cbBufferNeeded;
  18521.          pbBuffer = SafeMalloc(cbBuffer);    // SafeMalloc() is in SAMPLES.C
  18522.  
  18523.          uRet = DosPrintDestGetInfo(pszServer,  // Servername
  18524.                      pszPrinterName,            // Printername
  18525.                      sLevel,                    // Call level
  18526.                      pbBuffer,                  // Data buffer
  18527.                      cbBuffer,                  // Size of buffer
  18528.                      &cbBufferNeeded);          // Size required
  18529.  
  18530.          printf("DosPrintDestGetInfo returned %u\n", uRet);
  18531.          if (uRet == NERR_Success)
  18532.             DisplayInfo(sLevel, pbBuffer, 1);   // Display buffer
  18533.          free(pbBuffer);
  18534.       }
  18535.       else
  18536.          printf("DosPrintDestGetInfo returned %u\n", uRet);
  18537.  
  18538.    //=======================================================================
  18539.    //  DosPrintDestSetInfo
  18540.    //
  18541.    //  This API allows control over print destination settings.
  18542.    //  It must be called using level 3 (PRDINFO3).
  18543.    //
  18544.    //  In this example, a single element is set to the desired value.
  18545.    //  A program can also set all elements by setting the parameter number
  18546.    //  code to PARMNUM_ALL. Setting the logical address to a null string
  18547.    //  disconnects this printer from the computer.
  18548.    //=======================================================================
  18549.  
  18550.    uRet = DosPrintDestSetInfo(pszServer,     // Servername
  18551.                      pszPrinterName,            // Printername
  18552.                      3,                         // Level; must be 3
  18553.                      (char far *)szNull,        // Data
  18554.                      sizeof(szNull),            // Size of buffer
  18555.                      PRD_LOGADDR_PARMNUM);      // Parameter number code
  18556.  
  18557.       printf("DosPrintDestSetInfo returned %u", uRet);
  18558.       if (uRet)
  18559.          printf(": Disconnect failed");
  18560.       printf("\n");
  18561.  
  18562.    //========================================================================
  18563.    //  DosPrintDestEnum
  18564.    //
  18565.    //  This API lists all printers connected to the specified server.
  18566.    //  Allocate a buffer for the returned data. If the buffer is too
  18567.    small,
  18568.    //  try again with a bigger buffer, and keep trying until the buffer
  18569.    //  is large enough or until it cannot be made any larger.
  18570.    //========================================================================
  18571.  
  18572.       cbBuffer = DEFAULT_BUF_SIZE;
  18573.       pbBuffer = SafeMalloc(cbBuffer); // SafeMalloc() is in SAMPLES.C
  18574.       do
  18575.       {
  18576.           uRet = DosPrintDestEnum (pszServer,   // Servername
  18577.                      sLevel,                    // Call level
  18578.                      pbBuffer,                  // Buffer for info
  18579.                      cbBuffer,                  // Size of buffer
  18580.                      &cEntriesRead,             // Count of entries read
  18581.                      &cTotal);                  // Count of entries available
  18582.  
  18583.           if (uRet == ERROR_MORE_DATA)
  18584.           {
  18585.              free(pbBuffer);                    // Buffer too small
  18586.              if (cbBuffer == MAX_BUFFER_SIZE)
  18587.              {
  18588.                 printf("Exceeded buffer size\n");
  18589.                 exit(1);
  18590.              }
  18591.              else if (cbBuffer > (MAX_BUFFER_SIZE/2))
  18592.                 cbBuffer = MAX_BUFFER_SIZE;
  18593.              else
  18594.                 cbBuffer += cbBuffer;           // Allocate larger buffer
  18595.              pbBuffer = SafeMalloc(cbBuffer);
  18596.              fDone = FALSE;
  18597.           }
  18598.           else
  18599.              fDone = TRUE;
  18600.       } while (fDone == FALSE);  // Loop until buffer big enough or call
  18601.    fails
  18602.  
  18603.       printf("DosPrintDestEnum returned %u\n", uRet);
  18604.       printf("   Entries read = %hu out of %hu\n", cEntriesRead, cTotal);
  18605.  
  18606.       if (uRet == NERR_Success)
  18607.          DisplayInfo(sLevel, pbBuffer, cEntriesRead);
  18608.       free(pbBuffer);
  18609.  
  18610.    //========================================================================
  18611.    //  DosPrintDestDel
  18612.    //
  18613.    //  This API deletes the print destination.
  18614.    //========================================================================
  18615.  
  18616.       if (fDelete == TRUE)
  18617.       {
  18618.          uRet = DosPrintDestDel(pszServer,       // Servername
  18619.                                 pszPrinterName); // Printername
  18620.          printf("DosPrintDestDel returned %u\n", uRet);
  18621.       }
  18622.       exit(0);
  18623.    }  // End of main
  18624.  
  18625.    //=======================================================================
  18626.    //  DisplayInfo
  18627.    //
  18628.    //  Displays the print destination information obtained by
  18629.    //  DosPrintDestGetInfo or DosPrintDestEnum.
  18630.    //=======================================================================
  18631.  
  18632.    void DisplayInfo(short sLevel, char *pbBuffer, unsigned short cEntries)
  18633.    {
  18634.       char *         pprd0Info;   // Level 0 data
  18635.       PPRDINFO       pprd1Info;   // Pointer to level 1 structure
  18636.       PSZ *          pprd2Info;   // Array of pointers
  18637.       PPRDINFO3      pprd3Info;   // Pointer to level 3 structure
  18638.       unsigned short iCount;      // Index counter
  18639.  
  18640.       pprd0Info = (char *) pbBuffer;
  18641.       pprd1Info = (PPRDINFO) pbBuffer;
  18642.       pprd2Info = (PSZ *) pbBuffer;
  18643.       pprd3Info = (PPRDINFO3) pbBuffer;
  18644.  
  18645.    for (iCount = 0; iCount < cEntries; iCount++)
  18646.       {
  18647.          switch (sLevel)
  18648.          {
  18649.             case 0:
  18650.                printf("   Printer Name:  %s\n", pprd0Info);
  18651.                pprd0Info += (strlen(pprd0Info) + 1);
  18652.                break;
  18653.             case 1:
  18654.                printf("   Printer Name:  %s\n", pprd1Info->szName);
  18655.                printf("   User Name   :  %s\n", pprd1Info->szUserName);
  18656.                printf("   Job Id      :  %hu\n", pprd1Info->uJobId);
  18657.                if (pprd1Info->uJobId)  // Data valid only while job prints
  18658.                {
  18659.                   printf("   Job Status  :  0x%hx\n", pprd1Info->fsStatus);
  18660.                   printf("   Status Text :  %Fs\n", pprd1Info->pszStatus);
  18661.                   printf("   Time        :  %hu\n", pprd1Info->time);
  18662.                }
  18663.                pprd1Info++;
  18664.                break;
  18665.             case 2:
  18666.                printf("   Printer Name:  %Fs\n", *pprd2Info++);
  18667.                break;
  18668.             case 3:
  18669.                printf("   Printer Name:  %Fs\n", pprd3Info->pszPrinterName);
  18670.                printf("   Logical Addr:  %Fs\n", pprd3Info->pszLogAddr);
  18671.                printf("   Drivers     :  %Fs\n", pprd3Info->pszDrivers);
  18672.                printf("   Comment     :  %Fs\n", pprd3Info->pszComment);
  18673.                printf("   Job Id      :  %hu\n", pprd3Info->uJobId);
  18674.                if (pprd3Info->uJobId)
  18675.                {
  18676.                   printf("   User Name   :  %Fs\n", pprd3Info->pszUserName);
  18677.                   printf("   Job Status  :  0x%hx\n", pprd3Info->fsStatus);
  18678.                   printf("   Status Text :  %Fs\n", pprd3Info->pszStatus);
  18679.                   printf("   Print time  :  %hu\n", pprd3Info->time);
  18680.                }
  18681.                pprd3Info++;
  18682.                break;
  18683.             default:
  18684.                break;
  18685.          } // End switch sLevel
  18686.       } // End for loop
  18687.    }  // End function
  18688.  
  18689.    //=======================================================================
  18690.    //  Usage
  18691.    //
  18692.    //  Display possible command-line switches for this sample program.
  18693.    //=======================================================================
  18694.  
  18695.    void Usage(char *pszProgram)
  18696.    {
  18697.       fprintf(stderr, "Usage: %s [-s \\\\server] [-l level]", pszProgram);
  18698.       fprintf(stderr, " [-d driver]\n\t[-p printer] [-f flag delete]");
  18699.       fprintf(stderr, " [-a address] [-o operation]\n");
  18700.       exit(1);
  18701.    }
  18702.  
  18703.  
  18704.  
  18705.  
  18706.  
  18707.  Print Job Category
  18708.  
  18709.  Print Job API functions control the print jobs in a printer queue. When
  18710.  executed locally, Print Job functions do not require that the NETWKSTA
  18711.  device driver be installed. When a servername is supplied, they require that
  18712.  the Workstation service be started.
  18713.  
  18714.  The Print Job category functions, datatypes, structures, and constants are
  18715.  defined in the PMSPL.H header file. A source program can access these
  18716.  definitions by including the PMSPL.H header file. A source program can
  18717.  access error codes by defining the constant INCL_NETERRORS and including the
  18718.  LAN.H header file. For more information, see the "Example" section, later in
  18719.  this category.
  18720.  
  18721.  These are the Print Job API functions:
  18722.  
  18723.  
  18724.    ■   DosPrintJobContinue
  18725.  
  18726.    ■   DosPrintJobDel
  18727.  
  18728.    ■   DosPrintJobEnum
  18729.  
  18730.    ■   DosPrintJobGetId
  18731.  
  18732.    ■   DosPrintJobGetInfo
  18733.  
  18734.    ■   DosPrintJobPause
  18735.  
  18736.    ■   DosPrintJobSetInfo
  18737.  
  18738.  
  18739.  
  18740.  Description
  18741.  
  18742.  A print job is a file submitted to a printer queue for printing. The Print
  18743.  Job API functions control individual jobs within printer queues, and can
  18744.  change the position of a print job in the queue, pause a print job, or
  18745.  delete it from the queue.
  18746.  
  18747.  DosPrintJobGetId returns the identification number of the spooling job. The
  18748.  print spooler assigns an identification number when the job is queued.
  18749.  
  18750.  DosPrintJobEnum lists the print jobs in a particular printer queue.
  18751.  DosPrintJobGetInfo retrieves information about a particular print job.
  18752.  DosPrintJobSetInfo sets parameters related to the print job, such as its
  18753.  priority.
  18754.  
  18755.  DosPrintJobPause pauses a print job. DosPrintJobContinue allows a paused
  18756.  print job to continue.
  18757.  
  18758.  DosPrintJobDel removes a print job from a printer queue.
  18759.  
  18760.  The Print Job data structures and the Print Job API functions use MS OS/2
  18761.  conventions for names and type definitions. The OS2DEF.H header file defines
  18762.  these types:
  18763.  
  18764. ╓┌─────────────────────────────────┌─────────────────────────────────────────╖
  18765.  MS OS/2 Type Definition           C-Language Type
  18766.  ────────────────────────────────────────────────────────────────────────────
  18767.  CHAR                              char
  18768.  HFILE                             unsigned short
  18769.  PBYTE                             unsigned char far *
  18770.  PSZ                               unsigned char far *
  18771.  PUSHORT                           unsigned short *
  18772.  SPLENTRY                          pascal far
  18773.  SPLERR                            unsigned
  18774.  USHORT                            unsigned short
  18775.  ────────────────────────────────────────────────────────────────────────────
  18776.  MS OS/2 Type Definition           C-Language Type
  18777.  ────────────────────────────────────────────────────────────────────────────
  18778. ────────────────────────────────────────────────────────────────────────────
  18779.  
  18780.  
  18781.  
  18782.  Data Structures
  18783.  
  18784.  Level 0 and level 1 data structures are provided for compatibility with
  18785.  existing LAN Manager 1.0 applications. LAN Manager 2.0 applications should
  18786.  use level 0, 2, and 3 data structures.
  18787.  
  18788.  Existing LAN Manager 1.0 applications (that use the level 0 and level 1
  18789.  Print Job data structures) can be compiled and linked using the 1.0 header
  18790.  file NETSPOOL.H and the 1.0-compatible libraries NETSPOOL.LIB and
  18791.  NETSPOOL.DLL.
  18792.  
  18793.  Applications designed to run with both MS OS/2 1.1 and MS OS/2 1.2 should
  18794.  use the new level 0 and level 1 data structure names, include the PMSPL.H
  18795.  header file, and link with the NETSPOOL libraries.
  18796.  
  18797.  Applications that are designed to run only with MS OS/2 1.2 should use the
  18798.  PMSPL.LIB and PMSPL.DLL libraries. The PMSPL library functions provide
  18799.  better performance than the corresponding functions in the NETSPOOL library.
  18800.  
  18801.  
  18802.  Applications that run only with MS OS/2 1.2 can be built from existing
  18803.  applications. These applications can be upgraded by changing the data
  18804.  structure and element names. References to the prjob_info data structure and
  18805.  element names can be changed to the PRJINFO data structure and element
  18806.  names. There is one-to-one mapping from the prjob_info elements to the
  18807.  PRJINFO elements, as shown in the following table:
  18808.  
  18809. ╓┌──────────────────────────────────┌────────────────────────────────────────╖
  18810.  LAN Manager 1.0                    LAN Manager 2.0
  18811.  prjob_info Element                 PRJINFO Element
  18812.  ────────────────────────────────────────────────────────────────────────────
  18813.  prjob_id                           uJobId
  18814.  
  18815.  prjob_username                     szUserName
  18816.  
  18817.  prjob_pad_1                        pad_1
  18818.  LAN Manager 1.0                    LAN Manager 2.0
  18819.  prjob_info Element                 PRJINFO Element
  18820.  ────────────────────────────────────────────────────────────────────────────
  18821. prjob_pad_1                        pad_1
  18822.  
  18823.  prjob_notifyname                   szNotifyName
  18824.  
  18825.  prjob_datatype                     szDataType
  18826.  
  18827.  prjob_parms                        pszParms
  18828.  
  18829.  prjob_position                     uPosition
  18830.  
  18831.  prjob_status                       fsStatus
  18832.  
  18833.  prjob_status_string                pszStatus
  18834.  
  18835.  prjob_submitted                    ulSubmitted
  18836.  
  18837.  prjob_size                         ulSize
  18838.  
  18839.  LAN Manager 1.0                    LAN Manager 2.0
  18840.  prjob_info Element                 PRJINFO Element
  18841.  ────────────────────────────────────────────────────────────────────────────
  18842. 
  18843.  prjob_comment                      pszComment
  18844.  
  18845.  ────────────────────────────────────────────────────────────────────────────
  18846.  
  18847.  
  18848.  
  18849.  The new data structures are supported when they are directed to servers that
  18850.  run LAN Manager 1.0 software (down-level servers). New elements are given
  18851.  default values or values that indicate the element is not available, such as
  18852.  NULL.
  18853.  
  18854.  DosPrintJobSetInfo uses the level 1 data structure PRJINFO and the level 3
  18855.  data structure PRJINFO3. DosPrintJobEnum uses levels 0, 1, and 2.
  18856.  DosPrintJobGetInfo uses levels 0, 1, 2, and 3.
  18857.  
  18858.  DosPrintJobGetId returns the PRIDINFO data structure.
  18859.  
  18860.  
  18861.  Print Job Identification Number (level 0)
  18862.  
  18863.  At level 0, data is returned in this format:
  18864.  
  18865.    USHORT  uJobId;
  18866.  
  18867.  where
  18868.  
  18869.  uJobId
  18870.    Contains an unsigned short integer that specifies the identification
  18871.    number assigned to the print job when it was queued. The identification
  18872.    number is unique on a particular computer. A combination of the
  18873.    computername and uJobId is sufficient to uniquely identify a particular
  18874.    print job.
  18875.  
  18876.  
  18877.  Print Job Information (level 1)
  18878.  
  18879.  The PRJINFO data structure has this format:
  18880.  
  18881.    typedef struct _PRJINFO {
  18882.        USHORT  uJobId;
  18883.        CHAR    szUserName[UNLEN+1];
  18884.        CHAR    pad_1;
  18885.        CHAR    szNotifyName[CNLEN+1];
  18886.        CHAR    szDataType[DTLEN+1];
  18887.        PSZ     pszParms;
  18888.        USHORT  uPosition;
  18889.        USHORT  fsStatus;
  18890.        PSZ     pszStatus;
  18891.        ULONG   ulSubmitted;
  18892.        ULONG   ulSize;
  18893.        PSZ     pszComment;
  18894.    } PRJINFO;
  18895.  
  18896.  where
  18897.  
  18898.  uJobId
  18899.    Contains an unsigned short integer that specifies the identification
  18900.    number of the print job. The identification number is assigned by the
  18901.    print spooler.
  18902.  
  18903.  szUserName
  18904.    Contains an ASCIIZ string that specifies which user submitted the print
  18905.    job. The constant UNLEN is defined in the PMSPL.H header file. A null
  18906.    string indicates that the job was submitted from the local computer and
  18907.    the user did not log on.
  18908.  
  18909.  pad_1
  18910.    Aligns the next data structure element on a word boundary.
  18911.  
  18912.  szNotifyName
  18913.    Contains an ASCIIZ string that specifies the message alias that receives
  18914.    alert messages relating to the print job. The constant CNLEN is defined in
  18915.    the PMSPL.H header file. A null string is used for jobs submitted from the
  18916.    local computer.
  18917.  
  18918.  szDataType
  18919.    Contains an ASCIIZ string that specifies the datatype for the print job.
  18920.    This element corresponds to the pszDataType element of the MS OS/2
  18921.    DEVOPENSTRUC data structure that was supplied when the job was created.
  18922.    The DEVOPENSTRUC data structure is defined in the OS2DEV.H header file.
  18923.    The constant DTLEN is defined in the PMSPL.H header file.
  18924.  
  18925.  pszParms
  18926.    Points to an ASCIIZ string that contains a parameter string to pass to the
  18927.    spooler. The parameter string has this format:
  18928.  
  18929.    parm1=value1 parm2=value2 ...
  18930.  
  18931.    Note that a single space separates the parameter and value pairs.
  18932.  
  18933.  uPosition
  18934.    Contains an unsigned short integer that specifies the position of the
  18935.    print job in the printer queue. If uPosition is 1, the print job prints
  18936.    next.
  18937.  
  18938.  fsStatus
  18939.    Contains an unsigned short integer used as a status flag. Possible values
  18940.    are defined in the PMSPL.H header file.
  18941.  
  18942.    Bits 0-1 have the code PRJ_QSTATUS and the value 0x0003. This bit mask
  18943.    isolates the print job queued status bits, as follows:
  18944.  
  18945.  Bits  Code             Value  Meaning
  18946.  ────────────────────────────────────────────────────────────────────────────
  18947.  0-1   PRJ_QS_QUEUED    0      Print job is queued.
  18948.  
  18949.  0-1   PRJ_QS_PAUSED    1      Print job is paused.
  18950.  
  18951.  0-1   PRJ_QS_SPOOLING  2      Print job is spooling.
  18952.  
  18953.  0-1   PRJ_QS_PRINTING  3      Print job is printing
  18954.                                (bits 2-11 are valid).
  18955.  
  18956.  ────────────────────────────────────────────────────────────────────────────
  18957.  
  18958.  
  18959.    Bits 2-11 indicate the print job status. Bits 2-11 can be isolated using
  18960.    the constant PRJ_DEVSTATUS, which has the value 0x0FFC. Bit 15 signals
  18961.    whether an alert indicated that the print job was deleted. These are the
  18962.    meanings for individual bits:
  18963.  
  18964. ╓┌────┌────────────────┌───────┌─────────────────────────────────────────────╖
  18965.  Bit  Code             Value   Meaning
  18966.  ────────────────────────────────────────────────────────────────────────────
  18967.  2    PRJ_COMPLETE     0x0004  If 1, the print job is complete.
  18968.  
  18969.  3    PRJ_INTERV       0x0008  If 1, intervention is required.
  18970.  
  18971.  4    PRJ_ERROR        0x0010  If 1, an error occurred (pszStatus can
  18972.                                contain a comment explaining the error).
  18973.  
  18974.  5    PRJ_DESTOFFLINE  0x0020  If 1, the print destination is offline.
  18975.  
  18976.  6    PRJ_DESTPAUSED   0x0040  If 1, the print destination is paused.
  18977.  
  18978.  7    PRJ_NOTIFY       0x0080  If 1, an alert is raised.
  18979.  
  18980.  8    PRJ_DESTNOPAPER  0x0100  If 1, the print destination is out of paper.
  18981.  
  18982.  9    PRJ_DESTFORMCHG  0x0200  If 1, the printer is waiting for a form
  18983.                                change.
  18984.  
  18985.  10   PRJ_DESTCRTCHG   0x0400  If 1, the printer is waiting for a cartridge
  18986.  Bit  Code             Value   Meaning
  18987.  ────────────────────────────────────────────────────────────────────────────
  18988. 10   PRJ_DESTCRTCHG   0x0400  If 1, the printer is waiting for a cartridge
  18989.                                change.
  18990.  
  18991.  11   PRJ_DESTPENCHG   0x0800  If 1, the printer is waiting for a pen
  18992.                                change.
  18993.  
  18994.  15   PRJ_DELETED      0x8000  If 1, an alert indicates the job was deleted.
  18995.  
  18996.  ────────────────────────────────────────────────────────────────────────────
  18997.  
  18998.  
  18999.  
  19000.  pszStatus
  19001.    Points to an ASCIIZ string that contains a comment about the status of the
  19002.    print job posted by the queue's print processor. A null pointer or null
  19003.    string indicates that no information was posted. This element contains
  19004.    valid data only while the job is printing and an error occurs.
  19005.  
  19006.  ulSubmitted
  19007.    Contains an unsigned long integer that specifies the time the user
  19008.    submitted the print job. The time is stored in seconds elapsed since
  19009.    00:00:00, January 1, 1970.
  19010.  
  19011.  ulSize
  19012.    Contains an unsigned long integer that specifies the size (in bytes) of
  19013.    the print job.
  19014.  
  19015.  pszComment
  19016.    Points to an ASCIIZ string that contains a comment about the print job.
  19017.    This string can have as many as MAXCOMMENTSZ bytes. The constant
  19018.    MAXCOMMENTSZ is defined in the PMSPL.H header file.
  19019.  
  19020.  
  19021.  Print Job Information (level 2)
  19022.  
  19023.  The PRJINFO2 data structure has this format:
  19024.  
  19025.    typedef struct _PRJINFO2 {
  19026.        USHORT  uJobId;
  19027.        USHORT  uPriority;
  19028.        PSZ     pszUserName;
  19029.        USHORT  uPosition;
  19030.        USHORT  fsStatus;
  19031.        ULONG   ulSubmitted;
  19032.        ULONG   ulSize;
  19033.        PSZ     pszComment;
  19034.        PSZ     pszDocument;
  19035.    } PRJINFO2;
  19036.  
  19037.  where
  19038.  
  19039.  uJobId
  19040.    Contains an unsigned short integer that specifies the identification
  19041.    number of the print job. The identification number is assigned by the
  19042.    print spooler.
  19043.  
  19044.  uPriority
  19045.    Contains an unsigned short integer that specifies the priority of the
  19046.    print job. The range is 1 (lowest priority) through 99 (highest priority).
  19047.    If the constant PRJ_NO_PRIORITY is used, a default job priority is
  19048.    computed based on the queue priority. The default job priority is defined
  19049.    as follows:
  19050.  
  19051.    default job priority = 100 - (10 * queue priority)
  19052.  
  19053.    The constant PRJ_NO_PRIORITY is defined in the PMSPL.H header file. The
  19054.    job priority determines the order of jobs in the queue. If multiple queues
  19055.    print to the same printer, the spooler compares the priorities of the jobs
  19056.    at the front of the queues and schedules the job with the highest priority
  19057.    first. If job priorities are equal, the oldest job is scheduled.
  19058.  
  19059.  pszUserName
  19060.    Points to an ASCIIZ string that specifies the name of the user who
  19061.    submitted the print job.
  19062.  
  19063.  uPosition through pszComment
  19064.    Are the same as the corresponding elements of the PRJINFO data structure.
  19065.    For a complete description, see the preceding section.
  19066.  
  19067.  pszDocument
  19068.    Points to an ASCIIZ string that contains the document name of the print
  19069.    job. This string can have as many as CCHMAXPATH bytes. The constant
  19070.    CCHMAXPATH is defined in the MS OS/2 header file BSEDOS.H.
  19071.  
  19072.  
  19073.  Print Job Information (level 3)
  19074.  
  19075.  The PRJINFO3 data structure has this format:
  19076.  
  19077.    typedef struct _PRJINFO3 {
  19078.        USHORT     uJobId;
  19079.        USHORT     uPriority;
  19080.        PSZ        pszUserName;
  19081.        USHORT     uPosition;
  19082.        USHORT     fsStatus;
  19083.        ULONG      ulSubmitted;
  19084.        ULONG      ulSize;
  19085.        PSZ        pszComment;
  19086.        PSZ        pszDocument;
  19087.        PSZ        pszNotifyName;
  19088.        PSZ        pszDataType;
  19089.        PSZ        pszParms;
  19090.        PSZ        pszStatus;
  19091.        PSZ        pszQueue;
  19092.        PSZ        pszQProcName;
  19093.        PSZ        pszQProcParms;
  19094.        PSZ        pszDriverName;
  19095.        PDRIVDATA  pDriverData;
  19096.        PSZ        pszPrinterName;
  19097.    } PRJINFO3;
  19098.  
  19099.  where
  19100.  
  19101.  uJobId through pszDocument
  19102.    Are the same as the corresponding elements of the PRJINFO2 data structure.
  19103.    For a complete description, see the preceding section.
  19104.  
  19105.  pszNotifyName
  19106.    Points to an ASCIIZ string that contains the message alias that receives
  19107.    alert messages related to the print job. A null string indicates the job
  19108.    was submitted from the local computer.
  19109.  
  19110.  pszDataType
  19111.    Points to an ASCIIZ string that contains the datatype for the print job.
  19112.    This field corresponds to the pszDataType field of the MS OS/2
  19113.    DEVOPENSTRUC data structure supplied when the job was created. The
  19114.    DEVOPENSTRUC data structure is defined in the OS2DEV.H header file.
  19115.  
  19116.  pszParms
  19117.    Points to an ASCIIZ string that contains a parameter string to pass to the
  19118.    printer queue processor. The parameter string has this format:
  19119.  
  19120.    parms=value
  19121.  
  19122.  pszStatus
  19123.    Points to an ASCIIZ string that contains a comment about the status of the
  19124.    print job posted by the queue's print processor. A null pointer or null
  19125.    string indicates that no information was posted. This element contains
  19126.    valid data only while the job is printing and an error occurs.
  19127.  
  19128.  pszQueue
  19129.    Points to an ASCIIZ string that contains the name of the printer queue
  19130.    that contains the print job.
  19131.  
  19132.  pszQProcName
  19133.    Points to an ASCIIZ string that contains the name of the queue print
  19134.    processor.
  19135.  
  19136.  pszQProcParms
  19137.    Points to an ASCIIZ string that contains parameters passed to the queue
  19138.    print processor. The parameter string has the following format:
  19139.  
  19140.    parm1=value1 parm2=value2 ...
  19141.  
  19142.    Note that a single space separates the parameter and value pairs. An
  19143.    example  parameter, CPY=n, specifies that n copies of the document will be
  19144.    printed.
  19145.  
  19146.  pszDriverName
  19147.    Points to an ASCIIZ string that contains the name of the printer device
  19148.    driver.
  19149.  
  19150.  pDriverData
  19151.    Points to the MS OS/2 DRIVDATA data structure for the default driver. This
  19152.    data is specific to the device driver and is used only if pszDriverName is
  19153.    not null. The MS OS/2 DRIVDATA data structure is defined in the OS2DEF.H
  19154.    header file.
  19155.  
  19156.  pszPrinterName
  19157.    Points to an ASCIIZ string that contains the name of the printer on which
  19158.    the job is printing. If the job is not printing, pszPrinterName contains a
  19159.    null string or a null pointer.
  19160.  
  19161.  
  19162.  Print Job Identification Number
  19163.  
  19164.  DosPrintJobGetId returns the PRIDINFO data structure:
  19165.  
  19166.    typedef struct _PRIDINFO {
  19167.        USHORT  uJobId;
  19168.        CHAR    szServer[CNLEN+1];
  19169.        CHAR    szQName[QNLEN+1];
  19170.        CHAR    pad_1;
  19171.    } PRIDINFO;
  19172.  
  19173.  where
  19174.  
  19175.  uJobId
  19176.    Contains an unsigned short integer that specifies the identification
  19177.    number assigned to the print job when it was queued. The identification
  19178.    number is unique on a particular computer. A combination of the
  19179.    computername and uJobId is sufficient to uniquely identify a particular
  19180.    print job.
  19181.  
  19182.  szServer
  19183.    Specifies an ASCIIZ string that contains the name of the computer handling
  19184.    the print job. The constant CNLEN is defined in the PMSPL.H header file.
  19185.    If the name has more than CNLEN bytes, a null string is returned.
  19186.  
  19187.  szQName
  19188.    Specifies an ASCIIZ string that contains the name of the printer queue for
  19189.    the job. The constant QNLEN is defined in the PMSPL.H header file. If the
  19190.    name has more than QNLEN bytes, a null string is returned.
  19191.  
  19192.  pad_1
  19193.    Aligns the next data structure element on a word boundary.
  19194.  
  19195.  
  19196.  DosPrintJobContinue
  19197.  ────────────────────────────────────────────────────────────────────────────
  19198.  
  19199.  DosPrintJobContinue allows a paused print job to resume printing.
  19200.  
  19201.  
  19202.  Operating Systems Supported
  19203.  
  19204.  
  19205.    ■   MS OS/2 version 1.2, local and remote
  19206.  
  19207.    ■   MS OS/2 version 1.1, remote only
  19208.  
  19209.    ■   MS-DOS, remote only
  19210.  
  19211.  
  19212.  
  19213.  Privilege Level
  19214.  
  19215.  Admin privilege or print operator privilege is required to successfully
  19216.  execute DosPrintJobContinue on a remote server or on a computer that has
  19217.  local security enabled, except when users are continuing their own jobs. In
  19218.  this case, no special privilege is required.
  19219.  
  19220.  
  19221.  Syntax
  19222.  
  19223.    #define INCL_BASE
  19224.    #include <os2.h>
  19225.  
  19226.    #include <pmspl.h>
  19227.  
  19228.    #define INCL_NETERRORS
  19229.    #include <lan.h>
  19230.  
  19231.    SPLERR SPLENTRY
  19232.    DosPrintJobContinue (PSZ     pszServer,
  19233.                         USHORT  uJobId
  19234.                        );
  19235.  
  19236.  where
  19237.  
  19238.  pszServer
  19239.    Points to an ASCIIZ string that contains the name of the server on which
  19240.    to execute DosPrintJobContinue. A null pointer or null string specifies
  19241.    the local computer.
  19242.  
  19243.  uJobId
  19244.    Contains an unsigned short integer that specifies the identification
  19245.    number of the print job.
  19246.  
  19247.  Return Codes
  19248.  
  19249. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  19250.  Code                              Value   Meaning
  19251.  ────────────────────────────────────────────────────────────────────────────
  19252.  NERR_Success                      0       The function encountered no
  19253.                                            errors.
  19254.  
  19255.  ERROR_ACCESS_DENIED               5       The user has insufficient
  19256.                                            privilege for this operation.
  19257.  
  19258.  ERROR_BAD_NETPATH                 53      The network path was not found.
  19259.  Code                              Value   Meaning
  19260.  ────────────────────────────────────────────────────────────────────────────
  19261. ERROR_BAD_NETPATH                 53      The network path was not found.
  19262.  
  19263.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  19264.  
  19265.  NERR_RemoteOnly                   2106    This operation can be performed
  19266.                                            only on a server.
  19267.  
  19268.  NERR_BadTransactConfig            2141    The server is not configured for
  19269.                                            this transaction: IPC$ is not
  19270.                                            shared.
  19271.  
  19272.  NERR_JobNotFound                  2151    No print job matches the print
  19273.                                            job identification number typed.
  19274.  
  19275.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  19276.  
  19277.  NERR_JobInvalidState              2164    This operation cannot be
  19278.                                            performed on the print job in
  19279.                                            its current state.
  19280.  Code                              Value   Meaning
  19281.  ────────────────────────────────────────────────────────────────────────────
  19282.                                           its current state.
  19283.  
  19284.  NERR_InvalidComputer              2351    The specified computername is
  19285.                                            invalid.
  19286.  
  19287.  ────────────────────────────────────────────────────────────────────────────
  19288.  
  19289.  
  19290.  
  19291.  
  19292.  Remarks
  19293.  
  19294.  DosPrintJobContinue cannot continue a job that is already printing. Use
  19295.  DosPrintDestControl instead.
  19296.  
  19297.  See Also
  19298.  
  19299.  For information about             See
  19300.  ────────────────────────────────────────────────────────────────────────────
  19301.  Obtaining the identification      DosPrintJobGetId
  19302.  number of a print job
  19303.  
  19304.  Pausing a print job               DosPrintJobPause
  19305.  
  19306.  Retrieving information about a    DosPrintJobGetInfo
  19307.  particular print job
  19308.  
  19309.  
  19310.  DosPrintJobDel
  19311.  ────────────────────────────────────────────────────────────────────────────
  19312.  
  19313.  DosPrintJobDel deletes a print job from a printer queue.
  19314.  
  19315.  
  19316.  Operating Systems Supported
  19317.  
  19318.  
  19319.    ■   MS OS/2 version 1.2, local and remote
  19320.  
  19321.    ■   MS OS/2 version 1.1, remote only
  19322.  
  19323.    ■   MS-DOS, remote only
  19324.  
  19325.  
  19326.  
  19327.  Privilege Level
  19328.  
  19329.  Admin privilege or print operator privilege is required to successfully
  19330.  execute DosPrintJobDel on a remote server or on a computer that has local
  19331.  security enabled, except when users are deleting their own jobs. In this
  19332.  case, no special privilege is required.
  19333.  
  19334.  
  19335.  Syntax
  19336.  
  19337.    #define INCL_BASE
  19338.    #include <os2.h>
  19339.  
  19340.    #include <pmspl.h>
  19341.  
  19342.    #define INCL_NETERRORS
  19343.    #include <lan.h>
  19344.  
  19345.    SPLERR SPLENTRY
  19346.    DosPrintJobDel (PSZ     pszServer,
  19347.                    USHORT  uJobId
  19348.                   );
  19349.  
  19350.  where
  19351.  
  19352.  pszServer
  19353.    Points to an ASCIIZ string that contains the name of the server on which
  19354.    to execute DosPrintJobDel. A null pointer or null string specifies the
  19355.    local computer.
  19356.  
  19357.  uJobId
  19358.    Contains an unsigned short integer that specifies the identification
  19359.    number of the print job.
  19360.  
  19361.  Return Codes
  19362.  
  19363. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  19364.  Code                              Value   Meaning
  19365.  ────────────────────────────────────────────────────────────────────────────
  19366.  NERR_Success                      0       The function encountered no
  19367.                                            errors.
  19368.  
  19369.  ERROR_ACCESS_DENIED               5       The user has insufficient
  19370.                                            privilege for this operation.
  19371.  
  19372.  ERROR_BAD_NETPATH                 53      The network path was not found.
  19373.  
  19374.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  19375.  
  19376.  NERR_RemoteOnly                   2106    This operation can be performed
  19377.                                            only on a server.
  19378.  
  19379.  NERR_BadTransactConfig            2141    The server is not configured for
  19380.                                            this transaction: IPC$ is not
  19381.                                            shared.
  19382.  
  19383.  NERR_JobNotFound                  2151    No print job matches the print
  19384.                                            job identification number typed.
  19385.  Code                              Value   Meaning
  19386.  ────────────────────────────────────────────────────────────────────────────
  19387.                                           job identification number typed.
  19388.  
  19389.  NERR_ProcNoRespond                2160    The print processor is not
  19390.                                            responding.
  19391.  
  19392.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  19393.  
  19394.  NERR_InvalidComputer              2351    The specified computername is
  19395.                                            invalid.
  19396.  
  19397.  ────────────────────────────────────────────────────────────────────────────
  19398.  
  19399.  
  19400.  
  19401.  See Also
  19402.  
  19403.  For information about             See
  19404.  ────────────────────────────────────────────────────────────────────────────
  19405.  Listing the print jobs in a       DosPrintJobEnum
  19406.  printer queue
  19407.  
  19408.  Obtaining the identification      DosPrintJobGetId
  19409.  number of a print job
  19410.  
  19411.  
  19412.  
  19413.  
  19414.  DosPrintJobEnum
  19415.  ────────────────────────────────────────────────────────────────────────────
  19416.  
  19417.  DosPrintJobEnum lists print jobs in the specified printer queue.
  19418.  
  19419.  
  19420.  Operating Systems Supported
  19421.  
  19422.  
  19423.    ■   MS OS/2 version 1.2, local and remote
  19424.  
  19425.    ■   MS OS/2 version 1.1, remote only
  19426.  
  19427.    ■   MS-DOS, remote only
  19428.  
  19429.  
  19430.  
  19431.  Privilege Level
  19432.  
  19433.  No special privilege level is required to successfully execute
  19434.  DosPrintJobEnum.
  19435.  
  19436.  
  19437.  Syntax
  19438.  
  19439.    #define INCL_BASE
  19440.    #include <os2.h>
  19441.  
  19442.    #include <pmspl.h>
  19443.  
  19444.    #define INCL_NETERRORS
  19445.    #include <lan.h>
  19446.  
  19447.    SPLERR SPLENTRY
  19448.    DosPrintJobEnum (PSZ      pszServer,
  19449.                     PSZ      pszQueueName,
  19450.                     USHORT   uLevel,
  19451.                     PBYTE    pbBuf,
  19452.                     USHORT   cbBuf,
  19453.                     PUSHORT  pcReturned,
  19454.                     PUSHORT  pcTotal
  19455.                    );
  19456.  
  19457.  where
  19458.  
  19459.  pszServer
  19460.    Points to an ASCIIZ string that contains the name of the server on which
  19461.    to execute DosPrintJobEnum. A null pointer or null string specifies the
  19462.    local computer.
  19463.  
  19464.  pszQueueName
  19465.    Points to an ASCIIZ string that specifies which printer queue to monitor.
  19466.  
  19467.  uLevel
  19468.    Specifies the level of detail (0, 1, or 2) requested.
  19469.  
  19470.  pbBuf
  19471.    Points to the buffer in which to store the returned data.
  19472.  
  19473.  cbBuf
  19474.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  19475.  
  19476.  pcReturned
  19477.    Points to an unsigned short integer that specifies the number of entries
  19478.    returned to pbBuf. This count is valid only if DosPrintJobEnum returns
  19479.    NERR_Success or ERROR_MORE_DATA.
  19480.  
  19481.  pcTotal
  19482.    Points to an unsigned short integer that specifies the number of entries
  19483.    available. This count is valid only if DosPrintJobEnum returns
  19484.    NERR_Success or ERROR_MORE_DATA.
  19485.  
  19486.  Return Codes
  19487.  
  19488. ╓┌──────────────────────┌───────┌────────────────────────────────────────────╖
  19489.  Code                   Value   Meaning
  19490.  Code                   Value   Meaning
  19491.  ────────────────────────────────────────────────────────────────────────────
  19492.  NERR_Success           0       The function encountered no errors.
  19493.  
  19494.  ERROR_BAD_NETPATH      53      The network path was not found.
  19495.  
  19496.  ERROR_INVALID_LEVEL    124     The level for information retrieval or
  19497.                                 setting is invalid.
  19498.  
  19499.  ERROR_MORE_DATA        234     Additional data is available.
  19500.  
  19501.  NERR_QNotFound         2150    The queue name specified is invalid.
  19502.  
  19503.  NERR_SpoolerNotLoaded  2161    The spooler is not started.
  19504.  
  19505.  NERR_InvalidComputer   2351    The specified computername is invalid.
  19506.  
  19507.  ────────────────────────────────────────────────────────────────────────────
  19508.  
  19509.  
  19510.  
  19511.  
  19512.  Remarks
  19513.  
  19514.  Level 0 and level 1 calls are compatible with existing LAN Manager 1.0
  19515.  applications. Note that for LAN Manager 2.0 three new print destination
  19516.  status bits (9, 10, and 11) are added to the fsStatus element of the PRJINFO
  19517.  data structure. Existing applications that do not examine these new status
  19518.  bits may not accurately report the status.
  19519.  
  19520.  See Also
  19521.  
  19522.  For information about             See
  19523.  ────────────────────────────────────────────────────────────────────────────
  19524.  Modifying instructions for a      DosPrintJobSetInfo
  19525.  submitted print job
  19526.  
  19527.  Retrieving information about a    DosPrintJobGetInfo
  19528.  particular print job
  19529.  
  19530.  
  19531.  DosPrintJobGetId
  19532.  ────────────────────────────────────────────────────────────────────────────
  19533.  
  19534.  DosPrintJobGetId retrieves information about a remote print job.
  19535.  
  19536.  
  19537.  Operating Systems Supported
  19538.  
  19539.  
  19540.    ■   MS OS/2 version 1.2, local only with handle to remote queue name
  19541.  
  19542.    ■   MS OS/2 version 1.1, local only with handle to remote queue name
  19543.  
  19544.    ■   MS-DOS, local only with handle to remote queue name
  19545.  
  19546.  
  19547.  
  19548.  Privilege Level
  19549.  
  19550.  DosPrintJobGetId is a handle-based function. If you have privilege to open
  19551.  the file to get the handle, you do not need special privilege to call
  19552.  DosPrintJobGetId.
  19553.  
  19554.  
  19555.  Syntax
  19556.  
  19557.    #define INCL_BASE
  19558.    #include <os2.h>
  19559.  
  19560.    #include <pmspl.h>
  19561.  
  19562.    #define INCL_NETERRORS
  19563.    #include <lan.h>
  19564.  
  19565.    SPLERR SPLENTRY
  19566.    DosPrintJobGetId (HFILE      hFile,
  19567.                      PPRIDINFO  pInfo,
  19568.                      USHORT     cbInfo
  19569.                     );
  19570.  
  19571.  where
  19572.  
  19573.  hFile
  19574.    Specifies the handle of a redirected print device.
  19575.  
  19576.  pInfo
  19577.    Points to the buffer in which to store the returned data. On a successful
  19578.    return, the buffer contains the PRIDINFO data structure.
  19579.  
  19580.  cbInfo
  19581.    Specifies the size (in bytes) of the data returned in the buffer pointed
  19582.    to by pInfo.
  19583.  
  19584.  
  19585.  Return Codes
  19586.  
  19587. ╓┌──────────────────────┌───────┌────────────────────────────────────────────╖
  19588.  Code                   Value   Meaning
  19589.  ────────────────────────────────────────────────────────────────────────────
  19590.  NERR_Success           0       The function encountered no errors.
  19591.  
  19592.  ERROR_ACCESS_DENIED    5       The user has insufficient privilege for
  19593.                                 this operation.
  19594.  
  19595.  Code                   Value   Meaning
  19596.  ────────────────────────────────────────────────────────────────────────────
  19597. 
  19598.  ERROR_INVALID_HANDLE   6       The handle specified is invalid.
  19599.  
  19600.  ERROR_NOT_SUPPORTED    50      This network request is not supported.
  19601.  
  19602.  NERR_DevNotRedirected  2107    The devicename is not assigned to a shared
  19603.                                 resource.
  19604.  
  19605.  NERR_BufTooSmall       2123    The supplied buffer is too small.
  19606.  
  19607.  ────────────────────────────────────────────────────────────────────────────
  19608.  
  19609.  
  19610.  
  19611.  
  19612.  Remarks
  19613.  
  19614.  DosPrintJobGetId is handle-based. The handle must be a valid handle to a
  19615.  remote spooled queue. The handle cannot be a handle to a local job.
  19616.  
  19617.  If LAN Manager is not installed, DosPrintJobGetId returns
  19618.  ERROR_NOT_SUPPORTED.
  19619.  
  19620.  See Also
  19621.  
  19622.  For information about             See
  19623.  ────────────────────────────────────────────────────────────────────────────
  19624.  Listing the print jobs in a       DosPrintJobEnum
  19625.  printer queue
  19626.  
  19627.  Modifying the instructions for a  DosPrintJobSetInfo
  19628.  submitted print job
  19629.  
  19630.  Retrieving information about a    DosPrintJobGetInfo
  19631.  particular print job
  19632.  
  19633.  
  19634.  DosPrintJobGetInfo
  19635.  ────────────────────────────────────────────────────────────────────────────
  19636.  
  19637.  DosPrintJobGetInfo retrieves information about a particular print job.
  19638.  
  19639.  
  19640.  Operating Systems Supported
  19641.  
  19642.  
  19643.    ■   MS OS/2 version 1.2, local and remote
  19644.  
  19645.    ■   MS OS/2 version 1.1, remote only
  19646.  
  19647.    ■   MS-DOS, remote only
  19648.  
  19649.  
  19650.  
  19651.  Privilege Level
  19652.  
  19653.  No special privilege is required to successfully execute DosPrintJobGetInfo.
  19654.  
  19655.  
  19656.  
  19657.  Syntax
  19658.  
  19659.    #define INCL_BASE
  19660.    #include <os2.h>
  19661.  
  19662.    #include <pmspl.h>
  19663.  
  19664.    #define INCL_NETERRORS
  19665.    #include <lan.h>
  19666.  
  19667.    SPLERR SPLENTRY
  19668.    DosPrintJobGetInfo (PSZ      pszServer,
  19669.                        USHORT   uJobId,
  19670.                        USHORT   uLevel,
  19671.                        PBYTE    pbBuf,
  19672.                        USHORT   cbBuf,
  19673.                        PUSHORT  pcbNeeded
  19674.                       );
  19675.  
  19676.  where
  19677.  
  19678.  pszServer
  19679.    Points to an ASCIIZ string that contains the name of the server on which
  19680.    to execute DosPrintJobGetInfo. A null pointer or null string specifies the
  19681.    local computer.
  19682.  
  19683.  uJobId
  19684.    Contains an unsigned short integer that specifies the identification
  19685.    number of the print job.
  19686.  
  19687.  uLevel
  19688.    Specifies the level of detail (0, 1, 2, or 3) requested.
  19689.  
  19690.  pbBuf
  19691.    Points to the buffer in which data is returned.
  19692.  
  19693.  cbBuf
  19694.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  19695.  
  19696.  pcbNeeded
  19697.    Points to an unsigned short integer that specifies the number of bytes of
  19698.    information available. This count is valid only if DosPrintJobGetInfo
  19699.    returns NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  19700.  
  19701.  Return Codes
  19702.  
  19703. ╓┌──────────────────────┌───────┌────────────────────────────────────────────╖
  19704.  Code                   Value   Meaning
  19705.  ────────────────────────────────────────────────────────────────────────────
  19706.  NERR_Success           0       The function encountered no errors.
  19707.  
  19708.  ERROR_BAD_NETPATH      53      The network path was not found.
  19709.  
  19710.  ERROR_INVALID_LEVEL    124     The level for information retrieval or
  19711.                                 setting is invalid.
  19712.  
  19713.  ERROR_MORE_DATA        234     Additional data is available.
  19714.  
  19715.  NERR_RemoteOnly        2106    This operation can be performed only on a
  19716.                                 server.
  19717.  
  19718.  NERR_BufTooSmall       2123    The supplied buffer is too small.
  19719.  
  19720.  NERR_JobNotFound       2151    No print job matches the print job
  19721.  Code                   Value   Meaning
  19722.  ────────────────────────────────────────────────────────────────────────────
  19723. NERR_JobNotFound       2151    No print job matches the print job
  19724.                                 identification number typed.
  19725.  
  19726.  NERR_SpoolerNotLoaded  2161    The spooler is not started.
  19727.  
  19728.  NERR_InvalidComputer   2351    The specified computername is invalid.
  19729.  
  19730.  ────────────────────────────────────────────────────────────────────────────
  19731.  
  19732.  
  19733.  
  19734.  See Also
  19735.  
  19736.  For information about             See
  19737.  ────────────────────────────────────────────────────────────────────────────
  19738.  Listing the print jobs in a       DosPrintJobEnum
  19739.  printer queue
  19740.  
  19741.  Modifying the instructions for a  DosPrintJobSetInfo
  19742.  submitted print job
  19743.  
  19744.  Obtaining the identification      DosPrintJobGetId
  19745.  number of a print job
  19746.  
  19747.  
  19748.  DosPrintJobPause
  19749.  ────────────────────────────────────────────────────────────────────────────
  19750.  
  19751.  DosPrintJobPause pauses a print job in a printer queue.
  19752.  
  19753.  
  19754.  Operating Systems Supported
  19755.  
  19756.  
  19757.    ■   MS OS/2 version 1.2, local and remote
  19758.  
  19759.    ■   MS OS/2 version 1.1, remote only
  19760.  
  19761.    ■   MS-DOS, remote only
  19762.  
  19763.  
  19764.  
  19765.  Privilege Level
  19766.  
  19767.  Admin privilege or print operator privilege is required to successfully
  19768.  execute DosPrintJobPause on a remote server or on a computer that has local
  19769.  security enabled, except when users are pausing their own jobs. In this
  19770.  case, no special privilege is required.
  19771.  
  19772.  
  19773.  Syntax
  19774.  
  19775.    #define INCL_BASE
  19776.    #include <os2.h>
  19777.  
  19778.    #include <pmspl.h>
  19779.  
  19780.    #define INCL_NETERRORS
  19781.    #include <lan.h>
  19782.  
  19783.    SPLERR SPLENTRY
  19784.    DosPrintJobPause (PSZ     pszServer,
  19785.                      USHORT  uJobId
  19786.                     );
  19787.  
  19788.  where
  19789.  
  19790.  pszServer
  19791.    Points to an ASCIIZ string that contains the name of the server on which
  19792.    to execute DosPrintJobPause. A null pointer or null string specifies the
  19793.    local computer.
  19794.  
  19795.  uJobId
  19796.    Contains an unsigned short integer that specifies the identification
  19797.    number of the print job.
  19798.  
  19799.  Return Codes
  19800.  
  19801. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  19802.  Code                              Value   Meaning
  19803.  ────────────────────────────────────────────────────────────────────────────
  19804.  NERR_Success                      0       The function encountered no
  19805.  Code                              Value   Meaning
  19806.  ────────────────────────────────────────────────────────────────────────────
  19807.  NERR_Success                      0       The function encountered no
  19808.                                            errors.
  19809.  
  19810.  ERROR_ACCESS_DENIED               5       The user has insufficient
  19811.                                            privilege for this operation.
  19812.  
  19813.  ERROR_BAD_NETPATH                 53      The network path was not found.
  19814.  
  19815.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  19816.  
  19817.  NERR_RemoteOnly                   2106    This operation can be performed
  19818.                                            only on a server.
  19819.  
  19820.  NERR_BadTransactConfig            2141    The server is not configured for
  19821.                                            this transaction: IPC$ is not
  19822.                                            shared.
  19823.  
  19824.  NERR_JobNotFound                  2151    No print job matches the print
  19825.                                            job identification number typed.
  19826.  Code                              Value   Meaning
  19827.  ────────────────────────────────────────────────────────────────────────────
  19828.                                           job identification number typed.
  19829.  
  19830.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  19831.  
  19832.  NERR_JobInvalidState              2164    This operation cannot be
  19833.                                            performed on the print job in
  19834.                                            its current state.
  19835.  
  19836.  NERR_InvalidComputer              2351    The specified computername is
  19837.                                            invalid.
  19838.  
  19839.  ────────────────────────────────────────────────────────────────────────────
  19840.  
  19841.  
  19842.  
  19843.  
  19844.  Remarks
  19845.  
  19846.  DosPrintJobPause cannot pause a job that is already printing. Use
  19847.  DosPrintDestControl instead. If the print job is printing when the
  19848.  application calls DosPrintJobPause, the error code NERR_JobInvalidState is
  19849.  returned.
  19850.  
  19851.  See Also
  19852.  
  19853.  For information about             See
  19854.  ────────────────────────────────────────────────────────────────────────────
  19855.  Continuing a paused print job     DosPrintJobContinue
  19856.  
  19857.  Obtaining the identification      DosPrintJobGetId
  19858.  number of a print job
  19859.  
  19860.  Retrieving information about a    DosPrintJobGetInfo
  19861.  particular print job
  19862.  
  19863.  
  19864.  DosPrintJobSetInfo
  19865.  ────────────────────────────────────────────────────────────────────────────
  19866.  
  19867.  DosPrintJobSetInfo modifies the instructions for a submitted print job.
  19868.  
  19869.  
  19870.  Operating Systems Supported
  19871.  
  19872.  
  19873.    ■   MS OS/2 version 1.2, local and remote
  19874.  
  19875.    ■   MS OS/2 version 1.1, remote only
  19876.  
  19877.    ■   MS-DOS, remote only
  19878.  
  19879.  
  19880.  
  19881.  Privilege Level
  19882.  
  19883.  Admin privilege or print operator privilege is required to successfully
  19884.  execute DosPrintJobSetInfo on a remote server or on a computer that has
  19885.  local security enabled, except when users are setting information for their
  19886.  own job. In this case, the only restriction is that users cannot move their
  19887.  jobs forward in the queue.
  19888.  
  19889.  
  19890.  Syntax
  19891.  
  19892.    #define INCL_BASE
  19893.    #include <os2.h>
  19894.  
  19895.    #include <pmspl.h>
  19896.  
  19897.    #define INCL_NETERRORS
  19898.    #include <lan.h>
  19899.  
  19900.    SPLERR SPLENTRY
  19901.    DosPrintJobSetInfo (PSZ     pszServer,
  19902.                        USHORT  uJobId,
  19903.                        USHORT  uLevel,
  19904.                        PSZ     pbBuf,
  19905.                        USHORT  cbBuf,
  19906.                        USHORT  uParmNum
  19907.                       );
  19908.  
  19909.  where
  19910.  
  19911.  pszServer
  19912.    Points to an ASCIIZ string that contains the name of the server on which
  19913.    to execute DosPrintJobSetInfo. A null pointer or null string specifies the
  19914.    local computer.
  19915.  
  19916.  uJobId
  19917.    Contains an unsigned short integer that specifies the identification
  19918.    number of the print job.
  19919.  
  19920.  uLevel
  19921.    Specifies the level of detail (1 or 3) provided.
  19922.  
  19923.  pbBuf
  19924.    Points to a buffer that contains the data to be set.
  19925.  
  19926.  cbBuf
  19927.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  19928.  
  19929.  uParmNum
  19930.    Specifies whether to set one or all elements of the print job data
  19931.    structure. If uParmNum is PARMNUM_ALL, pbBuf must point to the print job
  19932.    data structure that corresponds to the uLevel parameter (level 1 indicates
  19933.    PRJINFO, level 3 indicates PRJINFO3). If uParmNum is any other defined
  19934.    value, only one element of the print job information is changed, and pbBuf
  19935.    must point to a valid value for that element.
  19936.  
  19937.    Not all elements can be set. Only those elements that have a specific
  19938.    PARMNUM constant value defined can be set. The PMSPL.H and NETCONS.H
  19939.    header files define these possible values for uParmNum:
  19940.  
  19941. ╓┌───────────────────────┌──────┌────────────────────────────────────────────╖
  19942.                                 Element of PRJINFO and PRJINFO3
  19943.  Code                    Value
  19944.  ────────────────────────────────────────────────────────────────────────────
  19945.  PARMNUM_ALL             0      All elements.
  19946.  
  19947.  PRJ_NOTIFYNAME_PARMNUM  3      szNotifyName or pszNotifyName
  19948.  
  19949.  PRJ_DATATYPE_PARMNUM    4      szDataType or pszDataType
  19950.  
  19951.  PRJ_PARMS_PARMNUM       5      pszParms
  19952.                                 Element of PRJINFO and PRJINFO3
  19953.  Code                    Value
  19954.  ────────────────────────────────────────────────────────────────────────────
  19955. PRJ_PARMS_PARMNUM       5      pszParms
  19956.  
  19957.  PRJ_POSITION_PARMNUM    6      uPosition
  19958.  
  19959.  PRJ_COMMENT_PARMNUM     11     pszComment
  19960.  
  19961.  PRJ_DOCUMENT_PARMNUM    12     pszDocument (level 3 only)
  19962.  
  19963.  PRJ_PRIORITY_PARMNUM    14     uPriority (level 3 only)
  19964.  
  19965.  PRJ_PROCPARMS_PARMNUM   16     pszQProcParms (level 3 only)
  19966.  
  19967.  PRJ_DRIVERDATA_PARMNUM  18     pDriverData (level 3 only)
  19968.  
  19969.  ────────────────────────────────────────────────────────────────────────────
  19970.  
  19971.  
  19972.  
  19973.    The uPosition element can have the following values:
  19974.  
  19975.  Value                             Position Change
  19976.  ────────────────────────────────────────────────────────────────────────────
  19977.  0                                 No change.
  19978.  
  19979.  1                                 Moves to first place.
  19980.  
  19981.  n > 1                             Assumes position n in queue. If n is
  19982.                                    greater than the number of jobs in the
  19983.                                    queue, the job moves to the end of the
  19984.                                    queue.
  19985.  
  19986.  ────────────────────────────────────────────────────────────────────────────
  19987.  
  19988.  
  19989.  Return Codes
  19990.  
  19991. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  19992.  Code                              Value   Meaning
  19993.  ────────────────────────────────────────────────────────────────────────────
  19994.  Code                              Value   Meaning
  19995.  ────────────────────────────────────────────────────────────────────────────
  19996.  NERR_Success                      0       The function encountered no
  19997.                                            errors.
  19998.  
  19999.  ERROR_ACCESS_DENIED               5       The user has insufficient
  20000.                                            privilege for this operation.
  20001.  
  20002.  ERROR_BAD_NETPATH                 53      The network path was not found.
  20003.  
  20004.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  20005.  
  20006.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  20007.                                            invalid.
  20008.  
  20009.  ERROR_INVALID_LEVEL               124     The level for information
  20010.                                            retrieval or setting is invalid.
  20011.  
  20012.  NERR_RemoteOnly                   2106    This operation can be performed
  20013.                                            only on a server.
  20014.  
  20015.  Code                              Value   Meaning
  20016.  ────────────────────────────────────────────────────────────────────────────
  20017. 
  20018.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  20019.  
  20020.  NERR_BadTransactConfig            2141    The server is not configured for
  20021.                                            this transaction: IPC$ is not
  20022.                                            shared.
  20023.  
  20024.  NERR_JobNotFound                  2151    No print job matches the print
  20025.                                            job identification number typed.
  20026.  
  20027.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  20028.  
  20029.  NERR_JobInvalidState              2164    This operation cannot be
  20030.                                            performed on the print job in
  20031.                                            its current state.
  20032.  
  20033.  NERR_SpoolNoMemory                2165    A spooler memory allocation
  20034.                                            failure occurred.
  20035.  
  20036.  Code                              Value   Meaning
  20037.  ────────────────────────────────────────────────────────────────────────────
  20038. 
  20039.  NERR_DriverNotFound               2166    The device driver specified has
  20040.                                            not been installed on the
  20041.                                            computer.
  20042.  
  20043.  NERR_ProcNotFound                 2168    The print processor has not been
  20044.                                            installed on the server.
  20045.  
  20046.  NERR_InvalidComputer              2351    The specified computername is
  20047.                                            invalid.
  20048.  
  20049.  ────────────────────────────────────────────────────────────────────────────
  20050.  
  20051.  
  20052.  
  20053.  
  20054.  Remarks
  20055.  
  20056.  Jobs created locally have no username, and can be operated upon by any user
  20057.  on the local computer. Admin privilege or printer operator privilege is
  20058.  required to operate on the job from a remote computer.
  20059.  
  20060.  The job position or job priority can be changed to allow a particular print
  20061.  job to print before other jobs in the queue. Applications or users without
  20062.  admin or print operator privilege can only move their own job backward in a
  20063.  printer queue and set the priority to a lower value. Without admin or print
  20064.  operator privilege, applications or users can improve the relative position
  20065.  of their job in the queue by changing all their other jobs in the queue to
  20066.  lower position or priority values. They cannot increase the job priority.
  20067.  
  20068.  When a new data structure is directed to a server running an earlier version
  20069.  of LAN Manager (a down-level server), the following parameter number codes
  20070.  are not supported: PRJ_PRIORITY_PARMNUM, PRJ_PROCPARMS_PARMNUM, and
  20071.  PRJ_DRIVERDATA_PARMNUM. The function returns ERROR_NOT_SUPPORTED for these
  20072.  codes. If the entire structure is passed, these unsupported entries are
  20073.  ignored.
  20074.  
  20075.  See Also
  20076.  
  20077.  For information about             See
  20078.  ────────────────────────────────────────────────────────────────────────────
  20079.  Listing the print jobs in a       DosPrintJobEnum
  20080.  printer queue
  20081.  
  20082.  Retrieving information about a    DosPrintJobGetInfo
  20083.  particular print job
  20084.  
  20085.  
  20086.  
  20087.  
  20088.  
  20089.  Print Job Category Example
  20090.  
  20091.    /*
  20092.       NETPRJ.C -- a program demonstrating the DosPrintJob API functions.
  20093.  
  20094.       Admin or print operator privilege is required to successfully
  20095.       execute the Print Job API functions on a remote server.
  20096.  
  20097.       DosPrintJobGetId is called to demonstrate that a Print Job ID can
  20098.       be returned for those applications that use Open to access a printer.
  20099.       This print job ID can then be used as an input parameter for the
  20100.    other
  20101.       Print Job API functions.
  20102.  
  20103.       This program calls DosPrintJobEnum to list all jobs in the specified
  20104.       queue. If the user did not select a job ID from the command
  20105.       line, the program selects the first job ID returned by the Enum
  20106.       function as the target job ID used in all other calls.
  20107.  
  20108.       DosPrintJobPause is called to pause the job, DosPrintJobSetInfo
  20109.       changes the job's position in the printer queue, DosPrintJobGetInfo
  20110.       displays the new settings, DosPrintJobContinue releases the paused
  20111.       job, and DosPrintJobDel deletes the job.
  20112.  
  20113.       Usage:  netprj [-s \\server] [-q queue] [-l level] [-n nth position]
  20114.                      [-f flag] [-j jobid]
  20115.       where  \\server     = Name of the server. A servername must be
  20116.                             preceded by two backslashes (\\).
  20117.              queue        = Name of the printer queue.
  20118.              level        = Level of detail.
  20119.              nth position = Job's new position in the queue.
  20120.              flag         = Flag to delete the job; 0 = no, 1 = yes.
  20121.              jobid        = ID of the target job for all function calls.
  20122.  
  20123.       API                     Used to...
  20124.       ===================     ===========================================
  20125.       DosPrintJobGetId        Get info about the print job (using handle)
  20126.       DosPrintJobEnum         List all print jobs in the specified queue
  20127.       DosPrintJobPause        Pause a print job in a printer queue
  20128.       DosPrintJobSetInfo      Set one or all print job parameters
  20129.       DosPrintJobGetInfo      Get info about the print job (using job
  20130.    ID)
  20131.       DosPrintJobContinue     Continue a paused print job
  20132.       DosPrintJobDel          Delete a print job from the queue
  20133.  
  20134.       This code sample is provided for demonstration purposes only.
  20135.       Microsoft makes no warranty, either express or implied,
  20136.       as to its usability in any given situation.
  20137.    */
  20138.    #define  INCL_BASE
  20139.    #include <os2.h>             // MS OS/2 base header files
  20140.    #include <pmspl.h>           // Print definitions
  20141.  
  20142.    #define  INCL_NETERRORS
  20143.    #include <lan.h>             // LAN Manager header files
  20144.  
  20145.    #include <fcntl.h>           // File-related defines
  20146.    #include <io.h>              // File-related functions
  20147.    #include <malloc.h>          // Memory allocation functions
  20148.    #include <share.h>           // File-related defines
  20149.    #include <stdio.h>           // C run-time header files
  20150.    #include <stdlib.h>
  20151.    #include <string.h>
  20152.    #include <time.h>
  20153.  
  20154.    #include "samples.h"         // SafeMalloc(), FarStrcpy(), etc.
  20155.  
  20156.    #define  DEFAULT_POS           1
  20157.    #define  DEFAULT_BUFFER_SIZE   512
  20158.    #define  MAX_BUFFER_SIZE       32768
  20159.    #define  DEFAULT_QUEUE         "PRINTQ"
  20160.  
  20161.    void DisplayInfo(USHORT uLevel, PBYTE pbBuffer, USHORT cEntries);
  20162.    void Usage(PSZ pszString);
  20163.  
  20164.    void main(int argc, char *argv[])
  20165.    {
  20166.       CHAR    szPath[2+CNLEN+1+UNLEN+1];     // Allow for slashes and
  20167.    NUL
  20168.       HFILE   hFile;                         // File handle
  20169.       INT     iCount;                        // Index, loop counter
  20170.       PBYTE   pbBuffer;                      // Pointer to return data
  20171.       PSZ     pszServerName = "";            // Default to local computer
  20172.       PSZ     pszQueueName = DEFAULT_QUEUE;  // Queuename
  20173.       SPLERR  uRet;                          // Return code
  20174.       USHORT  uLevel = 2;                    // Level of detail
  20175.       USHORT  fDone;                         // Flag successful call
  20176.       USHORT  fDelete = TRUE;                // Flag whether to delete
  20177.    or not
  20178.       USHORT  cEntriesRead;                  // Entries in buffer
  20179.       USHORT  cEntriesTotal;                 // Entries available
  20180.       USHORT  cbBuffer = 0;                  // Count of bytes in buffer
  20181.       USHORT  cbBufferNeeded = 0;            // Count of bytes available
  20182.       USHORT  uNewPosition = DEFAULT_POS;    // New position in queue;
  20183.    1 = top
  20184.       USHORT  uJobId = 0;                    // Print job ID number
  20185.       PPRIDINFO pprid;                       // DosPrintJobGetId data
  20186.  
  20187.    for (iCount = 1; iCount < argc; iCount++) // Get cmd-line
  20188.    switches
  20189.       {
  20190.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  20191.          {
  20192.             switch (tolower(*(argv[iCount]+1))) // Process switches
  20193.             {
  20194.                case 's':   // -s servername
  20195.                   pszServerName = argv[++iCount];
  20196.                   break;
  20197.                case 'q':   // -q queuename
  20198.                   pszQueueName = argv[++iCount];
  20199.                   break;
  20200.                case 'l':   // -l level
  20201.                   uLevel = atoi(argv[++iCount]);
  20202.                   break;
  20203.                case 'n':   // -n nth position in queue
  20204.                   uNewPosition = atoi(argv[++iCount]);
  20205.                   break;
  20206.                case 'f':   // -f flag for delete
  20207.                   fDelete = atoi(argv[++iCount]);
  20208.                   break;
  20209.                case 'j':
  20210.                   uJobId = atoi(argv[++iCount]);
  20211.                   break;
  20212.                case 'h':
  20213.                default:
  20214.                   Usage(argv[0]);
  20215.             }
  20216.          }
  20217.          else
  20218.             Usage(argv[0]);
  20219.       } // End for loop
  20220.       printf("\nPrint Job Category API Examples\n");
  20221.  
  20222.    //========================================================================
  20223.    //  DosPrintJobGetId
  20224.    //
  20225.    //  This API returns a job ID to allow existing applications that
  20226.  
  20227.    //  write directly to a remote server printer queue to use Print Job
  20228.  
  20229.    //  API functions. The input parameter is a handle to the remote
  20230.    //  printer queue.
  20231.    //========================================================================
  20232.  
  20233.    if ((pszServerName != NULL) && (*pszServerName != '\0'))
  20234.    // Remote only
  20235.       {
  20236.          FarStrcpy((PSZ)szPath, pszServerName);  // Servername
  20237.          strcat(szPath, "\\");                   // Slash precedes sharename
  20238.          FarStrcat((PSZ)szPath, pszQueueName);   // Queuename
  20239.  
  20240.          //  Open the file on the remote queue to obtain the handle.
  20241.          hFile = sopen(szPath,     // Remote printer queue: \\server\queue
  20242.                        O_RDONLY,   // Open read-only
  20243.                        SH_DENYNO); // Share deny-none
  20244.  
  20245.          if (hFile == -1)
  20246.             printf("sopen failed opening %s\n", szPath);
  20247.          else
  20248.          {
  20249.             printf("sopen succeeded opening %s\n", szPath);
  20250.             /*
  20251.              * If sopen succeeded, prepare to call DosPrintJobGetId:
  20252.                Allocate a buffer for the return data.
  20253.              */
  20254.             if ((pprid = (PPRIDINFO)_fmalloc(sizeof(PRIDINFO))) == NULL)
  20255.                exit(1);
  20256.  
  20257.             uRet = DosPrintJobGetId(hFile,   // Handle to printer queue
  20258.                           pprid,             // Pointer to return buffer
  20259.                           sizeof(PRIDINFO)); // Size of return buffer
  20260.             printf("DosPrintJobGetId returned %u\n", uRet);
  20261.             if (uRet == NERR_Success)
  20262.             {
  20263.                printf("Job ID   : %hu\n", pprid->uJobId);
  20264.                printf("Server   : %Fs\n",  pprid->szServer);
  20265.                printf("Queue    : %Fs\n",  pprid->szQName);
  20266.                /*
  20267.                 * If an application prints using the handle,
  20268.                 * DosPrintJobGetId can provide the job ID needed
  20269.                 * to use the other Print Job API functions.
  20270.                 */
  20271.                }
  20272.             _ffree((PVOID)pprid);
  20273.             close(hFile);       // Close handle
  20274.          }  // End successful sopen
  20275.       } // End if remote server
  20276.  
  20277.    //=======================================================================
  20278.    //  DosPrintJobEnum
  20279.    //
  20280.    //  This API lists all print jobs in the specified printer queue.
  20281.    //=======================================================================
  20282.  
  20283.       cbBuffer = DEFAULT_BUFFER_SIZE;
  20284.       if ((pbBuffer = (PBYTE)_fmalloc(cbBuffer)) == NULL)
  20285.       {
  20286.          printf("Cannot allocate buffer\n");
  20287.          exit(1);
  20288.       }
  20289.  
  20290.       do   // Call API function until buffer big enough or call fails
  20291.       {
  20292.          uRet = DosPrintJobEnum ( pszServerName, // Servername
  20293.                               pszQueueName,      // Queuename
  20294.                               uLevel,            // Call level
  20295.                               pbBuffer,          // Buffer for info
  20296.                               cbBuffer,          // Size of buffer
  20297.                               &cEntriesRead,     // Count of entries
  20298.    read
  20299.                               &cEntriesTotal);   // Count of entries
  20300.    available
  20301.          printf("DosPrintJobEnum returned %u\n", uRet);
  20302.          if ((uRet == NERR_BufTooSmall) || (uRet == ERROR_MORE_DATA))
  20303.          {
  20304.             // Allocate a buffer twice as large, up to the maximum size.
  20305.             _ffree((PVOID)pbBuffer);  // Buffer too small to hold data
  20306.             if (cbBuffer >= MAX_BUFFER_SIZE)
  20307.                exit(1);
  20308.             else if (cbBuffer > (MAX_BUFFER_SIZE/2))
  20309.                cbBuffer = MAX_BUFFER_SIZE;
  20310.             else
  20311.                cbBuffer += cbBuffer; // Allocate a larger one and try
  20312.    again
  20313.             if ((pbBuffer = (PBYTE)_fmalloc(cbBuffer)) == NULL)
  20314.                exit(1);
  20315.             fDone = FALSE;
  20316.          }
  20317.          else
  20318.             fDone = TRUE;
  20319.       } while (fDone == FALSE); // Loop until buffer big enough or call
  20320.    fails
  20321.  
  20322.    if (uRet == NERR_Success)
  20323.       {
  20324.          printf("DosPrintJobEnum read %hu ", cEntriesRead);
  20325.          printf(" out of %hu entries\n", cEntriesTotal);
  20326.          DisplayInfo(uLevel, pbBuffer, cEntriesRead);
  20327.  
  20328.    if ((uJobId == 0) && (cEntriesRead > 0))  // If data in
  20329.    the buffer
  20330.          {
  20331.             uJobId = *((USHORT FAR *)pbBuffer); // uJobId first, all
  20332.    levels
  20333.             printf(" Job ID for other functions = %hu\n", uJobId);
  20334.          }
  20335.       }
  20336.       _ffree((PVOID)pbBuffer);
  20337.  
  20338.    //=======================================================================
  20339.    //  DosPrintJobPause
  20340.    //
  20341.    //  This API pauses the specified print job.
  20342.    //=======================================================================
  20343.  
  20344.       uRet = DosPrintJobPause(pszServerName,  // Servername
  20345.                               uJobId);        // Job ID
  20346.       printf("DosPrintJobPause returned %u\n", uRet);
  20347.  
  20348.    //=======================================================================
  20349.    //  DosPrintJobSetInfo
  20350.    //
  20351.    //  This API allows control over one or all print job settings.
  20352.    //  In this example, a single element is set to the desired value
  20353.    //  (but a valid detail level [1 or 3] must still be provided).
  20354.    //=======================================================================
  20355.  
  20356.       uRet = DosPrintJobSetInfo(pszServerName,  // Servername
  20357.                           uJobId,               // Job ID
  20358.                           1,                    // Call level
  20359.                           (PBYTE)&uNewPosition, // Data to be set
  20360.                           sizeof(USHORT),       // Size of buffer
  20361.                           PRJ_POSITION_PARMNUM);// Set job position in
  20362.    queue
  20363.       printf("DosPrintJobSetInfo returned %u\n", uRet);
  20364.  
  20365.    //=======================================================================
  20366.    //  DosPrintJobGetInfo
  20367.    //
  20368.    //  This API returns information about one specific print job.
  20369.    //=======================================================================
  20370.  
  20371.       /*
  20372.        * Call with zero-length buffer, expect NERR_BufTooSmall.
  20373.        * Make a second call with the buffer of the required size.
  20374.        */
  20375.  
  20376.       uRet = DosPrintJobGetInfo(pszServerName,   // Servername
  20377.                             uJobId,              // Job ID
  20378.                             uLevel,              // Call level
  20379.                             NULL,                // Buffer for info
  20380.                             0,                   // Size of buffer
  20381.                             &cbBufferNeeded);    // Size required
  20382.  
  20383.       if (uRet == NERR_BufTooSmall)
  20384.       {
  20385.          cbBuffer = cbBufferNeeded;
  20386.          if ((pbBuffer = (PBYTE)_fmalloc(cbBuffer)) == NULL)
  20387.             exit(1);
  20388.  
  20389.          uRet = DosPrintJobGetInfo(pszServerName,// Servername
  20390.                                uJobId,           // Job ID
  20391.                                uLevel,           // Call level
  20392.                                pbBuffer,         // Buffer for info
  20393.                                cbBuffer,         // Size of buffer
  20394.                                &cbBufferNeeded); // Size required
  20395.       }
  20396.       printf("DosPrintJobGetInfo returned %u\n", uRet);
  20397.       if (uRet == NERR_Success)
  20398.          DisplayInfo(uLevel, pbBuffer, 1);  // Show results of GetInfo
  20399.       _ffree((PVOID)pbBuffer);
  20400.  
  20401.    //=======================================================================
  20402.    //  DosPrintJobContinue
  20403.    //
  20404.    //  This API allows a paused print job to continue.
  20405.    //=======================================================================
  20406.  
  20407.       uRet = DosPrintJobContinue(pszServerName,  // Servername
  20408.                                  uJobId);        // Job ID
  20409.       printf("DosPrintJobContinue returned %u\n", uRet);
  20410.  
  20411.    //=======================================================================
  20412.    //  DosPrintJobDel
  20413.    //
  20414.    //  This API deletes the print job. This sample program allows the
  20415.    user
  20416.    //  to specify a command-line flag that determines whether to delete
  20417.  
  20418.    //  the job or not.
  20419.    //=======================================================================
  20420.  
  20421.    if (fDelete == TRUE)
  20422.       {
  20423.          uRet = DosPrintJobDel(pszServerName, // Servername
  20424.                                uJobId);       // Job ID
  20425.          printf("DosPrintJobDel returned %u\n", uRet);
  20426.       }
  20427.       exit(0);
  20428.    }  // End of main
  20429.  
  20430.    //=======================================================================
  20431.    //  DisplayInfo
  20432.    //
  20433.    //  Display selected print job information obtained by
  20434.    //  DosPrintJobGetInfo or DosPrintJobEnum. DosPrintJobGetInfo allows
  20435.  
  20436.    //  levels 0, 1, 2, or 3. DosPrintJobEnum allows levels 0, 1, or 2.
  20437.    //=======================================================================
  20438.  
  20439.    void DisplayInfo(USHORT uLevel, PBYTE pbBuffer, USHORT cEntries)
  20440.    {
  20441.       PUSHORT   pprj0Info;  // Pointer to level 0 data structure
  20442.       PPRJINFO  pprj1Info;  // Pointer to level 1 data structure
  20443.       PPRJINFO2 pprj2Info;  // Pointer to level 2 data structure
  20444.       PPRJINFO3 pprj3Info;  // Pointer to level 3 data structure
  20445.       USHORT    iCount;     // Index, loop counter
  20446.       time_t    time;       // Convert job submission time
  20447.  
  20448.       pprj0Info = (PUSHORT) pbBuffer;    // Initialize pointers
  20449.       pprj1Info = (PPRJINFO) pbBuffer;
  20450.       pprj2Info = (PPRJINFO2) pbBuffer;
  20451.       pprj3Info = (PPRJINFO3) pbBuffer;
  20452.  
  20453.       for (iCount = 1; iCount <= cEntries; iCount++)
  20454.       {
  20455.          printf("\n");
  20456.          switch (uLevel)
  20457.          {
  20458.             case 0:
  20459.                printf("Job ID      :  %hu\n", *pprj0Info++);
  20460.                break;
  20461.             case 1:                     // Level 1 data in buffer
  20462.                printf("Job ID      :  %hu\n", pprj1Info->uJobId);
  20463.                printf("User Name   :  %Fs\n", pprj1Info->szUserName);
  20464.                printf("Position    :  %hu\n", pprj1Info->uPosition);
  20465.                printf("Job Status  :  0x%hx\n", pprj1Info->fsStatus);
  20466.                pprj1Info++;
  20467.                break;
  20468.             case 2:                     // Level 2 data in buffer
  20469.                printf("Job ID      : %hu\n", pprj2Info->uJobId);
  20470.                printf("Priority    : %hu\n", pprj2Info->uPriority);
  20471.                printf("User Name   : %Fs\n", pprj2Info->pszUserName);
  20472.                putenv("TZ=GMT0");   // Print time given in local time
  20473.                time = (time_t) pprj2Info->ulSubmitted;
  20474.                printf("Submitted   : %s", ctime(&time));
  20475.                printf("Job size    : %lu\n", pprj2Info->ulSize);
  20476.                pprj2Info++;
  20477.                break;
  20478.  
  20479.             case 3:                     // Level 3 data in buffer
  20480.                printf("Job ID      : %hu\n", pprj3Info->uJobId);
  20481.                printf("Priority    : %hu\n", pprj3Info->uPriority);
  20482.                printf("User Name   : %Fs\n", pprj3Info->pszUserName);
  20483.                printf("Queue       : %Fs\n", pprj3Info->pszQueue);
  20484.                printf("Printer Name: %Fs\n", pprj3Info->pszPrinterName);
  20485.                pprj3Info++;
  20486.                break;
  20487.  
  20488.             default:                    // Undefined level
  20489.                break;
  20490.          } // End switch uLevel
  20491.       } // End for loop
  20492.    }  // End function
  20493.  
  20494.    //=======================================================================
  20495.    //  Usage
  20496.    //
  20497.    //  Display possible command-line switches for this sample program.
  20498.    //=======================================================================
  20499.  
  20500.    void Usage(PSZ pszString)
  20501.    {
  20502.       fprintf(stderr, "Usage: %Fs [-s \\\\server] [-l level]", pszString);
  20503.       fprintf(stderr, " [-q queuename]\n\t[-j jobid] [-f flag delete]\n");
  20504.       exit(1);
  20505.    }
  20506.  
  20507.  
  20508.  
  20509.  
  20510.  
  20511.  
  20512.  
  20513.  Printer Queue Category
  20514.  
  20515.  Printer Queue API functions control the printer queues on a server. When
  20516.  executed locally, they do not require that the NETWKSTA device driver be
  20517.  installed. When a servername is supplied, they require that the Workstation
  20518.  service be started.
  20519.  
  20520.  The Printer Queue category functions, datatypes, structures, and constants
  20521.  are defined in the PMSPL.H header file. A source program can access these
  20522.  definitions by including the PMSPL.H header file. A source program can
  20523.  access error codes by defining the constant INCL_NETERRORS and including the
  20524.  LAN.H header file. For more information, see the "Example" section, later in
  20525.  this category.
  20526.  
  20527.  These are the Printer Queue API functions:
  20528.  
  20529.  
  20530.    ■   DosPrintQAdd
  20531.  
  20532.    ■   DosPrintQContinue
  20533.  
  20534.    ■   DosPrintQDel
  20535.  
  20536.    ■   DosPrintQEnum
  20537.  
  20538.    ■   DosPrintQGetInfo
  20539.  
  20540.    ■   DosPrintQPause
  20541.  
  20542.    ■   DosPrintQPurge
  20543.  
  20544.    ■   DosPrintQSetInfo
  20545.  
  20546.  
  20547.  
  20548.  Description
  20549.  
  20550.  A printer queue is an ordered list of print jobs on a computer. A single
  20551.  computer can have multiple printer queues. When a print job is submitted to
  20552.  a printer queue, the spooler directs the print job to a print processor for
  20553.  processing before printing. The print spooler continuously examines the
  20554.  printer queues. The action taken depends on the following:
  20555.  
  20556.  
  20557.    ■   Printer queue priority (in relation to other printer queues)
  20558.  
  20559.    ■   Time of day during which the printer queue accepts jobs
  20560.  
  20561.    ■   Print destination(s) available to the printer queue
  20562.  
  20563.    ■   Print processor, driver, and driver data defaults for jobs added to
  20564.        the queue
  20565.  
  20566.  
  20567.  DosPrintQAdd creates a printer queue on the specified server. DosPrintQDel
  20568.  deletes a printer queue.
  20569.  
  20570.  DosPrintQPause pauses the operation of a printer queue and suspends
  20571.  scheduling of all print jobs but the current job. A paused queue continues
  20572.  to accept new jobs. DosPrintQContinue resumes processing of print jobs in a
  20573.  paused printer queue. Print jobs can be submitted to a paused queue, but
  20574.  jobs are not spooled to a print destination or print processor until the
  20575.  printer queue resumes processing. DosPrintQPurge  removes all pending jobs
  20576.  in a printer queue, leaving only currently printing jobs.
  20577.  
  20578.  The DosPrintQEnum API function lists information about all printer queues on
  20579.  a server. The DosPrintQGetInfo API function retrieves information about a
  20580.  particular printer queue. The DosPrintQSetInfo API function allows you to
  20581.  change parameter settings for a particular printer queue.
  20582.  
  20583.  The Printer Queue data structures and the Printer Queue API functions use MS
  20584.  OS/2 conventions for names and type definitions. The OS2DEF.H header file
  20585.  defines these types:
  20586.  
  20587. ╓┌─────────────────────────────────┌─────────────────────────────────────────╖
  20588.  MS OS/2 Type Definition           C-Language Type
  20589.  ────────────────────────────────────────────────────────────────────────────
  20590.  CHAR                              char
  20591.  PBYTE                             unsigned char far *
  20592.  PSZ                               unsigned char far *
  20593.  PUSHORT                           unsigned short *
  20594.  SPLENTRY                          pascal far
  20595.  SPLERR                            unsigned
  20596.  USHORT                            unsigned short
  20597.  ────────────────────────────────────────────────────────────────────────────
  20598.  
  20599.  
  20600.  
  20601.  Data Structures
  20602.  
  20603.  Level 0, level 1, and level 2 data structures are provided for compatibility
  20604.  with existing LAN Manager 1.0 applications. LAN Manager 2.0 applications
  20605.  should use level 3, level 4, and level 5 data structures.
  20606.  
  20607.  Existing LAN Manager 1.0 applications (that use the level 0, 1, and 2 data
  20608.  structures) can be compiled and linked using the 1.0 header file NETSPOOL.H
  20609.  and the 1.0-compatible libraries NETSPOOL.LIB and NETSPOOL.DLL.
  20610.  
  20611.  Applications designed to run with both MS OS/2 1.1 and MS OS/2 1.2 should
  20612.  use the new level 3, level 4, and level 5 data structure names, include the
  20613.  PMSPL.H header file, and link with the NETSPOOL libraries.
  20614.  
  20615.  Applications that are designed to run only with MS OS/2 1.2 should use the
  20616.  PMSPL.LIB and PMSPL.DLL libraries. The PMSPL library functions provide
  20617.  better performance than the corresponding functions in the NETSPOOL library.
  20618.  
  20619.  
  20620.  Applications that run only with MS OS/2 1.2 can be built from existing
  20621.  applications. These applications can be upgraded by changing the data
  20622.  structure and element names. References to the prq_info data structure and
  20623.  element names can be changed to the PRQINFO data structure and element
  20624.  names. The prq_processor element of the prq_info data structure must be
  20625.  changed. This element contains a path to a .EXE file; the corresponding
  20626.  pszPrProc element of the PRQINFO data structure contains a queue processor
  20627.  name.
  20628.  
  20629.  There is one-to-one mapping from the size and type of the prq_info elements
  20630.  to the PRQINFO elements, as shown in the following table:
  20631.  
  20632. ╓┌────────────────────────────────┌──────────────────────────────────────────╖
  20633.  LAN Manager 1.0                  LAN Manager 2.0
  20634.  prq_info Element                 PRQINFO Element
  20635.  ────────────────────────────────────────────────────────────────────────────
  20636.  prq_name                         szName
  20637.  
  20638.  prq_pad1                         pad_1
  20639.  
  20640.  prq_priority                     uPriority
  20641.  
  20642.  prq_starttime                    uStarttime
  20643.  
  20644.  prq_untiltime                    uUntiltime
  20645.  LAN Manager 1.0                  LAN Manager 2.0
  20646.  prq_info Element                 PRQINFO Element
  20647.  ────────────────────────────────────────────────────────────────────────────
  20648. prq_untiltime                    uUntiltime
  20649.  
  20650.  prq_separator                    pszSepFile
  20651.  
  20652.  prq_processor                    pszPrProc
  20653.  
  20654.  prq_destinations                 pszDestinations
  20655.  
  20656.  prq_parms                        pszParms
  20657.  
  20658.  prq_comment                      pszComment
  20659.  
  20660.  prq_status                       fsStatus
  20661.  
  20662.  prq_jobcount                     cJobs
  20663.  
  20664.  ────────────────────────────────────────────────────────────────────────────
  20665.  
  20666.  LAN Manager 1.0                  LAN Manager 2.0
  20667.  prq_info Element                 PRQINFO Element
  20668.  ────────────────────────────────────────────────────────────────────────────
  20669. 
  20670.  
  20671.  
  20672.  The new data structures are supported when they are directed to servers that
  20673.  run LAN Manager 1.0 software (down-level servers). New elements are given
  20674.  default values or values that indicate the element is not available, such as
  20675.  NULL.
  20676.  
  20677.  DosPrintQAdd and DosPrintQSetInfo use the level 1 data structure PRQINFO or
  20678.  the level 3 data structure PRQINFO3.
  20679.  
  20680.  DosPrintQEnum and DosPrintQGetInfo use levels 0, 1, 2, 3, 4, and 5.
  20681.  
  20682.  
  20683.  Printer Queue Name (level 0)
  20684.  
  20685.  At level 0, data is returned in this format:
  20686.  
  20687.    CHAR szName[QNLEN+1];
  20688.  
  20689.  where
  20690.  
  20691.  szName
  20692.    Contains an ASCIIZ string that specifies the name of a printer queue. The
  20693.    constant QNLEN is defined in the PMSPL.H header file.
  20694.  
  20695.  
  20696.  Printer Queue Information (level 1)
  20697.  
  20698.  The PRQINFO data structure has this format:
  20699.  
  20700.    typedef struct _PRQINFO {
  20701.        CHAR    szName[QNLEN+1];
  20702.        CHAR    pad_1;
  20703.        USHORT  uPriority;
  20704.        USHORT  uStarttime;
  20705.        USHORT  uUntiltime;
  20706.        PSZ     pszSepFile;
  20707.        PSZ     pszPrProc;
  20708.        PSZ     pszDestinations;
  20709.        PSZ     pszParms;
  20710.        PSZ     pszComment;
  20711.        USHORT  fsStatus;
  20712.        USHORT  cJobs;
  20713.    } PRQINFO;
  20714.  
  20715.  where
  20716.  
  20717.  szName
  20718.    Contains an ASCIIZ string that specifies the name of the printer queue.
  20719.    The constant QNLEN is defined in the PMSPL.H header file.
  20720.  
  20721.  pad_1
  20722.    Aligns the next data structure element on a word boundary.
  20723.  
  20724.  uPriority
  20725.    Contains an unsigned short integer that specifies the printer queue
  20726.    priority, ranging from 1 (highest) through 9 (lowest). When two or more
  20727.    printer queues submit print jobs to the same destination, jobs in printer
  20728.    queues with higher priorities are processed before those in lower-priority
  20729.    queues.
  20730.  
  20731.    The printer queue priority is used to determine the default print job
  20732.    priority. The default job priority is used when no priority is specified
  20733.    for the job or when the specified job priority is higher than the default
  20734.    job priority. For more information, see the Print Job category API
  20735.    functions.
  20736.  
  20737.  uStarttime
  20738.    Contains an unsigned short integer that specifies the time of day a
  20739.    printer queue becomes active and can start sending print jobs to print
  20740.    destinations. This value represents the number of minutes since 00:00
  20741.    (midnight). For example, a value of 60 indicates that the printer queue
  20742.    becomes active at 1:00 A.M.
  20743.  
  20744.  uUntiltime
  20745.    Contains an unsigned short integer that specifies the time of day a
  20746.    printer queue becomes inactive and stops sending print jobs to print
  20747.    destinations. This value  represents the number of minutes since 00:00
  20748.    (midnight). For example, a value of 1020 (60 minutes * 17 hours) indicates
  20749.    that the printer queue becomes inactive at 5:00 P.M.
  20750.  
  20751.  pszSepFile
  20752.    Points to an ASCIIZ string that contains the pathname of a separator page
  20753.    file. A relative pathname is relative to the current spool directory. The
  20754.    separator page file contains formatting information for the page(s) that
  20755.    separates print jobs. Separator pages are printed only by some print
  20756.    processors, such as LMPRINT; PMPRINT does not print them.
  20757.  
  20758.  pszPrProc
  20759.    Points to an ASCIIZ string that contains the name of the print processor.
  20760.    A null pointer or null string indicates the default queue processor.
  20761.  
  20762.  pszDestinations
  20763.    Points to an ASCIIZ string that contains a list of print destinations for
  20764.    this queue (the concatenated print destinations are separated by spaces).
  20765.    The specified print destinations process the print jobs in this printer
  20766.    queue. Print jobs submitted to the queue are sent to the first available
  20767.    destination in the list.
  20768.  
  20769.  pszParms
  20770.    Points to an ASCIIZ string that contains parameters required by printer
  20771.    queues. The parameter string has the following format:
  20772.  
  20773.    parm1=value1 parm2=value2 ...
  20774.  
  20775.    Note that a single space separates the parameter and value pairs.
  20776.  
  20777.  pszComment
  20778.    Points to an ASCIIZ string that contains a comment about the printer
  20779.    queue.
  20780.  
  20781.  fsStatus
  20782.    Contains an unsigned short integer that specifies the status of a printer
  20783.    queue. Possible values are defined in the PMSPL.H header file. The
  20784.    PRQ_STATUS_MASK code has a value of 3 and specifies the status of the
  20785.    printer queue, as follows:
  20786.  
  20787.  Code         Value  Meaning
  20788.  ────────────────────────────────────────────────────────────────────────────
  20789.  PRQ_ACTIVE   0      Active.
  20790.  PRQ_PAUSE    1      Paused.
  20791.  PRQ_ERROR    2      Error occurred.
  20792.  PRQ_PENDING  3      Deletion pending.
  20793.  ────────────────────────────────────────────────────────────────────────────
  20794.  
  20795.  cJobs
  20796.    Contains an unsigned short integer that specifies the number of print jobs
  20797.    currently in the queue.
  20798.  
  20799.  
  20800.  Printer Queue and Job Information (level 2)
  20801.  
  20802.  Level 2 indicates that the return data consists of the Printer Queue data
  20803.  structure PRQINFO followed by a Print Job data structure PRJINFO for every
  20804.  job in the queue. For a full description of the Printer Queue data structure
  20805.  PRQINFO, see the preceding section.
  20806.  
  20807.  The Print Job data structure PRJINFO has this format:
  20808.  
  20809.    typedef struct _PRJINFO {
  20810.        USHORT  uJobId;
  20811.        CHAR    szUserName[UNLEN+1];
  20812.        CHAR    pad_1;
  20813.        CHAR    szNotifyName[CNLEN+1];
  20814.        CHAR    szDataType[DTLEN+1];
  20815.        PSZ     pszParms;
  20816.        USHORT  uPosition;
  20817.        USHORT  fsStatus;
  20818.        PSZ     pszStatus;
  20819.        ULONG   ulSubmitted;
  20820.        ULONG   ulSize;
  20821.        PSZ     pszComment;
  20822.    } PRJINFO;
  20823.  
  20824.  where
  20825.  
  20826.  uJobId
  20827.    Contains an unsigned short integer that specifies the identification
  20828.    number of the print job. The identification number is assigned by the
  20829.    print spooler.
  20830.  
  20831.  szUserName
  20832.    Specifies an ASCIIZ string that contains the name of the user who
  20833.    submitted the print job. The constant UNLEN is defined in the PMSPL.H
  20834.    header file. A null string indicates that the job was submitted from the
  20835.    local computer.
  20836.  
  20837.  pad_1
  20838.    Aligns the next data structure element on a word boundary.
  20839.  
  20840.  szNotifyName
  20841.    Contains an ASCIIZ string that specifies the message alias that receives
  20842.    alert messages relating to the print job. A null string indicates that the
  20843.    job was submitted from the local computer. The constant CNLEN is defined
  20844.    in the PMSPL.H header file.
  20845.  
  20846.  szDataType
  20847.    Contains an ASCIIZ string that specifies the datatype for the print job.
  20848.    This element corresponds to the pszDataType element of the MS OS/2
  20849.    DEVOPENSTRUC data structure supplied when the job was created.
  20850.    DEVOPENSTRUC is defined in the OS2DEV.H header file. The constant DTLEN is
  20851.    defined in the PMSPL.H header file.
  20852.  
  20853.  pszParms
  20854.    Points to an ASCIIZ string that contains a parameter string to pass to the
  20855.    printer queue processor. The parameter string has this format:
  20856.  
  20857.    parms=value
  20858.  
  20859.  uPosition
  20860.    Contains an unsigned short integer that specifies the position of the
  20861.    print job in the printer queue. If uPosition is 1, the print job prints
  20862.    next.
  20863.  
  20864.  fsStatus
  20865.    Contains an unsigned short integer used as a status flag. Possible values
  20866.    are defined in the PMSPL.H header file.
  20867.  
  20868.    Bits 0-1 have the code PRJ_QSTATUS and the value 0x0003. This bit mask
  20869.    isolates the print job queued status bits, as follows:
  20870.  
  20871.  Bits  Code             Value  Meaning
  20872.  ────────────────────────────────────────────────────────────────────────────
  20873.  0-1   PRJ_QS_QUEUED    0      Print job is queued.
  20874.  
  20875.  0-1   PRJ_QS_PAUSED    1      Print job is paused.
  20876.  
  20877.  0-1   PRJ_QS_SPOOLING  2      Print job is spooling.
  20878.  
  20879.  0-1   PRJ_QS_PRINTING  3      Print job is printing
  20880.                                (bits 2-11 are valid).
  20881.  
  20882.  ────────────────────────────────────────────────────────────────────────────
  20883.  
  20884.  
  20885.    Bits 2-11 indicate the print job status. Bits 2-11 can be isolated using
  20886.    the constant PRJ_DEVSTATUS, which has the value 0x0FFC. Bit 15 signals
  20887.    whether an alert indicated the print job was deleted. These are the
  20888.    meanings for individual bits:
  20889.  
  20890. ╓┌────┌────────────────┌───────┌─────────────────────────────────────────────╖
  20891.  Bit  Code             Value   Meaning
  20892.  ────────────────────────────────────────────────────────────────────────────
  20893.  2    PRJ_COMPLETE     0x0004  If 1, the job is complete.
  20894.  
  20895.  3    PRJ_INTERV       0x0008  If 1, intervention is required.
  20896.  
  20897.  Bit  Code             Value   Meaning
  20898.  ────────────────────────────────────────────────────────────────────────────
  20899. 
  20900.  4    PRJ_ERROR        0x0010  If 1, an error occurred (pszStatus can
  20901.                                contain a comment explaining the error).
  20902.  
  20903.  5    PRJ_DESTOFFLINE  0x0020  If 1, the print destination is offline.
  20904.  
  20905.  6    PRJ_DESTPAUSED   0x0040  If 1, the print destination is paused.
  20906.  
  20907.  7    PRJ_NOTIFY       0x0080  If 1, an alert is raised.
  20908.  
  20909.  8    PRJ_DESTNOPAPER  0x0100  If 1, the print destination is out of paper.
  20910.  
  20911.  9    PRJ_DESTFORMCHG  0x0200  If 1, the printer is waiting for a form
  20912.                                change.
  20913.  
  20914.  10   PRJ_DESTCRTCHG   0x0400  If 1, the printer is waiting for a cartridge
  20915.                                change.
  20916.  
  20917.  11   PRJ_DESTPENCHG   0x0800  If 1, the printer is waiting for a pen
  20918.  Bit  Code             Value   Meaning
  20919.  ────────────────────────────────────────────────────────────────────────────
  20920. 11   PRJ_DESTPENCHG   0x0800  If 1, the printer is waiting for a pen
  20921.                                change.
  20922.  
  20923.  15   PRJ_DELETED      0x8000  If 1, an alert indicates the print job was
  20924.                                deleted.
  20925.  
  20926.  ────────────────────────────────────────────────────────────────────────────
  20927.  
  20928.  
  20929.  
  20930.  pszStatus
  20931.    Points to an ASCIIZ string that contains a comment about the status of the
  20932.    print job posted by the queue's print processor. A null pointer or null
  20933.    string indicates that no information was posted.
  20934.  
  20935.  ulSubmitted
  20936.    Contains an unsigned long integer that specifies the time the user
  20937.    submitted the print job. The time is given as the number of seconds
  20938.    elapsed since 00:00:00, January 1, 1970.
  20939.  
  20940.  ulSize
  20941.    Contains an unsigned long integer that specifies the size (in bytes) of
  20942.    the print job.
  20943.  
  20944.  pszComment
  20945.    Points to an ASCIIZ string that contains a comment about the print job. It
  20946.    can have as many as MAXCOMMENTSZ bytes, as defined in the PMSPL.H header
  20947.    file.
  20948.  
  20949.  
  20950.  Printer Queue Information (level 3)
  20951.  
  20952.  The PRQINFO3 data structure has this format:
  20953.  
  20954.    typedef struct _PRQINFO3 {
  20955.        PSZ        pszName;
  20956.        USHORT     uPriority;
  20957.        USHORT     uStarttime;
  20958.        USHORT     uUntiltime;
  20959.        USHORT     pad1;
  20960.        PSZ        pszSepFile;
  20961.        PSZ        pszPrProc;
  20962.        PSZ        pszParms;
  20963.        PSZ        pszComment;
  20964.        USHORT     fsStatus;
  20965.        USHORT     cJobs;
  20966.        PSZ        pszPrinters;
  20967.        PSZ        pszDriverName;
  20968.        PDRIVDATA  pDriverData;
  20969.    } PRQINFO3;
  20970.  
  20971.  where
  20972.  
  20973.  pszName
  20974.    Points to an ASCIIZ string that contains the name of the printer queue.
  20975.    The queuename can have as many as CCHMAXPATHCOMP bytes, as defined in the
  20976.    MS OS/2 header file BSEDOS.H.
  20977.  
  20978.  uPriority through cJobs
  20979.    Are the same as the corresponding elements of the PRQINFO data structure.
  20980.    For a complete description, see "Printer Queue Information (level 1),"
  20981.    earlier in this category.
  20982.  
  20983.  pszPrinters
  20984.    Points to an ASCIIZ string that contains a list of printers that can print
  20985.    from the printer queue. These names reference printers that already exist.
  20986.    If a null pointer or null string is supplied, the queue is created but is
  20987.    not connected to any printers. Printernames in the list are separated by
  20988.    commas (,). If the printername contains spaces, the name should be
  20989.    enclosed in double quotation marks (" ").
  20990.  
  20991.  pszDriverName
  20992.    Points to an ASCIIZ string that contains the default device driver for the
  20993.    queue. The device driver must already have been installed. The default
  20994.    device driver is used to create a print job when only a queuename is
  20995.    specified. If a null pointer or null string is supplied, pDriverData is
  20996.    not used.
  20997.  
  20998.  pDriverData
  20999.    Points to the device driver data for the default driver. This data is
  21000.    specific to the device driver, and it is used only if pszDriverName is not
  21001.    a null pointer or null string.
  21002.  
  21003.  
  21004.  Printer Queue Information (level 4)
  21005.  
  21006.  Level 4 indicates that the return data consists of the Printer Queue data
  21007.  structure(s) PRQINFO3 followed by a Print Job data structure PRJINFO2 for
  21008.  each job in the queue.
  21009.  
  21010.  For a full description of the Printer Queue data structure PRQINFO3, see the
  21011.  preceding section.
  21012.  
  21013.  The Print Job data structure PRJINFO2 has this format:
  21014.  
  21015.    typedef struct _PRJINFO2 {
  21016.        USHORT  uJobId;
  21017.        USHORT  uPriority;
  21018.        PSZ     pszUserName;
  21019.        USHORT  uPosition;
  21020.        USHORT  fsStatus;
  21021.        ULONG   ulSubmitted;
  21022.        ULONG   ulSize;
  21023.        PSZ     pszComment;
  21024.        PSZ     pszDocument;
  21025.    } PRJINFO2;
  21026.  
  21027.  where
  21028.  
  21029.  uJobId
  21030.    Contains an unsigned short integer that specifies the identification
  21031.    number of the print job. The identification number is assigned by the
  21032.    print spooler.
  21033.  
  21034.  uPriority
  21035.    Contains an unsigned short integer that specifies the priority of the
  21036.    print job, ranging from 1 (lowest priority) through 99 (highest priority).
  21037.    The constant PRJ_NO_PRIORITY should be used to get the default job
  21038.    priority based on the queue priority. The constant PRJ_NO_PRIORITY is
  21039.    defined in the PMSPL.H header file.
  21040.  
  21041.    The job priority determines the order of jobs in the queue. If multiple
  21042.    queues print to the same printer, the jobs at the front of the queues are
  21043.    examined. The job with the highest priority is scheduled. If the job
  21044.    priorities are equal, the oldest job is scheduled.
  21045.  
  21046.  pszUserName
  21047.    Points to an ASCIIZ string that contains the name of the user who
  21048.    submitted the print job.
  21049.  
  21050.  uPosition through pszComment
  21051.    Are the same as the corresponding elements of the PRJINFO data structure.
  21052.    For a complete description, see "Printer Queue and Job Information (level
  21053.    2)," earlier in this category.
  21054.  
  21055.  pszDocument
  21056.    Points to an ASCIIZ string that contains the document name of the print
  21057.    job. The document name can have as many as CCHMAXPATH bytes, as defined in
  21058.    the MS OS/2 header file BSEDOS.H.
  21059.  
  21060.  
  21061.  Printer Queue Information (level 5)
  21062.  
  21063.  At level 5, data is returned in this format:
  21064.  
  21065.    PSZ  pszName;
  21066.  
  21067.  where
  21068.  
  21069.  pszName
  21070.    Points to an ASCIIZ string that specifies the name of the printer queue.
  21071.    The queuename can have as many as CCHMAXPATHCOMP bytes, as defined in the
  21072.    MS OS/2 header file BSEDOS.H.
  21073.  
  21074.  See Also
  21075.  
  21076.  For information about             See
  21077.  ────────────────────────────────────────────────────────────────────────────
  21078.  Controlling a print destination   Print Destination Category
  21079.  
  21080.  Controlling print jobs            Print Job Category
  21081.  
  21082.  
  21083.  DosPrintQAdd
  21084.  ────────────────────────────────────────────────────────────────────────────
  21085.  
  21086.  DosPrintQAdd creates a printer queue on a server.
  21087.  
  21088.  
  21089.  Operating Systems Supported
  21090.  
  21091.  
  21092.    ■   MS OS/2 version 1.2, local and remote
  21093.  
  21094.    ■   MS OS/2 version 1.1, remote only
  21095.  
  21096.    ■   MS-DOS, remote only
  21097.  
  21098.  
  21099.  
  21100.  Privilege Level
  21101.  
  21102.  Admin privilege or print operator privilege is required to successfully
  21103.  execute DosPrintQAdd on a remote server or on a computer that has local
  21104.  security enabled.
  21105.  
  21106.  
  21107.  Syntax
  21108.  
  21109.    #define INCL_BASE
  21110.    #include <os2.h>
  21111.  
  21112.    #include <pmspl.h>
  21113.  
  21114.    #define INCL_NETERRORS
  21115.    #include <lan.h>
  21116.  
  21117.    SPLERR SPLENTRY
  21118.    DosPrintQAdd (PSZ     pszServer,
  21119.                  USHORT  uLevel,
  21120.                  PBYTE   pbBuf,
  21121.                  USHORT  cbBuf
  21122.                 );
  21123.  
  21124.  where
  21125.  
  21126.  pszServer
  21127.    Points to an ASCIIZ string that contains the name of a server on which to
  21128.    execute DosPrintQAdd. A null pointer or null string specifies the local
  21129.    computer.
  21130.  
  21131.  uLevel
  21132.    Specifies the level of detail (1 or 3) provided in the buffer pointed to
  21133.    by pbBuf. Level 1 is provided for compatibility with existing LAN Manager
  21134.    1.0 applications and should not be used in new applications. Only level 3
  21135.    should be used in new applications.
  21136.  
  21137.  pbBuf
  21138.    Points to the buffer that contains data for the printer queue to be added.
  21139.    The buffer should contain a PRQINFO or PRQINFO3 data structure,
  21140.    corresponding to the level specified by uLevel.
  21141.  
  21142.  cbBuf
  21143.    Specifies the size (in bytes) of the data buffer pointed to by pbBuf.
  21144.  
  21145.  Return Codes
  21146.  
  21147. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  21148.  Code                              Value   Meaning
  21149.  Code                              Value   Meaning
  21150.  ────────────────────────────────────────────────────────────────────────────
  21151.  NERR_Success                      0       The function encountered no
  21152.                                            errors.
  21153.  
  21154.  ERROR_ACCESS_DENIED               5       The user has insufficient
  21155.                                            privilege for this operation.
  21156.  
  21157.  ERROR_BAD_NETPATH                 53      The network path was not found.
  21158.  
  21159.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  21160.  
  21161.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  21162.                                            invalid.
  21163.  
  21164.  ERROR_INVALID_LEVEL               124     The level for information
  21165.                                            retrieval or setting is invalid.
  21166.  
  21167.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  21168.                                            is not installed.
  21169.  
  21170.  Code                              Value   Meaning
  21171.  ────────────────────────────────────────────────────────────────────────────
  21172. 
  21173.  NERR_RemoteOnly                   2106    This operation can be performed
  21174.                                            only on a server.
  21175.  
  21176.  NERR_RedirectedPath               2117    The operation is invalid for a
  21177.                                            redirected resource. The
  21178.                                            devicename specified is assigned
  21179.                                            to a shared resource.
  21180.  
  21181.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  21182.  
  21183.  NERR_WkstaNotStarted              2138    The Workstation service is not
  21184.                                            started.
  21185.  
  21186.  NERR_BadTransactConfig            2141    The server is not configured for
  21187.                                            this transaction: IPC$ is not
  21188.                                            shared.
  21189.  
  21190.  NERR_DestNotFound                 2152    The print destination was not
  21191.  Code                              Value   Meaning
  21192.  ────────────────────────────────────────────────────────────────────────────
  21193. NERR_DestNotFound                 2152    The print destination was not
  21194.                                            found.
  21195.  
  21196.  NERR_QExists                      2154    A printer queue with this name
  21197.                                            already exists.
  21198.  
  21199.  NERR_QNoRoom                      2155    The server does not have enough
  21200.                                            memory available to add another
  21201.                                            printer queue.
  21202.  
  21203.  NERR_DestNoRoom                   2157    The server does not have enough
  21204.                                            memory available to add another
  21205.                                            printer.
  21206.  
  21207.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  21208.  
  21209.  NERR_DestInvalidState             2162    This operation cannot be
  21210.                                            performed on the print
  21211.                                            destination in its current state.
  21212.  Code                              Value   Meaning
  21213.  ────────────────────────────────────────────────────────────────────────────
  21214.                                           destination in its current state.
  21215.  
  21216.  NERR_SpoolNoMemory                2165    A spooler memory allocation
  21217.                                            failure occurred.
  21218.  
  21219.  NERR_DriverNotFound               2166    The device driver specified has
  21220.                                            not been installed on the
  21221.                                            computer.
  21222.  
  21223.  NERR_DataTypeInvalid              2167    The datatype is not supported by
  21224.                                            the queue's print processor.
  21225.  
  21226.  NERR_ProcNotFound                 2168    The print processor has not been
  21227.                                            installed on the server.
  21228.  
  21229.  NERR_BadDev                       2341    The devicename is invalid
  21230.                                            because it does not represent a
  21231.                                            physical device, or because the
  21232.                                            device hardware is faulty.
  21233.  Code                              Value   Meaning
  21234.  ────────────────────────────────────────────────────────────────────────────
  21235.                                           device hardware is faulty.
  21236.  
  21237.  NERR_CommDevInUse                 2343    The device is already used with
  21238.                                            a communication-device queue. It
  21239.                                            cannot be used with both
  21240.                                            communication-device queues and
  21241.                                            printer queues.
  21242.  
  21243.  NERR_InvalidComputer              2351    The specified computername is
  21244.                                            invalid.
  21245.  
  21246.  ────────────────────────────────────────────────────────────────────────────
  21247.  
  21248.  
  21249.  
  21250.  
  21251.  Remarks
  21252.  
  21253.  The PRQINFO data structure is provided only for compatibility with existing
  21254.  LAN Manager 1.0 applications. All new applications should use the PRQINFO3
  21255.  data structure.
  21256.  
  21257.  If the specified queuename is already in use on the server, DosPrintQAdd
  21258.  fails unless the queue is marked for pending deletion. In this case, the
  21259.  queue is not deleted and the parameters provided in DosPrintQAdd are used to
  21260.  set the values of the queue configuration. (The queuename is specified by
  21261.  the szName element of the PRQINFO data structure or by the pszName element
  21262.  of the PRQINFO3 data structure.)
  21263.  
  21264.  If the queuename exceeds the maximum legal length, ERROR_INVALID_PARAMETER
  21265.  is returned. The maximum legal length depends on the installed file system.
  21266.  
  21267.  
  21268.  A queue can be added successfully even if it is not connected to a printer.
  21269.  A queue can be added successfully on an MS OS/2 1.2 workstation.
  21270.  
  21271.  Applications that use the level 3 data structure PRQINFO3 can specify that
  21272.  the queue should use the default pDriverData value by supplying a null
  21273.  pointer for the pDriverData parameter; a new pszDriverName element will be
  21274.  supplied.
  21275.  
  21276.  See Also
  21277.  
  21278.  For information about             See
  21279.  ────────────────────────────────────────────────────────────────────────────
  21280.  Changing the parameters of a      DosPrintQSetInfo
  21281.  printer queue
  21282.  
  21283.  Deleting a printer queue          DosPrintQDel
  21284.  
  21285.  Listing a server's printer        DosPrintQEnum
  21286.  queues
  21287.  
  21288.  Retrieving information about a    DosPrintQGetInfo
  21289.  printer queue
  21290.  
  21291.  
  21292.  DosPrintQContinue
  21293.  ────────────────────────────────────────────────────────────────────────────
  21294.  
  21295.  DosPrintQContinue allows a paused printer queue to resume printing.
  21296.  
  21297.  
  21298.  Operating Systems Supported
  21299.  
  21300.  
  21301.    ■   MS OS/2 version 1.2, local and remote
  21302.  
  21303.    ■   MS OS/2 version 1.1, remote only
  21304.  
  21305.    ■   MS-DOS, remote only
  21306.  
  21307.  
  21308.  
  21309.  Privilege Level
  21310.  
  21311.  Admin privilege or print operator privilege is required to successfully
  21312.  execute DosPrintQContinue on a remote server or on a computer that has local
  21313.  security enabled.
  21314.  
  21315.  
  21316.  Syntax
  21317.  
  21318.    #define INCL_BASE
  21319.    #include <os2.h>
  21320.  
  21321.    #include <pmspl.h>
  21322.  
  21323.    #define INCL_NETERRORS
  21324.    #include <lan.h>
  21325.  
  21326.    SPLERR SPLENTRY
  21327.    DosPrintQContinue (PSZ  pszServer,
  21328.                       PSZ  pszQueueName
  21329.                      );
  21330.  
  21331.  where
  21332.  
  21333.  pszServer
  21334.    Points to an ASCIIZ string that contains the name of a server on which to
  21335.    execute DosPrintQContinue. A null pointer or null string specifies the
  21336.    local computer.
  21337.  
  21338.  pszQueueName
  21339.    Points to an ASCIIZ string that contains the name of the printer queue.
  21340.  
  21341.  Return Codes
  21342.  
  21343. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  21344.  Code                              Value   Meaning
  21345.  ────────────────────────────────────────────────────────────────────────────
  21346.  NERR_Success                      0       The function encountered no
  21347.                                            errors.
  21348.  
  21349.  ERROR_ACCESS_DENIED               5       The user has insufficient
  21350.                                            privilege for this operation.
  21351.  
  21352.  ERROR_BAD_NETPATH                 53      The network path was not found.
  21353.  
  21354.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  21355.  
  21356.  NERR_RemoteOnly                   2106    This operation can be performed
  21357.                                            only on a server.
  21358.  
  21359.  Code                              Value   Meaning
  21360.  ────────────────────────────────────────────────────────────────────────────
  21361. 
  21362.  NERR_BadTransactConfig            2141    The server is not configured for
  21363.                                            this transaction: IPC$ is not
  21364.                                            shared.
  21365.  
  21366.  NERR_QNotFound                    2150    The queuename specified is
  21367.                                            invalid.
  21368.  
  21369.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  21370.  
  21371.  NERR_QInvalidState                2163    This operation cannot be
  21372.                                            performed on the printer queue
  21373.                                            in its current state.
  21374.  
  21375.  NERR_InvalidComputer              2351    The specified computername is
  21376.                                            invalid.
  21377.  
  21378.  ────────────────────────────────────────────────────────────────────────────
  21379.  
  21380.  Code                              Value   Meaning
  21381.  ────────────────────────────────────────────────────────────────────────────
  21382. 
  21383.  
  21384.  
  21385.  
  21386.  Remarks
  21387.  
  21388.  DosPrintQContinue reenables a printer queue that has been paused by a call
  21389.  to DosPrintQPause or disabled by an error. DosPrintQContinue does not affect
  21390.  an active printer queue.
  21391.  
  21392.  See Also
  21393.  
  21394.  For information about             See
  21395.  ────────────────────────────────────────────────────────────────────────────
  21396.  Listing a server's printer        DosPrintQEnum
  21397.  queues
  21398.  
  21399.  Pausing a printer queue           DosPrintQPause
  21400.  
  21401.  Retrieving information about a    DosPrintQGetInfo
  21402.  printer queue
  21403.  
  21404.  
  21405.  
  21406.  
  21407.  DosPrintQDel
  21408.  ────────────────────────────────────────────────────────────────────────────
  21409.  
  21410.  DosPrintQDel deletes a printer queue from a server.
  21411.  
  21412.  
  21413.  Operating Systems Supported
  21414.  
  21415.  
  21416.    ■   MS OS/2 version 1.2, local and remote
  21417.  
  21418.    ■   MS OS/2 version 1.1, remote only
  21419.  
  21420.    ■   MS-DOS, remote only
  21421.  
  21422.  
  21423.  
  21424.  Privilege Level
  21425.  
  21426.  Admin privilege or print operator privilege is required to successfully
  21427.  execute DosPrintQDel on a remote server or on a computer that has local
  21428.  security enabled.
  21429.  
  21430.  
  21431.  Syntax
  21432.  
  21433.    #define INCL_BASE
  21434.    #include <os2.h>
  21435.  
  21436.    #include <pmspl.h>
  21437.  
  21438.    #define INCL_NETERRORS
  21439.    #include <lan.h>
  21440.  
  21441.    SPLERR SPLENTRY
  21442.    DosPrintQDel (PSZ  pszServer,
  21443.                  PSZ  pszQueueName
  21444.                 );
  21445.  
  21446.  where
  21447.  
  21448.  pszServer
  21449.    Points to an ASCIIZ string that contains the name of the server on which
  21450.    to execute DosPrintQDel. A null pointer or null string specifies the local
  21451.    computer.
  21452.  
  21453.  pszQueueName
  21454.    Points to an ASCIIZ string that specifies which printer queue to delete.
  21455.  
  21456.  Return Codes
  21457.  
  21458. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  21459.  Code                              Value   Meaning
  21460.  ────────────────────────────────────────────────────────────────────────────
  21461.  NERR_Success                      0       The function encountered no
  21462.                                            errors.
  21463.  
  21464.  Code                              Value   Meaning
  21465.  ────────────────────────────────────────────────────────────────────────────
  21466. 
  21467.  ERROR_ACCESS_DENIED               5       The user has insufficient
  21468.                                            privilege for this operation.
  21469.  
  21470.  ERROR_BAD_NETPATH                 53      The network path was not found.
  21471.  
  21472.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  21473.  
  21474.  NERR_RemoteOnly                   2106    This operation can be performed
  21475.                                            only on a server.
  21476.  
  21477.  NERR_BadTransactConfig            2141    The server is not configured for
  21478.                                            this transaction: IPC$ is not
  21479.                                            shared.
  21480.  
  21481.  NERR_QNotFound                    2150    The queuename specified is
  21482.                                            invalid.
  21483.  
  21484.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  21485.  Code                              Value   Meaning
  21486.  ────────────────────────────────────────────────────────────────────────────
  21487. NERR_SpoolerNotLoaded             2161    The spooler is not started.
  21488.  
  21489.  NERR_QInvalidState                2163    This operation cannot be
  21490.                                            performed on the printer queue
  21491.                                            in its current state.
  21492.  
  21493.  NERR_InvalidComputer              2351    The specified computername is
  21494.                                            invalid.
  21495.  
  21496.  ────────────────────────────────────────────────────────────────────────────
  21497.  
  21498.  
  21499.  
  21500.  
  21501.  Remarks
  21502.  
  21503.  If print jobs remain to be processed in a printer queue, DosPrintQDel marks
  21504.  the printer queue as "pending delete" so it cannot accept new jobs, and
  21505.  deletes the queue when all jobs have been printed.
  21506.  
  21507.  See Also
  21508.  
  21509.  For information about             See
  21510.  ────────────────────────────────────────────────────────────────────────────
  21511.  Canceling all print jobs in a     DosPrintQPurge
  21512.  printer queue
  21513.  
  21514.  Establishing a printer queue      DosPrintQAdd
  21515.  
  21516.  Listing a server's printer        DosPrintQEnum
  21517.  queues
  21518.  
  21519.  Retrieving information about a    DosPrintQGetInfo
  21520.  printer queue
  21521.  
  21522.  
  21523.  DosPrintQEnum
  21524.  ────────────────────────────────────────────────────────────────────────────
  21525.  
  21526.  DosPrintQEnum lists all printer queues on a server.
  21527.  
  21528.  
  21529.  Operating Systems Supported
  21530.  
  21531.  
  21532.    ■   MS OS/2 version 1.2, local and remote
  21533.  
  21534.    ■   MS OS/2 version 1.1, remote only
  21535.  
  21536.    ■   MS-DOS, remote only
  21537.  
  21538.  
  21539.  
  21540.  Privilege Level
  21541.  
  21542.  No special privilege level is required to successfully execute
  21543.  DosPrintQEnum.
  21544.  
  21545.  
  21546.  Syntax
  21547.  
  21548.    #define INCL_BASE
  21549.    #include <os2.h>
  21550.  
  21551.    #include <pmspl.h>
  21552.  
  21553.    #define INCL_NETERRORS
  21554.    #include <lan.h>
  21555.  
  21556.    SPLERR SPLENTRY
  21557.    DosPrintQEnum (PSZ      pszServer,
  21558.                   USHORT   uLevel,
  21559.                   PSZ      pbBuf,
  21560.                   USHORT   cbBuf,
  21561.                   PUSHORT  pcReturned,
  21562.                   PUSHORT  pcTotal
  21563.                  );
  21564.  
  21565.  where
  21566.  
  21567.  pszServer
  21568.    Points to an ASCIIZ string that contains the name of the server on which
  21569.    to execute DosPrintQEnum. A null pointer or null string specifies the
  21570.    local computer.
  21571.  
  21572.  uLevel
  21573.    Specifies the level of detail (0, 1, 2, 3, 4, or 5) requested.
  21574.  
  21575.  pbBuf
  21576.    Points to the buffer in which to store the returned data. On a successful
  21577.    return, the buffer contains a sequence of data structures corresponding to
  21578.    the level of detail requested.
  21579.  
  21580.  cbBuf
  21581.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  21582.  
  21583.  pcReturned
  21584.    Points to an unsigned short integer that specifies the number of entries
  21585.    returned in the buffer pointed to by pbBuf. This count is valid only if
  21586.    DosPrintQEnum returns NERR_Success or ERROR_MORE_DATA.
  21587.  
  21588.  pcTotal
  21589.    Points to an unsigned short integer that specifies the total number of
  21590.    entries available. This count is valid only if DosPrintQEnum returns
  21591.    NERR_Success or ERROR_MORE_DATA.
  21592.  
  21593.  Return Codes
  21594.  
  21595. ╓┌──────────────────────┌───────┌────────────────────────────────────────────╖
  21596.  Code                   Value   Meaning
  21597.  ────────────────────────────────────────────────────────────────────────────
  21598.  NERR_Success           0       The function encountered no errors.
  21599.  
  21600.  ERROR_BAD_NETPATH      53      The network path was not found.
  21601.  
  21602.  ERROR_INVALID_LEVEL    124     The level for information retrieval or
  21603.                                 setting is invalid.
  21604.  
  21605.  ERROR_MORE_DATA        234     Additional data is available.
  21606.  
  21607.  NERR_NetNotStarted     2102    The LAN Manager NETWKSTA driver is not
  21608.                                 installed.
  21609.  
  21610.  NERR_RemoteOnly        2106    This operation can be performed only on a
  21611.  Code                   Value   Meaning
  21612.  ────────────────────────────────────────────────────────────────────────────
  21613. NERR_RemoteOnly        2106    This operation can be performed only on a
  21614.                                 server.
  21615.  
  21616.  NERR_SpoolerNotLoaded  2161    The spooler is not started.
  21617.  
  21618.  NERR_InvalidComputer   2351    The specified computername is invalid.
  21619.  
  21620.  ────────────────────────────────────────────────────────────────────────────
  21621.  
  21622.  
  21623.  
  21624.  
  21625.  Remarks
  21626.  
  21627.  Levels 0, 1, and 2 are provided only for compatibility with existing LAN
  21628.  Manager 1.0 applications and should not be used in new applications. All new
  21629.  applications should use levels 3, 4, and 5.
  21630.  
  21631.  Levels 0, 1, and 2 return queuenames only if the number of bytes in the
  21632.  queuename is less than or equal to QNLEN. (The constant QNLEN is defined in
  21633.  the PMSPL.H header file.) At levels 0, 1, and 2, the values of pcReturned
  21634.  and pcTotal are set to the count of queues with short names. At levels 3, 4,
  21635.  and 5, all queuenames are returned, and the values pcReturned and pcTotal
  21636.  represent the count of all queues.
  21637.  
  21638.  See Also
  21639.  
  21640.  For information about             See
  21641.  ────────────────────────────────────────────────────────────────────────────
  21642.  Retrieving information about a    DosPrintQGetInfo
  21643.  printer queue
  21644.  
  21645.  
  21646.  DosPrintQGetInfo
  21647.  ────────────────────────────────────────────────────────────────────────────
  21648.  
  21649.  DosPrintQGetInfo retrieves information about a particular printer queue on a
  21650.  server.
  21651.  
  21652.  
  21653.  Operating Systems Supported
  21654.  
  21655.  
  21656.    ■   MS OS/2 version 1.2, local and remote
  21657.  
  21658.    ■   MS OS/2 version 1.1, remote only
  21659.  
  21660.    ■   MS-DOS, remote only
  21661.  
  21662.  
  21663.  
  21664.  Privilege Level
  21665.  
  21666.  No special privilege level is required to successfully execute
  21667.  DosPrintQGetInfo.
  21668.  
  21669.  
  21670.  Syntax
  21671.  
  21672.    #define INCL_BASE
  21673.    #include <os2.h>
  21674.  
  21675.    #include <pmspl.h>
  21676.  
  21677.    #define INCL_NETERRORS
  21678.    #include <lan.h>
  21679.  
  21680.    SPLERR SPLENTRY
  21681.    DosPrintQGetInfo (PSZ      pszServer,
  21682.                      PSZ      pszQueueName,
  21683.                      USHORT   uLevel,
  21684.                      PSZ      pbBuf,
  21685.                      USHORT   cbBuf,
  21686.                      PUSHORT  pcbNeeded
  21687.                     );
  21688.  
  21689.  where
  21690.  
  21691.  pszServer
  21692.    Points to an ASCIIZ string that contains the name of the server on which
  21693.    to execute DosPrintQGetInfo. A null pointer or null string specifies the
  21694.    local computer.
  21695.  
  21696.  pszQueueName
  21697.    Points to an ASCIIZ string that contains the name of the printer queue.
  21698.  
  21699.  uLevel
  21700.    Specifies the level of detail (0, 1, 2, 3, 4, or 5) requested.
  21701.  
  21702.  pbBuf
  21703.    Points to the buffer in which to store the return data. On a successful
  21704.    return, the buffer contains a sequence of data structures corresponding to
  21705.    the level of detail requested.
  21706.  
  21707.  cbBuf
  21708.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  21709.  
  21710.  pcbNeeded
  21711.    Points to an unsigned short integer that specifies the number of bytes of
  21712.    information available. This count is valid only if DosPrintQGetInfo
  21713.    returns NERR_Success, ERROR_MORE_DATA, or NERR_BufTooSmall.
  21714.  
  21715.  Return Codes
  21716.  
  21717. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  21718.  Code                              Value   Meaning
  21719.  ────────────────────────────────────────────────────────────────────────────
  21720.  NERR_Success                      0       The function encountered no
  21721.                                            errors.
  21722.  
  21723.  ERROR_BAD_NETPATH                 53      The network path was not found.
  21724.  
  21725.  ERROR_INVALID_LEVEL               124     The level for information
  21726.                                            retrieval or setting is invalid.
  21727.  
  21728.  ERROR_FILENAME_EXCED_RANGE        206     The filename specified is
  21729.                                            invalid for the file system.
  21730.                                            This code is returned when
  21731.                                            checking a FAT disk partition
  21732.                                            only. It cannot be returned for
  21733.                                            an HPFS partition.
  21734.  
  21735.  ERROR_MORE_DATA                   234     Additional data is available.
  21736.  
  21737.  Code                              Value   Meaning
  21738.  ────────────────────────────────────────────────────────────────────────────
  21739. 
  21740.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  21741.                                            is not installed.
  21742.  
  21743.  NERR_RemoteOnly                   2106    This operation can be performed
  21744.                                            only on a server.
  21745.  
  21746.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  21747.  
  21748.  NERR_QNotFound                    2150    The queuename specified is
  21749.                                            invalid.
  21750.  
  21751.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  21752.  
  21753.  NERR_InvalidComputer              2351    The specified computername is
  21754.                                            invalid.
  21755.  
  21756.  ────────────────────────────────────────────────────────────────────────────
  21757.  
  21758.  Code                              Value   Meaning
  21759.  ────────────────────────────────────────────────────────────────────────────
  21760. 
  21761.  
  21762.  
  21763.  
  21764.  Remarks
  21765.  
  21766.  Levels 0, 1, and 2 are provided for compatibility with existing LAN Manager
  21767.  1.0 applications and should not be used in new applications. All new
  21768.  applications should use levels 3, 4, and 5.
  21769.  
  21770.  Levels 0, 1, and 2 return queuenames only if the number of bytes in the
  21771.  queuename is less than or equal to QNLEN. (The constant QNLEN is defined in
  21772.  the PMSPL.H header file.) At levels 0, 1, and 2, the values of pcReturned
  21773.  and pcTotal are set to the count of queues with short names. At levels 3, 4,
  21774.  and 5, all queuenames are returned, and the values pcReturned and pcTotal
  21775.  represent the count of all queues.
  21776.  
  21777.  When a new data structure is directed to a server that runs an earlier
  21778.  version of LAN Manager (a down-level server), the elements uPriority,
  21779.  pszPrProc, and pszPrinters are given default values. The element pszPrProc
  21780.  points to the string "LM10," pszPrinters points to a list of port names
  21781.  separated by commas, and uPriority has the value PRJ_NO_PRIORITY.
  21782.  
  21783.  See Also
  21784.  
  21785.  For information about             See
  21786.  ────────────────────────────────────────────────────────────────────────────
  21787.  Finding out a print job's         DosPrintJobGetInfo
  21788.  position in a queue
  21789.  
  21790.  Listing a server's printer        DosPrintQEnum
  21791.  queues
  21792.  
  21793.  Modifying the configuration of a  DosPrintQSetInfo
  21794.  printer queue
  21795.  
  21796.  
  21797.  DosPrintQPause
  21798.  ────────────────────────────────────────────────────────────────────────────
  21799.  
  21800.  DosPrintQPause pauses the operation of a printer queue, suspending
  21801.  processing of all print jobs except the current job. A paused queue accepts
  21802.  new jobs.
  21803.  
  21804.  
  21805.  Operating Systems Supported
  21806.  
  21807.  
  21808.    ■   MS OS/2 version 1.2, local and remote
  21809.  
  21810.    ■   MS OS/2 version 1.1, remote only
  21811.  
  21812.    ■   MS-DOS, remote only
  21813.  
  21814.  
  21815.  
  21816.  Privilege Level
  21817.  
  21818.  Admin privilege or print operator privilege is required to successfully
  21819.  execute DosPrintQPause on a remote server or on a computer that has local
  21820.  security enabled.
  21821.  
  21822.  
  21823.  Syntax
  21824.  
  21825.    #define INCL_BASE
  21826.    #include <os2.h>
  21827.  
  21828.    #include <pmspl.h>
  21829.  
  21830.    #define INCL_NETERRORS
  21831.    #include <lan.h>
  21832.  
  21833.    SPLERR SPLENTRY
  21834.    DosPrintQPause (PSZ  pszServer,
  21835.                    PSZ  pszQueueName
  21836.                   );
  21837.  
  21838.  where
  21839.  
  21840.  pszServer
  21841.    Points to an ASCIIZ string that contains the name of the server on which
  21842.    to execute DosPrintQPause. A null pointer or null string specifies the
  21843.    local computer.
  21844.  
  21845.  pszQueueName
  21846.    Points to an ASCIIZ string that specifies which printer queue to pause.
  21847.  
  21848.  Return Codes
  21849.  
  21850. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  21851.  Code                              Value   Meaning
  21852.  ────────────────────────────────────────────────────────────────────────────
  21853.  NERR_Success                      0       The function encountered no
  21854.                                            errors.
  21855.  
  21856.  ERROR_ACCESS_DENIED               5       The user has insufficient
  21857.                                            privilege for this operation.
  21858.  
  21859.  ERROR_BAD_NETPATH                 53      The network path was not found.
  21860.  
  21861.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  21862.  
  21863.  Code                              Value   Meaning
  21864.  ────────────────────────────────────────────────────────────────────────────
  21865. 
  21866.  NERR_RemoteOnly                   2106    This operation can be performed
  21867.                                            only on a server.
  21868.  
  21869.  NERR_BadTransactConfig            2141    The server is not configured for
  21870.                                            this transaction: IPC$ is not
  21871.                                            shared.
  21872.  
  21873.  NERR_QNotFound                    2150    The queuename specified is
  21874.                                            invalid.
  21875.  
  21876.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  21877.  
  21878.  NERR_InvalidComputer              2351    The specified computername is
  21879.                                            invalid.
  21880.  
  21881.  ────────────────────────────────────────────────────────────────────────────
  21882.  
  21883.  
  21884.  
  21885.  
  21886.  Remarks
  21887.  
  21888.  Pausing a printer queue suspends processing of all print jobs in the queue
  21889.  except the job that is printing. A paused queue can accept submitted print
  21890.  jobs, but it holds them in the queue until a call to DosPrintQContinue
  21891.  allows the queue to resume printing.
  21892.  
  21893.  See Also
  21894.  
  21895.  For information about             See
  21896.  ────────────────────────────────────────────────────────────────────────────
  21897.  Continuing a paused printer       DosPrintQContinue
  21898.  queue
  21899.  
  21900.  Finding out the position of a     DosPrintJobGetInfo
  21901.  print job in a printer queue
  21902.  
  21903.  Retrieving information about a    DosPrintQGetInfo
  21904.  printer queue
  21905.  
  21906.  
  21907.  DosPrintQPurge
  21908.  ────────────────────────────────────────────────────────────────────────────
  21909.  
  21910.  DosPrintQPurge removes all pending jobs in a printer queue, leaving only
  21911.  currently printing jobs.
  21912.  
  21913.  
  21914.  Operating Systems Supported
  21915.  
  21916.  
  21917.    ■   MS OS/2 version 1.2, local and remote
  21918.  
  21919.    ■   MS OS/2 version 1.1, remote only
  21920.  
  21921.    ■   MS-DOS, remote only
  21922.  
  21923.  
  21924.  
  21925.  Privilege Level
  21926.  
  21927.  Admin privilege or print operator privilege is required to successfully
  21928.  execute DosPrintQPurge on a remote server or on a computer that has local
  21929.  security enabled.
  21930.  
  21931.  
  21932.  Syntax
  21933.  
  21934.    #define INCL_BASE
  21935.    #include <os2.h>
  21936.  
  21937.    #include <pmspl.h>
  21938.  
  21939.    #define INCL_NETERRORS
  21940.    #include <lan.h>
  21941.  
  21942.    SPLERR SPLENTRY
  21943.    DosPrintQPurge (PSZ  pszServer,
  21944.                    PSZ  pszQueueName
  21945.                   );
  21946.  
  21947.  where
  21948.  
  21949.  pszServer
  21950.    Points to an ASCIIZ string that contains the name of the server on which
  21951.    to execute DosPrintQPurge. A null pointer or null string specifies the
  21952.    local computer.
  21953.  
  21954.  pszQueueName
  21955.    Points to an ASCIIZ string that specifies which printer queue to purge.
  21956.  
  21957.  Return Codes
  21958.  
  21959. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  21960.  Code                              Value   Meaning
  21961.  ────────────────────────────────────────────────────────────────────────────
  21962.  NERR_Success                      0       The function encountered no
  21963.                                            errors.
  21964.  
  21965.  ERROR_ACCESS_DENIED               5       The user has insufficient
  21966.                                            privilege for this operation.
  21967.  
  21968.  Code                              Value   Meaning
  21969.  ────────────────────────────────────────────────────────────────────────────
  21970. 
  21971.  ERROR_BAD_NETPATH                 53      The network path was not found.
  21972.  
  21973.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  21974.  
  21975.  NERR_RemoteOnly                   2106    This operation can be performed
  21976.                                            only on a server.
  21977.  
  21978.  NERR_BadTransactConfig            2141    The server is not configured for
  21979.                                            this transaction: IPC$ is not
  21980.                                            shared.
  21981.  
  21982.  NERR_QNotFound                    2150    The queuename specified is
  21983.                                            invalid.
  21984.  
  21985.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  21986.  
  21987.  NERR_InvalidComputer              2351    The specified computername is
  21988.                                            invalid.
  21989.  Code                              Value   Meaning
  21990.  ────────────────────────────────────────────────────────────────────────────
  21991.                                           invalid.
  21992.  
  21993.  ────────────────────────────────────────────────────────────────────────────
  21994.  
  21995.  
  21996.  
  21997.  
  21998.  Remarks
  21999.  
  22000.  DosPrintQPurge does not affect a print job already sent to a print
  22001.  destination.
  22002.  
  22003.  If a printer queue is pending deletion when DosPrintQPurge is called, the
  22004.  purge clears the way for the printer queue to be deleted at the end of the
  22005.  current printing.
  22006.  
  22007.  See Also
  22008.  
  22009.  For information about             See
  22010.  ────────────────────────────────────────────────────────────────────────────
  22011.  Listing a server's printer        DosPrintQEnum
  22012.  queues
  22013.  
  22014.  Listing the print jobs in a       DosPrintQGetInfo
  22015.  printer queue
  22016.  
  22017.  Retrieving information about a    DosPrintQGetInfo
  22018.  printer queue
  22019.  
  22020.  
  22021.  DosPrintQSetInfo
  22022.  ────────────────────────────────────────────────────────────────────────────
  22023.  
  22024.  DosPrintQSetInfo modifies the configuration of a printer queue.
  22025.  
  22026.  
  22027.  Operating Systems Supported
  22028.  
  22029.  
  22030.    ■   MS OS/2 version 1.2, local and remote
  22031.  
  22032.    ■   MS OS/2 version 1.1, remote only
  22033.  
  22034.    ■   MS-DOS, remote only
  22035.  
  22036.  
  22037.  
  22038.  Privilege Level
  22039.  
  22040.  Admin privilege or print operator privilege is required to successfully
  22041.  execute DosPrintQSetInfo on a remote server or on a computer that has local
  22042.  security enabled.
  22043.  
  22044.  
  22045.  Syntax
  22046.  
  22047.    #define INCL_BASE
  22048.    #include <os2.h>
  22049.  
  22050.    #include <pmspl.h>
  22051.  
  22052.    #define INCL_NETERRORS
  22053.    #include <lan.h>
  22054.  
  22055.    SPLERR SPLENTRY
  22056.    DosPrintQSetInfo (PSZ     pszServer,
  22057.                      PSZ     pszQueueName,
  22058.                      USHORT  uLevel,
  22059.                      PSZ     pbBuf,
  22060.                      USHORT  cbBuf,
  22061.                      USHORT  uParmNum
  22062.                     );
  22063.  
  22064.  where
  22065.  
  22066.  pszServer
  22067.    Points to an ASCIIZ string that contains the name of the server on which
  22068.    to execute DosPrintQSetInfo. A null pointer or null string specifies the
  22069.    local computer.
  22070.  
  22071.  pszQueueName
  22072.    Points to an ASCIIZ string that specifies which printer queue is to be
  22073.    modified.
  22074.  
  22075.  uLevel
  22076.    Contains an unsigned short integer that specifies the level of detail (1
  22077.    or 3) provided.
  22078.  
  22079.  pbBuf
  22080.    Points to the provided data structure or component.
  22081.  
  22082.  cbBuf
  22083.    Specifies the size (in bytes) of the buffer pointed to by pbBuf.
  22084.  
  22085.  uParmNum
  22086.    Specifies whether to set all printer queue information or to set only a
  22087.    part of it. If uParmNum is PARMNUM_ALL, pbBuf must point to a PRQINFO or
  22088.    PRQINFO3 data structure. If uParmNum is any other defined value, only one
  22089.    element of the printer queue information is changed, and  pbBuf must point
  22090.    to a valid value for that element.
  22091.  
  22092.    Not all elements can be set. Only those elements that have a specific
  22093.    PARMNUM constant value defined can be set. The PMSPL.H header file defines
  22094.    these possible values for uParmNum:
  22095.  
  22096. ╓┌─────────────────────────┌──────┌──────────────────────────────────────────╖
  22097.                                   Element of PRQINFO and PRQINFO3
  22098.  Code                      Value
  22099.  ────────────────────────────────────────────────────────────────────────────
  22100.  PARMNUM_ALL               0      All elements.
  22101.  
  22102.  PRQ_PRIORITY_PARMNUM      2      uPriority
  22103.  
  22104.  PRQ_STARTTIME_PARMNUM     3      uStarttime
  22105.  
  22106.  PRQ_UNTILTIME_PARMNUM     4      uUntiltime
  22107.  
  22108.  PRQ_SEPARATOR_PARMNUM     5      pszSepFile
  22109.  
  22110.  PRQ_PROCESSOR_PARMNUM     6      pszPrProc
  22111.  
  22112.  PRQ_DESTINATIONS_PARMNUM  7      pszDestinations (level 1 only)
  22113.  
  22114.  PRQ_PARMS_PARMNUM         8      pszParms
  22115.                                   Element of PRQINFO and PRQINFO3
  22116.  Code                      Value
  22117.  ────────────────────────────────────────────────────────────────────────────
  22118. PRQ_PARMS_PARMNUM         8      pszParms
  22119.  
  22120.  PRQ_COMMENT_PARMNUM       9      pszComment
  22121.  
  22122.  PRQ_PRINTERS_PARMNUM      12     pszPrinters (level 3 only)
  22123.  
  22124.  PRQ_DRIVERNAME_PARMNUM    13     pszDriverName (level 3 only)
  22125.  
  22126.  PRQ_DRIVERDATA_PARMNUM    14     pDriverData (level 3 only)
  22127.  
  22128.  ────────────────────────────────────────────────────────────────────────────
  22129.  
  22130.  
  22131.  
  22132.  Return Codes
  22133.  
  22134. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  22135.  Code                              Value   Meaning
  22136.  Code                              Value   Meaning
  22137.  ────────────────────────────────────────────────────────────────────────────
  22138.  NERR_Success                      0       The function encountered no
  22139.                                            errors.
  22140.  
  22141.  ERROR_ACCESS_DENIED               5       The user has insufficient
  22142.                                            privilege for this operation.
  22143.  
  22144.  ERROR_BAD_NETPATH                 53      The network path was not found.
  22145.  
  22146.  
  22147.  
  22148.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  22149.  
  22150.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  22151.                                            invalid.
  22152.  
  22153.  ERROR_INVALID_LEVEL               124     The level for information
  22154.                                            retrieval or setting is invalid.
  22155.  
  22156.  NERR_RemoteOnly                   2106    This operation can be performed
  22157.  Code                              Value   Meaning
  22158.  ────────────────────────────────────────────────────────────────────────────
  22159. NERR_RemoteOnly                   2106    This operation can be performed
  22160.                                            only on a server.
  22161.  
  22162.  NERR_RedirectedPath               2117    The operation is invalid for a
  22163.                                            redirected resource. The
  22164.                                            devicename specified is assigned
  22165.                                            to a shared resource.
  22166.  
  22167.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  22168.  
  22169.  NERR_BadTransactConfig            2141    The server is not configured for
  22170.                                            this transaction: IPC$ is not
  22171.                                            shared.
  22172.  
  22173.  NERR_QNotFound                    2150    The queuename specified is
  22174.                                            invalid.
  22175.  
  22176.  NERR_DestNotFound                 2152    The print destination was not
  22177.                                            found.
  22178.  Code                              Value   Meaning
  22179.  ────────────────────────────────────────────────────────────────────────────
  22180.                                           found.
  22181.  
  22182.  NERR_DestNoRoom                   2157    The server does not have enough
  22183.                                            memory available to add another
  22184.                                            printer.
  22185.  
  22186.  NERR_SpoolerNotLoaded             2161    The spooler is not started.
  22187.  
  22188.  NERR_DestInvalidState             2162    This operation cannot be
  22189.                                            performed on the print
  22190.                                            destination in its current state.
  22191.  
  22192.  NERR_SpoolNoMemory                2165    A spooler memory allocation
  22193.                                            failure occurred.
  22194.  
  22195.  NERR_DriverNotFound               2166    The device driver specified has
  22196.                                            not been installed on the
  22197.                                            computer.
  22198.  
  22199.  Code                              Value   Meaning
  22200.  ────────────────────────────────────────────────────────────────────────────
  22201. 
  22202.  NERR_DataTypeInvalid              2167    The datatype is not supported by
  22203.                                            the queue's print processor.
  22204.  
  22205.  NERR_ProcNotFound                 2168    The print processor has not been
  22206.                                            installed on the server.
  22207.  
  22208.  NERR_BadDev                       2341    The devicename is invalid
  22209.                                            because it does not represent a
  22210.                                            physical device, or because the
  22211.                                            device hardware is faulty.
  22212.  
  22213.  
  22214.  NERR_CommDevInUse                 2343    The device is already used with
  22215.                                            a communication-device queue. It
  22216.                                            cannot be used with both
  22217.                                            communication-device queues and
  22218.                                            printer queues.
  22219.  
  22220.  Code                              Value   Meaning
  22221.  ────────────────────────────────────────────────────────────────────────────
  22222. 
  22223.  NERR_InvalidComputer              2351    The specified computername is
  22224.                                            invalid.
  22225.  
  22226.  ────────────────────────────────────────────────────────────────────────────
  22227.  
  22228.  
  22229.  
  22230.  
  22231.  Remarks
  22232.  
  22233.  The PRQINFO data structure is provided only for compatibility with existing
  22234.  LAN Manager 1.0 applications. All new applications should use the PRQINFO3
  22235.  data structure.
  22236.  
  22237.  If the uPriority element of the PRQINFO3 data structure is set to
  22238.  PRQ_NO_PRIORITY, the queue priority is not changed.
  22239.  
  22240.  If a null pointer is provided for the pDriverData element of the PRQINFO3
  22241.  data structure, the spooler provides the default driver data.
  22242.  
  22243.  When a new data structure is directed to a server that is running an earlier
  22244.  version of LAN Manager (a down-level server), the PRQ_DRIVERNAME_PARMNUM and
  22245.  PRQ_DRIVERDATA_PARMNUM parameter number codes are not supported. The
  22246.  function returns ERROR_NOT_SUPPORTED for these codes. If the entire
  22247.  structure is passed, these unsupported entries are ignored. The code
  22248.  PRQ_PRINTERS_PARMNUM is interpreted as PRQ_DESTINATIONS_PARMNUM, and commas
  22249.  that are used as delimiters are replaced by blanks.
  22250.  
  22251.  See Also
  22252.  
  22253.  For information about             See
  22254.  ────────────────────────────────────────────────────────────────────────────
  22255.  Establishing a printer queue      DosPrintQAdd
  22256.  
  22257.  Listing the printer queues on a   DosPrintQEnum
  22258.  server
  22259.  
  22260.  Retrieving a print job's          DosPrintJobGetId
  22261.  identification number
  22262.  
  22263.  Retrieving the configuration of   DosPrintQGetInfo
  22264.  a printer queue
  22265.  
  22266.  
  22267.  
  22268.  
  22269.  
  22270.  Printer Queue Category Example
  22271.  
  22272.    /*
  22273.       NETPRQ.C -- a program demonstrating the DosPrintQ API functions.
  22274.  
  22275.       This sample program demonstrates how to add a printer queue using
  22276.  
  22277.       DosPrintQAdd, then pauses the queue using DosPrintQPause and calls
  22278.       DosPrintQGetInfo to display its status. The queue priority is
  22279.       modified using DosPrintQSetInfo, and the new priority is displayed
  22280.       using DosPrintQEnum. DosPrintQPurge is called to purge all jobs
  22281.       from the queue, and then DosPrintQContinue allows the paused printer
  22282.       queue to continue. DosPrintQDel deletes the printer queue.
  22283.  
  22284.       usage:  netprj [-s \\server] [-l level] [-p priority] [-q queue]
  22285.                      [-f flag] [-c comment]
  22286.       where  \\server = Name of the server. A servername must be preceded
  22287.  
  22288.                         by two backslashes (\\).
  22289.              level    = Level of detail.
  22290.              priority = Priority of the queue.
  22291.              queue    = Name of the printer queue.
  22292.              flag     = Flag to delete the queue; 0 = no, 1 = yes.
  22293.              comment  = Queue's comment (enclose in quotes).
  22294.  
  22295.        API                     Used to...
  22296.        =================       ============================================
  22297.        DosPrintQAdd            Add a new printer queue
  22298.        DosPrintQContinue       Continue a paused printer queue
  22299.        DosPrintQDel            Delete the printer queue
  22300.        DosPrintQEnum           List all printer queues available
  22301.        DosPrintQGetInfo        Get specific info on a single printer
  22302.    queue
  22303.        DosPrintQPause          Pause the printer queue
  22304.        DosPrintQPurge          Delete all jobs from the printer queue
  22305.        DosPrintQSetInfo        Set specific info for a single printer
  22306.    queue
  22307.  
  22308.       This code sample is provided for demonstration purposes only.
  22309.       Microsoft makes no warranty, either express or implied,
  22310.       as to its usability in any given situation.
  22311.    */
  22312.  
  22313.    #define  INCL_BASE
  22314.    #include <os2.h>            // MS OS/2 base header files
  22315.    #include <pmspl.h>          // Print definitions
  22316.  
  22317.    #define  INCL_NETERRORS
  22318.    #include <lan.h>            // LAN Manager header files
  22319.  
  22320.    #include <stdio.h>          // C run-time header files
  22321.    #include <stdlib.h>
  22322.    #include <string.h>
  22323.    #include "samples.h"        // Internal routine header file
  22324.  
  22325.    #define DEFAULT_BUFFER_SIZE  1024
  22326.    #define MAX_BUFFER_SIZE      32768
  22327.    #define DEFAULT_PRIORITY     9
  22328.    #define NEW_PRIORITY         1
  22329.    #define NEWCOMMENT           "Print q built by example program"
  22330.    #define NEWQUEUENAME         "PRINTQ0"
  22331.  
  22332.    void DisplayInfo(short sLevel, char *pbBuffer, unsigned short cEntries);
  22333.    void Usage(char *pszString);
  22334.  
  22335.    void main(int argc, char *argv[])
  22336.    {
  22337.       char *          pbBuffer;            // Buffer for return data
  22338.       char *          pszServer = "";      // Default to local computer
  22339.       char far *      pszQueueName = NEWQUEUENAME;
  22340.       char far *      pszComment = NEWCOMMENT;
  22341.       int             iCount;              // Index, loop counter
  22342.       PRQINFO3        prq3;                // Level 3 data structure
  22343.       short           sLevel = 3;          // Level of detail
  22344.       unsigned        uRet;                // Return code
  22345.       unsigned short  fDone;               // Flag successful call
  22346.       unsigned short  fDelete = TRUE;      // Delete queue flag
  22347.       unsigned short  cEntriesRead;        // Count of entries read
  22348.       unsigned short  cEntriesTotal;       // Count of entries available
  22349.  
  22350.       unsigned short  cbBuffer = 0;        // Count of bytes read
  22351.       unsigned short  cbBufferNeeded = 0;  // Count of bytes needed
  22352.       unsigned short  uPriority = NEW_PRIORITY;// Used to set queue
  22353.  
  22354.       for (iCount = 1; iCount < argc; iCount++) // Get command-line switches
  22355.       {
  22356.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  22357.          {
  22358.             switch (tolower(*(argv[iCount]+1))) // Process switches
  22359.             {
  22360.                case 's':                        // -s servername
  22361.                   pszServer = argv[++iCount];
  22362.                   break;
  22363.                case 'p':                        // -p priority
  22364.                   uPriority = atoi(argv[++iCount]);
  22365.                   break;
  22366.                case 'l':                        // -l level
  22367.                   sLevel = atoi(argv[++iCount]);
  22368.                   break;
  22369.                case 'q':                        // -q queuename
  22370.                   pszQueueName = argv[++iCount];
  22371.                   break;
  22372.                case 'c':                        // -c comment
  22373.                   pszComment = argv[++iCount];
  22374.                   break;
  22375.                case 'f':                        // -f flag deletion
  22376.                   fDelete = atoi(argv[++iCount]);
  22377.                   break;
  22378.                case 'h':
  22379.                default:
  22380.                   Usage(argv[0]);
  22381.             }
  22382.          }
  22383.          else
  22384.             Usage(argv[0]);
  22385.       } // End for loop
  22386.       printf("\nPrint Queue Category API Examples\n");
  22387.  
  22388.    //========================================================================
  22389.    //  DosPrintQAdd
  22390.    //
  22391.    //  This API adds a printer queue to the specified server.
  22392.    //========================================================================
  22393.  
  22394.       memset(&prq3, 0, sizeof(PRQINFO3));       // Initialize memory
  22395.    to zeros
  22396.       prq3.pszName = pszQueueName;              // Set names
  22397.       prq3.uPriority = DEFAULT_PRIORITY;
  22398.       prq3.pszComment = pszComment;
  22399.  
  22400.       uRet = DosPrintQAdd(pszServer,            // Servername
  22401.                           3,                    // Level
  22402.                           (char far *)&prq3,    // New printer structure
  22403.                           sizeof(PRQINFO3));    // Size of buffer
  22404.       printf("DosPrintQAdd returned %u\n", uRet);
  22405.       if (uRet == NERR_Success)
  22406.       {
  22407.          printf("%Fs added to ", prq3.pszName);
  22408.          if ((pszServer == NULL) || (*pszServer == '\0'))
  22409.             printf("the local computer\n");
  22410.          else
  22411.             printf("%s\n", pszServer);
  22412.          printf("Priority set to %hu\n", prq3.uPriority);
  22413.       }
  22414.  
  22415.    //========================================================================
  22416.    //  DosPrintQPause
  22417.    //
  22418.    //  This API pauses the specified printer queue.
  22419.    //========================================================================
  22420.  
  22421.       uRet = DosPrintQPause(pszServer,          // Servername
  22422.                             pszQueueName);      // Queuename
  22423.       printf("DosPrintQPause returned %u\n", uRet);
  22424.  
  22425.    //========================================================================
  22426.    //  DosPrintQGetInfo
  22427.    //
  22428.    //  This API returns information about a specific printer queue.
  22429.    //========================================================================
  22430.  
  22431.       // Call with zero-length buffer, expect NERR_BufTooSmall
  22432.       uRet = DosPrintQGetInfo(pszServer,         // Servername
  22433.                                 pszQueueName,    // Queuename
  22434.                                 sLevel,          // Call level
  22435.                                 NULL,            // Buffer for info
  22436.                                 0,               // Size of buffer
  22437.                                 &cbBufferNeeded);// Required size
  22438.       if (uRet == NERR_BufTooSmall)
  22439.       {
  22440.          cbBuffer = cbBufferNeeded;
  22441.          pbBuffer = SafeMalloc(cbBuffer);  // SafeMalloc() in samples.c
  22442.          uRet = DosPrintQGetInfo(pszServer,      // Servername
  22443.                               pszQueueName,      // Queuename
  22444.                               sLevel,            // Call level
  22445.                               pbBuffer,          // Buffer for info
  22446.                               cbBuffer,          // Size of buffer
  22447.                               &cbBufferNeeded);  // Required size
  22448.          printf("DosPrintQGetInfo returned %u\n", uRet);
  22449.          if (uRet == NERR_Success)
  22450.             DisplayInfo(sLevel, pbBuffer, 1);    // Show return data
  22451.          free(pbBuffer);
  22452.       }
  22453.       else
  22454.          printf("DosPrintQGetInfo returned %u\n", uRet);
  22455.  
  22456.    //========================================================================
  22457.    //  DosPrintQSetInfo
  22458.    //
  22459.    //  This API controls print destination settings. DosPrintQSetInfo
  22460.    must
  22461.    //  be called using level 1 or level 3. In this example, a single
  22462.  
  22463.    //  element is set to the desired value. A program can also set all
  22464.  
  22465.    //  elements by setting the parameter number code to PARMNUM_ALL.
  22466.    //========================================================================
  22467.  
  22468.       prq3.uPriority = uPriority;               // Disconnect using SetInfo
  22469.       uRet = DosPrintQSetInfo(pszServer,        // Servername
  22470.                   pszQueueName,                 // Queuename
  22471.                   3,                            // Call level
  22472.                   (char far *)&(prq3.uPriority),// Data to set
  22473.                   sizeof(USHORT),               // Size of buffer
  22474.                   PRQ_PRIORITY_PARMNUM);        // Parameter number code
  22475.       printf("DosPrintQSetInfo returned %u\n", uRet);
  22476.  
  22477.    //========================================================================
  22478.    //  DosPrintQEnum
  22479.    //
  22480.    //  This API lists all printers connected to the specified server.
  22481.    //========================================================================
  22482.  
  22483.       cbBuffer = DEFAULT_BUFFER_SIZE;
  22484.       pbBuffer = SafeMalloc(cbBuffer); // SafeMalloc() is in samples.c
  22485.       do  // Until buffer is big enough to succeed
  22486.       {
  22487.          uRet = DosPrintQEnum (pszServer,      // Servername
  22488.                                sLevel,         // Call level
  22489.                                pbBuffer,       // Buffer for info
  22490.                                cbBuffer,       // Size of buffer
  22491.                                &cEntriesRead,  // Count of entries read
  22492.                                &cEntriesTotal);// Count of entries available
  22493.          if (uRet == ERROR_MORE_DATA)
  22494.          {
  22495.             free(pbBuffer);   // Buffer too small to hold data
  22496.             if (cbBuffer >= MAX_BUFFER_SIZE)
  22497.                exit(1);
  22498.             else if (cbBuffer > (MAX_BUFFER_SIZE/2))
  22499.                cbBuffer = MAX_BUFFER_SIZE;
  22500.             else
  22501.                cbBuffer += cbBuffer; // Allocate a larger one and try
  22502.    again
  22503.             pbBuffer = SafeMalloc(cbBuffer);  // SafeMalloc() in samples.c
  22504.                fDone = FALSE;
  22505.          }
  22506.  
  22507.    else
  22508.             fDone = TRUE;
  22509.       } while (fDone == FALSE); // Loop until buf big enough or call
  22510.    fails
  22511.       printf("DosPrintQEnum returned %u\n", uRet);
  22512.       if (uRet == NERR_Success)
  22513.       {
  22514.          printf("DosPrintQEnum read %hu ", cEntriesRead);
  22515.          printf(" out of %hu entries\n", cEntriesTotal);
  22516.          DisplayInfo(sLevel, pbBuffer, cEntriesRead);
  22517.       }
  22518.       free(pbBuffer);
  22519.  
  22520.    //=====================================================================
  22521.    //  DosPrintQPurge
  22522.    //
  22523.    //  This API deletes all jobs from the printer queue.
  22524.    //=====================================================================
  22525.  
  22526.       uRet = DosPrintQPurge(pszServer,          // Servername
  22527.                              pszQueueName);     // Queuename
  22528.       printf("DosPrintQPurge returned %u\n", uRet);
  22529.  
  22530.    //=====================================================================
  22531.    //  DosPrintQContinue
  22532.    //
  22533.    //  This API allows a paused printer queue to continue.
  22534.    //=====================================================================
  22535.  
  22536.       uRet = DosPrintQContinue(pszServer,      // Servername
  22537.                                pszQueueName);  // Queuename
  22538.       printf("DosPrintQContinue returned %u\n", uRet);
  22539.  
  22540.    //=====================================================================
  22541.    //  DosPrintQDel
  22542.    //
  22543.    //  This API deletes the printer queue. This sample program allows
  22544.    //  a command-line switch that prevents deletion of the queue.
  22545.    //=====================================================================
  22546.  
  22547.       if (fDelete == TRUE)
  22548.       {
  22549.          uRet = DosPrintQDel(pszServer,         // Servername
  22550.                              pszQueueName);     // Queuename
  22551.          printf("DosPrintQDel returned %u\n", uRet);
  22552.       }
  22553.       exit(0);
  22554.    }  // End of main
  22555.  
  22556.    //=====================================================================
  22557.    //  DisplayInfo
  22558.    //
  22559.    //  Displays printer queue information obtained by DosPrintQGetInfo
  22560.    or
  22561.    //  DosPrintQEnum.
  22562.    //
  22563.    //  Level 0:  Queuename
  22564.    //  Level 1:  PRQINFO data structure
  22565.    //  Level 2:  PRQINFO followed by PRJINFO for each job
  22566.    //  Level 3:  PRQINFO3 data structure
  22567.    //  Level 4:  PRQINFO3 followed by PRJINFO2 for each job
  22568.    //  Level 5:  Far pointer to queuename
  22569.    //=====================================================================
  22570.  
  22571.    void DisplayInfo(short sLevel, char *pbBuffer, unsigned short cEntries)
  22572.    {
  22573.       char *     pprq0;  // Level 0 data
  22574.       PPRQINFO   pprq1;  // Pointer to queue data provided at levels
  22575.    1, 2
  22576.       PPRJINFO   pprj1;  // Pointer to job data provided at level 2
  22577.       PPRJINFO2  pprj2;  // Pointer to job data provided at level 3
  22578.       PPRQINFO3  pprq3;  // Pointer to queue data provided at levels
  22579.    3, 4
  22580.       char far * far * pprq5;  // Pointer to level 5 data
  22581.       unsigned short iCount, iJobs, cJobs;  // Loop counters
  22582.  
  22583.       pprq0 = (char *) pbBuffer;            // Initialize pointers
  22584.       pprq1 = (PPRQINFO) pbBuffer;
  22585.       pprq3 = (PPRQINFO3) pbBuffer;
  22586.       pprq5 = (char far * far *) pbBuffer;
  22587.  
  22588.       for (iCount = 1; iCount <= cEntries; iCount++)
  22589.       {
  22590.          printf("\n");
  22591.          switch (sLevel)
  22592.          {
  22593.             case 0:                         // Level 0 data
  22594.                printf("Queue Name  :  %s\n", pprq0);
  22595.                pprq0 += (QNLEN + 1);
  22596.                break;
  22597.  
  22598.             case 1:                         // Level 1 data
  22599.                printf("Queue Name  :  %s\n", pprq1->szName);
  22600.                printf("Priority    :  %hu\n", pprq1->uPriority);
  22601.                printf("Comment     :  %Fs\n", pprq1->pszComment);
  22602.                printf("Jobs        :  %hu\n", pprq1->cJobs);
  22603.                printf("Queue Status:  0x%hx\n", pprq1->fsStatus);
  22604.                pprq1++;
  22605.                break;
  22606.  
  22607.             case 2:                         // Level 2 data
  22608.                printf("Queue Name  :  %s\n", pprq1->szName);
  22609.                printf("Priority    :  %hu\n", pprq1->uPriority);
  22610.                printf("Comment     :  %Fs\n", pprq1->pszComment);
  22611.                cJobs = pprq1->cJobs;
  22612.                printf("Jobs        :  %hu\n", cJobs);
  22613.                printf("Queue Status:  0x%hx\n", pprq1->fsStatus);
  22614.                pprq1++;
  22615.                pprj1 = (PPRJINFO) pprq1;
  22616.                for (iJobs = 0; iJobs < cJobs; iJobs++)
  22617.                {
  22618.                   printf("\n");
  22619.                   printf("  Job Id      :  %hu\n", pprj1->uJobId);
  22620.                   printf("  User Name   :  %s\n", pprj1->szUserName);
  22621.                   printf("  Position    :  %hu\n", pprj1->uPosition);
  22622.                   pprj1++;
  22623.                }
  22624.                pprq1 = (PPRQINFO) pprj1;
  22625.                break;
  22626.  
  22627.             case 3:                       // Level 3 data
  22628.                printf("Queue Name  :  %Fs\n", pprq3->pszName);
  22629.                printf("Priority    :  %hu\n", pprq3->uPriority);
  22630.                printf("Comment     :  %Fs\n", pprq3->pszComment);
  22631.                printf("Jobs        :  %hu\n", pprq3->cJobs);
  22632.                printf("Queue Status:  0x%hx\n", pprq3->fsStatus);
  22633.                pprq3++;
  22634.                break;
  22635.  
  22636.             case 4:                       // Level 4 data
  22637.                printf("Printer Name:  %s\n", pprq3->pszName);
  22638.                printf("Priority    :  %hu\n", pprq3->uPriority);
  22639.                printf("Comment     :  %Fs\n", pprq3->pszComment);
  22640.                cJobs = pprq3->cJobs;
  22641.                printf("Jobs        :  %hu\n", cJobs);
  22642.                printf("Queue Status:  0x%hx\n", pprq3->fsStatus);
  22643.                pprq3++;                   // Skip queue data
  22644.                pprj2 = (PPRJINFO2)pprq3;  // Examine job data
  22645.                for (iJobs = 0; iJobs < cJobs; iJobs++)
  22646.  
  22647.    {
  22648.                   printf("\n");
  22649.                   printf("  Job Id      :  %hu\n", pprj2->uJobId);
  22650.                   printf("  User Name   :  %Fs\n", pprj2->pszUserName);
  22651.                   printf("  Priority    :  %hu\n", pprj2->uPriority);
  22652.                   printf("  Document    :  %Fs\n", pprj2->pszDocument);
  22653.                   pprj2++;   // Bump to look at next print job structure
  22654.                }
  22655.  
  22656.    pprq3 = (PPRQINFO3) pprj2; // If next element, it
  22657.    is queue
  22658.                break;
  22659.  
  22660.             case 5:                       // Level 5 data
  22661.                printf("Queue Name  :  %Fs\n", *pprq5);
  22662.                pprq5++;
  22663.                break;
  22664.             default:                      // Undefined level
  22665.                break;
  22666.          } // End switch sLevel
  22667.       } // End for loop
  22668.    }  // End function
  22669.  
  22670.    //=====================================================================
  22671.    //  Usage
  22672.    //
  22673.    //  Display possible command-line switches for this sample program.
  22674.    //=====================================================================
  22675.  
  22676.    void Usage(char *pszString)
  22677.    {
  22678.       fprintf(stderr, "Usage: %s [-s \\\\server] [-l level]", pszString);
  22679.       fprintf(stderr, " [-p priority]\n\t[-q queuename] [-f flag delete]");
  22680.       fprintf(stderr, " [-c comment for queue]\n");
  22681.       exit(1);
  22682.    }
  22683.  
  22684.  
  22685.  
  22686.  
  22687.  
  22688.  
  22689.  
  22690.  
  22691.  
  22692.  Remote Utility Category
  22693.  
  22694.  Remote Utility API functions enable applications to copy and move remote
  22695.  files, execute a program remotely, and access the time-of-day information on
  22696.  a remote server. They require that the Workstation service be running on the
  22697.  local computer.
  22698.  
  22699.  The Remote Utility category functions, datatypes, structures, and constants
  22700.  are defined in the NETCONS.H, NETERR.H, and REMUTIL.H header files. A source
  22701.  program can access these definitions by defining the constants
  22702.  INCL_NETERRORS and INCL_NETREMUTIL, and including the master header file,
  22703.  LAN.H. For more information, see the "Example" section, later in this
  22704.  category.
  22705.  
  22706.  These are the Remote Utility API functions:
  22707.  
  22708.  
  22709.    ■   NetRemoteCopy
  22710.  
  22711.    ■   NetRemoteExec
  22712.  
  22713.    ■   NetRemoteMove
  22714.  
  22715.    ■   NetRemoteTOD
  22716.  
  22717.  
  22718.  
  22719.  Description
  22720.  
  22721.  NetRemoteCopy copies files on remote servers without copying the files
  22722.  physically to and from the local workstation.
  22723.  
  22724.  NetRemoteMove moves files or directories from one location to another on a
  22725.  remote server, without physically moving the data if the source and
  22726.  destination are on the same drive. If the source and destination are on
  22727.  different drives, the move takes place directly from source to destination,
  22728.  without moving the data to and from the local workstation.
  22729.  
  22730.  For both NetRemoteCopy and NetRemoteMove, the source and destination must be
  22731.  on the same server.
  22732.  
  22733.  NetRemoteExec executes a program on a remote server. It is similar to the
  22734.  DosExecPgm function, but NetRemoteExec is executed on a remote network
  22735.  server. For information about DosExecPgm, see your MS OS/2 programming
  22736.  manual(s).
  22737.  
  22738.  NetRemoteTOD returns time-of-day information from a remote server.
  22739.  
  22740.  
  22741.  Data Structures
  22742.  
  22743.  NetRemoteCopy returns a copy_info data structure. NetRemoteMove returns a
  22744.  move_info data structure. NetRemoteTOD returns a time_of_day_info data
  22745.  structure. NetRemoteExec does not use a data structure.
  22746.  
  22747.  
  22748.  File Copy Information
  22749.  
  22750.  The copy_info data structure has this format:
  22751.  
  22752.    struct copy_info {
  22753.        unsigned short  ci_num_copied;
  22754.        char            ci_err_buf[1];
  22755.    };
  22756.  
  22757.  where
  22758.  
  22759.  ci_num_copied
  22760.    Specifies the number of files copied.
  22761.  
  22762.  ci_err_buf
  22763.    Contains a variable-length ASCIIZ string that specifies error information
  22764.    about the file copy operation.
  22765.  
  22766.  
  22767.  File Move Information
  22768.  
  22769.  The move_info data structure has this format:
  22770.  
  22771.    struct move_info {
  22772.        unsigned short  mi_num_moved;
  22773.        char            mi_err_buf[1];
  22774.    };
  22775.  
  22776.  where
  22777.  
  22778.  mi_num_moved
  22779.    Specifies the number of files moved.
  22780.  
  22781.  mi_err_buf
  22782.    Contains a variable-length ASCIIZ string that specifies error information
  22783.    about the move operation.
  22784.  
  22785.  
  22786.  Time-of-Day Information
  22787.  
  22788.  The time_of_day_info data structure has this format:
  22789.  
  22790.    struct time_of_day_info {
  22791.        unsigned long   tod_elapsedt;
  22792.        unsigned long   tod_msecs;
  22793.        unsigned char   tod_hours;
  22794.        unsigned char   tod_mins;
  22795.        unsigned char   tod_secs;
  22796.        unsigned char   tod_hunds;
  22797.        unsigned short  tod_timezone;
  22798.        unsigned short  tod_tinterval;
  22799.        unsigned char   tod_day;
  22800.        unsigned char   tod_month;
  22801.        unsigned short  tod_year;
  22802.        unsigned char   tod_weekday;
  22803.    };
  22804.  
  22805.  where
  22806.  
  22807.  tod_elapsedt
  22808.    Specifies the number of seconds elapsed since 00:00:00, January 1, 1970.
  22809.  
  22810.  tod_msecs
  22811.    Specifies the number of milliseconds from an arbitrary starting point
  22812.    (system reset). Typically, tod_msecs is read twice, once at the start of a
  22813.    process and again at the end, then subtracting one value from the other to
  22814.    determine how long that process took.
  22815.  
  22816.  tod_hours
  22817.    Specifies the current hour (0-23).
  22818.  
  22819.  tod_mins
  22820.    Specifies the current minute (0-59).
  22821.  
  22822.  tod_secs
  22823.    Specifies the current second (0-59).
  22824.  
  22825.  tod_hunds
  22826.    Specifies the current hundredth second (0.01 second) (0-99).
  22827.  
  22828.  tod_timezone
  22829.    Specifies the time zone of the server. This value is calculated (in
  22830.    minutes) from Greenwich Mean Time (GMT). For time zones west of Greenwich,
  22831.    the value is positive; for time zones east of Greenwich, the value is
  22832.    negative. A value of -1 indicates that the time zone is undefined.
  22833.  
  22834.  tod_tinterval
  22835.    Specifies the time interval for each tick of the clock. Each integral
  22836.    integer represents one ten-thousandth second (0.0001 second).
  22837.  
  22838.  tod_day
  22839.    Specifies the day of the month (1-31).
  22840.  
  22841.  tod_month
  22842.    Specifies the month of the year (1-12).
  22843.  
  22844.  tod_year
  22845.    Specifies the year.
  22846.  
  22847.  tod_weekday
  22848.    Specifies the day of the week (0-6, where 0 is Sunday, 1 is Monday, and so
  22849.    on).
  22850.  
  22851.  
  22852.  NetRemoteCopy
  22853.  ────────────────────────────────────────────────────────────────────────────
  22854.  
  22855.  NetRemoteCopy copies one or more files from one location to another on a
  22856.  remote server. The source and destination for the file copy operation must
  22857.  be on the same server.
  22858.  
  22859.  
  22860.  Operating Systems Supported
  22861.  
  22862.  
  22863.    ■   MS OS/2 version 1.2, local only. The function can operate on remote
  22864.        files by using universal naming convention (UNC) paths or redirected
  22865.        drives.
  22866.  
  22867.    ■   MS OS/2 version 1.1, local only. The function can operate on remote
  22868.        files by using UNC paths or redirected drives.
  22869.  
  22870.    ■   MS-DOS, local only. The function can operate on remote files by using
  22871.        UNC paths or redirected drives.
  22872.  
  22873.  
  22874.  
  22875.  Privilege Level
  22876.  
  22877.  The execution privilege level for NetRemoteCopy depends on the access
  22878.  restrictions of the file(s) being accessed.
  22879.  
  22880.  
  22881.  Syntax
  22882.  
  22883.    #define INCL_NETREMUTIL
  22884.    #define INCL_NETERRORS
  22885.    #include <lan.h>
  22886.  
  22887.    API_FUNCTION
  22888.    NetRemoteCopy (const char far *  pszSourcePath,
  22889.                   const char far *  pszDestPath,
  22890.                   const char far *  pszSourcePasswd,
  22891.                   const char far *  pszDestPasswd,
  22892.                   unsigned short    fsOpen,
  22893.                   unsigned short    fsCopy,
  22894.                   char far *        pbBuffer,
  22895.                   unsigned short    cbBuffer
  22896.                  );
  22897.  
  22898.  where
  22899.  
  22900.  pszSourcePath
  22901.    Points to an ASCIIZ string that contains the pathname of the file(s) to be
  22902.    copied. This value can be expressed in UNC format or with a redirected
  22903.    drive letter.
  22904.  
  22905.  pszDestPath
  22906.    Points to an ASCIIZ string that contains the name of the path where the
  22907.    file specified by pszSourcePath is to be copied. When a wildcard is used
  22908.    for pszSourcePath, pszDestPath must be a directory. This value can be
  22909.    expressed in UNC format or with a redirected drive letter.
  22910.  
  22911.  pszSourcePasswd
  22912.    Points to an ASCIIZ string that contains the password needed to access the
  22913.    path specified by pszSourcePath. A null pointer indicates a password is
  22914.    not required.
  22915.  
  22916.  pszDestPasswd
  22917.    Points to an ASCIIZ string that contains the password needed to access the
  22918.    path specified by pszDestPath. A null pointer indicates a password is not
  22919.    required.
  22920.  
  22921.  fsOpen
  22922.    Specifies how to open pszDestPath. The REMUTIL.H header file defines these
  22923.    possible values:
  22924.  
  22925.  Bit(s)                            Meaning
  22926.  ────────────────────────────────────────────────────────────────────────────
  22927.  0-1                               Used if pszDestPath exists. If 0, the
  22928.                                    open operation fails. If 1, the file is
  22929.                                    appended. If 2, the file is overwritten.
  22930.  
  22931.  2-3                               Reserved; must be 0.
  22932.  
  22933.  4                                 Used if pszDestPath does not exist. If 0,
  22934.                                    the open operation fails. If 1, the file
  22935.                                    is created.
  22936.  
  22937.  5-15                              Reserved; must be 0.
  22938.  
  22939.  ────────────────────────────────────────────────────────────────────────────
  22940.  
  22941.  
  22942.  fsCopy
  22943.    Specifies how the file copy operation is done. The REMUTIL.H header file
  22944.    defines these possible values:
  22945.  
  22946. ╓┌─────────────┌─────────┌───────────────────────────────────────────────────╖
  22947.  Code          Bit Mask  Meaning
  22948.  ────────────────────────────────────────────────────────────────────────────
  22949.  MUST_BE_FILE  0x1       If 1, pszDestPath must be a file.
  22950.  
  22951.  MUST_BE_DIR   0x2       If 1, pszDestPath must be a directory.
  22952.  
  22953.  ASCII_DEST    0x4       If 0, pszDestPath is opened in binary mode. If 1,
  22954.                          pszDestPath is opened in text mode.
  22955.  Code          Bit Mask  Meaning
  22956.  ────────────────────────────────────────────────────────────────────────────
  22957.                         pszDestPath is opened in text mode.
  22958.  
  22959.  ASCII_SOURCE  0x8       If 0, pszSourcePath is opened in binary mode. If 1,
  22960.                          pszSourcePath is opened in text mode.
  22961.  
  22962.  VERIFY        0x10      If 1, all write operations are verified.
  22963.  
  22964.  ────────────────────────────────────────────────────────────────────────────
  22965.  
  22966.  
  22967.  
  22968.    Note that the fsCopy parameter must not be set to both MUST_BE_FILE and
  22969.    MUST_BE_DIR at the same time.
  22970.  
  22971.  pbBuffer
  22972.    Points to the buffer in which to store the returned copy_info data
  22973.    structure.
  22974.  
  22975.  cbBuffer
  22976.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  22977.  
  22978.  Return Codes
  22979.  
  22980. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  22981.  Code                              Value   Meaning
  22982.  ────────────────────────────────────────────────────────────────────────────
  22983.  NERR_Success                      0       The function encountered no
  22984.                                            errors.
  22985.  
  22986.  ERROR_FILE_NOT_FOUND              2       The file was not found.
  22987.  
  22988.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  22989.  
  22990.  ERROR_ACCESS_DENIED               5       The user has insufficient
  22991.                                            privilege for this operation.
  22992.  
  22993.  ERROR_NO_MORE_FILES               18      No more files are available.
  22994.  
  22995.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  22996.  
  22997.  Code                              Value   Meaning
  22998.  ────────────────────────────────────────────────────────────────────────────
  22999. 
  23000.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  23001.  
  23002.  ERROR_FILE_EXISTS                 80      The file already exists.
  23003.  
  23004.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  23005.                                            invalid.
  23006.  
  23007.  ERROR_NO_PROC_SLOTS               89      No process slots are available.
  23008.  
  23009.  ERROR_MORE_DATA                   234     Additional data is available.
  23010.  
  23011.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  23012.                                            is not installed.
  23013.  
  23014.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  23015.  
  23016.  NERR_WkstaNotStarted              2138    The Workstation service is not
  23017.                                            started.
  23018.  Code                              Value   Meaning
  23019.  ────────────────────────────────────────────────────────────────────────────
  23020.                                           started.
  23021.  
  23022.  NERR_BadSource                    2381    The source path is invalid.
  23023.  
  23024.  NERR_BadDest                      2382    The destination pathname does
  23025.                                            not exist.
  23026.  
  23027.  NERR_DifferentServers             2383    The source and destination paths
  23028.                                            are on different servers.
  23029.  
  23030.  ────────────────────────────────────────────────────────────────────────────
  23031.  
  23032.  
  23033.  
  23034.  
  23035.  Remarks
  23036.  
  23037.  With NetRemoteCopy, both of the following cases are valid:
  23038.  
  23039.  
  23040.    ■   The source and destination are both files. The source file is copied
  23041.        to the destination file, subject to fsOpen and fsCopy limitations.
  23042.  
  23043.    ■   The source is a file or wildcard and the destination is a directory.
  23044.        The source file(s) is copied to the destination directory, subject to
  23045.        fsOpen and fsCopy limitations.
  23046.  
  23047.  
  23048.  If the remote server runs out of resources while processing the request,
  23049.  NetRemoteCopy returns ERROR_NO_PROC_SLOTS. Any files already transferred are
  23050.  not removed from the specified destination.
  23051.  
  23052.  See Also
  23053.  
  23054.  For information about             See
  23055.  ────────────────────────────────────────────────────────────────────────────
  23056.  Moving remote files between       NetRemoteMove
  23057.  servers
  23058.  
  23059.  Passwords for shared resources    Share Category
  23060.  
  23061.  User passwords                    User Category
  23062.  
  23063.  
  23064.  NetRemoteExec
  23065.  ────────────────────────────────────────────────────────────────────────────
  23066.  
  23067.  NetRemoteExec enables a remote server to execute a program located on that
  23068.  remote server. It is a network extension of the DosExecPgm function. The
  23069.  executed program runs on the computer connected to the caller's current
  23070.  drive. If the caller's current drive is on a remote server, the child
  23071.  process executes on that server. If the caller's current drive is a local
  23072.  drive, the child process executes locally.
  23073.  
  23074.  
  23075.  Operating Systems Supported
  23076.  
  23077.  
  23078.    ■   MS OS/2 version 1.2, local only. The function can operate on remote
  23079.        files by using redirected drives.
  23080.  
  23081.    ■   MS OS/2 version 1.1, local only. The function can operate on remote
  23082.        files by using redirected drives.
  23083.  
  23084.    ■   MS-DOS not supported.
  23085.  
  23086.  
  23087.  
  23088.  Privilege Level
  23089.  
  23090.  The execution privilege level for NetRemoteExec depends on the access
  23091.  restrictions of the file(s) being accessed.
  23092.  
  23093.  
  23094.  Syntax
  23095.  
  23096.    #define INCL_NETREMUTIL
  23097.    #define INCL_NETERRORS
  23098.    #include <lan.h>
  23099.  
  23100.    API_FUNCTION
  23101.    NetRemoteExec (char far *        pszReserved1,
  23102.                   char far *        pszFailName,
  23103.                   unsigned          cbFailName,
  23104.                   unsigned          fAsync,
  23105.                   const char far *  pszArgs,
  23106.                   const char far *  pszEnvs,
  23107.                   char far *        pReturnCodes,
  23108.                   const char far *  pszPgmName,
  23109.                   char far *        pszReserved2,
  23110.                   unsigned short    fsRemoteExec
  23111.                  );
  23112.  
  23113.  where
  23114.  
  23115.  pszReserved1
  23116.    Reserved pointer; must be -1.
  23117.  
  23118.  pszFailName
  23119.    Points to a buffer into which a name is copied if NetRemoteExec cannot
  23120.    successfully load and start the specified program. The name is that of the
  23121.    object that failed, such as a dynamic-link library.
  23122.  
  23123.  cbFailName
  23124.    Specifies the size (in bytes) of the buffer pointed to by pszFailName.
  23125.  
  23126.  fAsync
  23127.    Specifies the asynchronous and trace flags. The MS OS/2 BSEDOS.H header
  23128.    file defines these possible values:
  23129.  
  23130.  Code              Value  Meaning
  23131.  ────────────────────────────────────────────────────────────────────────────
  23132.  EXEC_SYNC         0      Synchronous process.
  23133.  EXEC_ASYNC        1      Asynchronous process without result code.
  23134.  EXEC_ASYNCRESULT  2      Asynchronous process with result code.
  23135.  ────────────────────────────────────────────────────────────────────────────
  23136.  
  23137.  pszArgs
  23138.    Points to a set of ASCIIZ strings that contain the arguments of the
  23139.    program to be executed. For programs to run with MS-DOS or MS OS/2,
  23140.    pszArgs should point to a string containing the program name, a NUL
  23141.    character, the program parameters (separated by spaces), and terminated by
  23142.    two NUL characters.
  23143.  
  23144.  pszEnvs
  23145.    Points to a set of ASCIIZ strings that specify environment variables and
  23146.    their current values. The set must be terminated by two NUL characters.
  23147.    The environment variable strings have this form:
  23148.  
  23149.    variable=value
  23150.  
  23151.  pReturnCodes
  23152.    Points to an MS OS/2 data structure (RESULTCODES) that contains the return
  23153.    codes that result from the file execution. This is the same data structure
  23154.    used with the DosExecPgm function.
  23155.  
  23156.  pszPgmName
  23157.    Points to an ASCIIZ string that contains the name and optional extension
  23158.    of the file to  be executed. This name must not contain any path
  23159.    separators or a drive letter. The location of the program is determined by
  23160.    the runpath parameter set in the [netrun] section of the LANMAN.INI file
  23161.    on the remote server.
  23162.  
  23163.  pszReserved2
  23164.    Reserved pointer; must be 0.
  23165.  
  23166.  fsRemoteExec
  23167.    Specifies the remote executable flags that control program execution. The
  23168.    REMUTIL.H header file defines the possible values, as follows.
  23169.  
  23170.    The REM_PIPE_MODE code has the value 1. This bit mask isolates the mode
  23171.    for standard input, as follows:
  23172.  
  23173.  Code                              Value       Meaning
  23174.  ────────────────────────────────────────────────────────────────────────────
  23175.  REM_PIPE_MODE_MSG                 0           Message mode pipe for
  23176.                                                standard input.
  23177.  
  23178.  REM_PIPE_MODE_CHAR                1           Character mode pipe for
  23179.                                                standard input.
  23180.  
  23181.    The REM_WAIT_MODE code has the value 2. This bit mask
  23182.  isolates the wait mode for the process, as follows:
  23183.  
  23184.  Code                              Value       Meaning
  23185.  ────────────────────────────────────────────────────────────────────────────
  23186.  REM_WAIT_MODE_PROCESS             0           The DosCwait function waits
  23187.                                                for the child process to
  23188.                                                finish before returning.
  23189.  
  23190.  REM_WAIT_MODE_TREE                2           The DosCwait function waits
  23191.                                                for all spawned processes to
  23192.                                                finish before returning.
  23193.  
  23194.    The REM_SIGL_MODE code has the value 4. This bit mask
  23195.  isolates the mode for remote signals, as follows:
  23196.  
  23197.  Code                              Value       Meaning
  23198.  ────────────────────────────────────────────────────────────────────────────
  23199.  REM_SIGL_MODE_MAP                 0           Map SIGINTR and SIGBREAK to
  23200.                                                SIGKILL when sending remote
  23201.                                                standard signals.
  23202.  
  23203.  REM_SIGL_MODE_RAW                 4           Send signals as received.
  23204.  
  23205.  Return Codes
  23206.  
  23207. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  23208.  Code                              Value   Meaning
  23209.  ────────────────────────────────────────────────────────────────────────────
  23210.  NERR_Success                      0       The function encountered no
  23211.                                            errors.
  23212.  
  23213.  ERROR_FILE_NOT_FOUND              2       The file was not found.
  23214.  
  23215.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  23216.  
  23217.  ERROR_ACCESS_DENIED               5       The user has insufficient
  23218.                                            privilege for this operation.
  23219.  
  23220.  ERROR_NOT_SUPPORTED               50      This network request is not
  23221.                                            supported.
  23222.  
  23223.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  23224.                                            invalid.
  23225.  
  23226.  NERR_RunSrvPaused                 2385    The server is paused and cannot
  23227.                                            run a program or command.
  23228.  Code                              Value   Meaning
  23229.  ────────────────────────────────────────────────────────────────────────────
  23230.                                           run a program or command.
  23231.  
  23232.  NERR_ErrCommRunSrv                2389    An error occurred when
  23233.                                            communicating with a run server.
  23234.  
  23235.  NERR_ErrorExecingGhost            2391    An error occurred when starting
  23236.                                            a background process.
  23237.  
  23238.  NERR_ShareNotFound                2392    The shared resource was not
  23239.                                            found.
  23240.  
  23241.  ────────────────────────────────────────────────────────────────────────────
  23242.  
  23243.  
  23244.  
  23245.  
  23246.  Remarks
  23247.  
  23248.  NetRemoteExec requires that the LAN Manager Netrun service be running on the
  23249.  remote server. If this service is not running, NetRemoteExec returns
  23250.  ERROR_PATH_NOT_FOUND. If the Netrun service is running but the specified
  23251.  executable cannot be found on the run path, NetRemoteExec returns
  23252.  ERROR_FILE_NOT_FOUND.
  23253.  
  23254.  A process executed remotely inherits the following handles from the calling
  23255.  process:
  23256.  
  23257.  Handle               Meaning
  23258.  ────────────────────────────────────────────────────────────────────────────
  23259.  0                    Standard input (stdin).
  23260.  1                    Standard output (stdout).
  23261.  2                    Standard error (stderr).
  23262.  ────────────────────────────────────────────────────────────────────────────
  23263.  
  23264.  When NetRemoteExec initiates an asynchronous process, the process
  23265.  identification (PID) returned to the first word of pReturnCodes is a valid
  23266.  local PID that represents the remote program. The PID can be used with any
  23267.  MS OS/2 function that accepts a PID as a parameter, such as DosFlagProcess
  23268.  (to send signals to the remote process), DosCWait (to wait for the remote
  23269.  process to exit), and DosKillProcess (to terminate the process).
  23270.  
  23271.  See Also
  23272.  
  23273.  For information about             See
  23274.  ────────────────────────────────────────────────────────────────────────────
  23275.  DosFlagProcess, DosCWait,         MSOS/2 programming manual(s)
  23276.  DosKillProcess
  23277.  
  23278.  Executing a program               DosExecPgm, in MSOS/2 programming
  23279.                                    manual(s)
  23280.  
  23281.  Listing the resources on a        NetShareEnum
  23282.  server
  23283.  
  23284.  Listing the servers on the        NetServerAdminCommand
  23285.  network
  23286.  
  23287.  Netrun service                    LAN Manager administrator's manual(s)
  23288.  
  23289.  
  23290.  NetRemoteMove
  23291.  ────────────────────────────────────────────────────────────────────────────
  23292.  
  23293.  NetRemoteMove moves one or more files from one location to another on a
  23294.  remote server. The source and destination pathnames must be on the same
  23295.  server.
  23296.  
  23297.  
  23298.  Operating Systems Supported
  23299.  
  23300.  
  23301.    ■   MS OS/2 version 1.2, local only. The function can operate on remote
  23302.        files by using UNC paths or redirected drives.
  23303.  
  23304.    ■   MS OS/2 version 1.1, local only. The function can operate on remote
  23305.        files by using UNC paths or redirected drives.
  23306.  
  23307.    ■   MS-DOS, local only. The function can operate on remote files by using
  23308.        UNC paths or redirected drives.
  23309.  
  23310.  
  23311.  
  23312.  Privilege Level
  23313.  
  23314.  The execution privilege level for NetRemoteMove depends on the access
  23315.  restrictions of the file being moved.
  23316.  
  23317.  
  23318.  Syntax
  23319.  
  23320.    #define INCL_NETREMUTIL
  23321.    #define INCL_NETERRORS
  23322.    #include <lan.h>
  23323.  
  23324.    API_FUNCTION
  23325.    NetRemoteMove (const char far *  pszSourcePath,
  23326.                   const char far *  pszDestPath,
  23327.                   const char far *  pszSourcePasswd,
  23328.                   const char far *  pszDestPasswd,
  23329.                   unsigned short    fsOpen,
  23330.                   unsigned short    fsMove,
  23331.                   char far *        pbBuffer,
  23332.                   unsigned short    cbBuffer
  23333.                  );
  23334.  
  23335.  where
  23336.  
  23337.  pszSourcePath
  23338.    Points to an ASCIIZ string that contains the pathname of the file to be
  23339.    moved. Wildcards are acceptable.
  23340.  
  23341.  pszDestPath
  23342.    Points to an ASCIIZ string that contains the name of the path where the
  23343.    file specified by pszSourcePath is to be moved. If pszSourcePath is a
  23344.    wildcard, pszDestPath must be a directory.
  23345.  
  23346.  pszSourcePasswd
  23347.    Points to an ASCIIZ string that contains the password for the path
  23348.    specified by pszSourcePath. A null pointer means a password is not
  23349.    required.
  23350.  
  23351.  pszDestPasswd
  23352.    Points to an ASCIIZ string that contains the password for the path
  23353.    specified by pszDestPath. A null pointer means a password is not required.
  23354.  
  23355.  fsOpen
  23356.    Specifies how to open pszDestPath. The REMUTIL.H header file defines these
  23357.    possible values:
  23358.  
  23359.  Bit(s)                            Meaning
  23360.  ────────────────────────────────────────────────────────────────────────────
  23361.  0-1                               Use if pszDestPath exists. If 0, the
  23362.                                    open fails. If 1, the file is appended.
  23363.                                    If 2, the file is overwritten.
  23364.  
  23365.  2-3                               Reserved; must be 0.
  23366.  
  23367.  4                                 Use if pszDestPath does not exist. If 0,
  23368.                                    the open fails. If 1, the file is
  23369.                                    created.
  23370.  
  23371.  5-15                              Reserved; must be 0.
  23372.  
  23373.  ────────────────────────────────────────────────────────────────────────────
  23374.  
  23375.  
  23376.  fsMove
  23377.    Specifies control for the file move. The REMUTIL.H header file defines
  23378.    these possible values:
  23379.  
  23380.  Code          Bit Mask  Meaning
  23381.  ────────────────────────────────────────────────────────────────────────────
  23382.  MUST_BE_FILE  0x1       If 1, pszDestPath must be a file.
  23383.  MUST_BE_DIR   0x2       If 1, pszDestPath must be a directory.
  23384.  ────────────────────────────────────────────────────────────────────────────
  23385.  
  23386.    Note that the fsMove parameter must not be set to both MUST_BE_FILE and
  23387.    MUST_BE_DIR at the same time.
  23388.  
  23389.  pbBuffer
  23390.    Points to the buffer in which to store the returned move_info data
  23391.    structure.
  23392.  
  23393.  cbBuffer
  23394.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  23395.  
  23396.  Return Codes
  23397.  
  23398. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  23399.  Code                              Value   Meaning
  23400.  ────────────────────────────────────────────────────────────────────────────
  23401.  NERR_Success                      0       The function encountered no
  23402.                                            errors.
  23403.  
  23404.  ERROR_FILE_NOT_FOUND              2       The file was not found.
  23405.  
  23406.  ERROR_PATH_NOT_FOUND              3       The path was not found.
  23407.  
  23408.  ERROR_ACCESS_DENIED               5       The user has insufficient
  23409.                                            privilege for this operation.
  23410.  
  23411.  ERROR_NO_MORE_FILES               18      No more files are available.
  23412.  
  23413.  ERROR_SHARING_VIOLATION           32      A sharing violation occurred.
  23414.  
  23415.  ERROR_FILE_EXISTS                 80      The file already exists.
  23416.  
  23417.  Code                              Value   Meaning
  23418.  ────────────────────────────────────────────────────────────────────────────
  23419. 
  23420.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  23421.                                            invalid.
  23422.  
  23423.  ERROR_NO_PROC_SLOTS               89      No process slots are available.
  23424.  
  23425.  ERROR_MORE_DATA                   234     Additional data is available.
  23426.  
  23427.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  23428.  
  23429.  NERR_BadSource                    2381    The source path is invalid.
  23430.  
  23431.  NERR_BadDest                      2382    The destination pathname does
  23432.                                            not exist.
  23433.  
  23434.  NERR_DifferentServers             2383    The source and destination paths
  23435.                                            are on different servers.
  23436.  
  23437.  ────────────────────────────────────────────────────────────────────────────
  23438.  Code                              Value   Meaning
  23439.  ────────────────────────────────────────────────────────────────────────────
  23440. ────────────────────────────────────────────────────────────────────────────
  23441.  
  23442.  
  23443.  
  23444.  
  23445.  Remarks
  23446.  
  23447.  If the source and destination files are in the same directory, NetRemoteMove
  23448.  renames the source file. If they are in different directories, NetRemoteMove
  23449.  modifies the directory table accordingly. When the source and destination
  23450.  are on different drives, NetRemoteMove moves pszSourcePath to pszDestPath
  23451.  and then deletes pszSourcePath.
  23452.  
  23453.  With NetRemoteMove, both of the following cases are valid:
  23454.  
  23455.  
  23456.    ■   The source and destination are both files. The source file is copied
  23457.        to the destination file, subject to fsOpen and fsMove limitations.
  23458.  
  23459.    ■   The source is a file or wildcard and the destination is a directory.
  23460.        The source file(s) is copied to the destination directory, subject to
  23461.        fsOpen and fsMove limitations.
  23462.  
  23463.  
  23464.  If the remote server runs out of resources while processing the request,
  23465.  NetRemoteMove returns ERROR_NO_PROC_SLOTS. Any files already transferred are
  23466.  not removed from the specified destination.
  23467.  
  23468.  See Also
  23469.  
  23470.  For information about             See
  23471.  ────────────────────────────────────────────────────────────────────────────
  23472.  Copying a file from one network   NetRemoteCopy
  23473.  location to another
  23474.  
  23475.  
  23476.  NetRemoteTOD
  23477.  ────────────────────────────────────────────────────────────────────────────
  23478.  
  23479.  NetRemoteTOD returns a server's time of day.
  23480.  
  23481.  
  23482.  Operating Systems Supported
  23483.  
  23484.  
  23485.    ■   MS OS/2 version 1.2, local and remote
  23486.  
  23487.    ■   MS OS/2 version 1.1, local and remote
  23488.  
  23489.    ■   MS-DOS, local and remote
  23490.  
  23491.  
  23492.  
  23493.  Privilege Level
  23494.  
  23495.  No special privilege level is required to successfully execute NetRemoteTOD.
  23496.  
  23497.  
  23498.  
  23499.  Syntax
  23500.  
  23501.    #define INCL_NETREMUTIL
  23502.    #define INCL_NETERRORS
  23503.    #include <lan.h>
  23504.  
  23505.    API_FUNCTION
  23506.    NetRemoteTOD (const char far *  pszServer,
  23507.                  char far *        pbBuffer,
  23508.                  unsigned short    cbBuffer
  23509.                 );
  23510.  
  23511.  where
  23512.  
  23513.  pszServer
  23514.    Points to an ASCIIZ string that contains the name of the server on which
  23515.    to execute NetRemoteTOD. A null pointer or null string specifies the local
  23516.    computer.
  23517.  
  23518.  pbBuffer
  23519.    Points to the buffer in which to store the returned time_of_day_info data
  23520.    structure.
  23521.  
  23522.  cbBuffer
  23523.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  23524.  
  23525.  Return Codes
  23526.  
  23527. ╓┌─────────────────────┌───────┌─────────────────────────────────────────────╖
  23528.  Code                  Value   Meaning
  23529.  ────────────────────────────────────────────────────────────────────────────
  23530.  NERR_Success          0       The function encountered no errors.
  23531.  ERROR_BAD_NETPATH     53      The network path was not found.
  23532.  NERR_BufTooSmall      2123    The supplied buffer is too small.
  23533.  NERR_WkstaNotStarted  2138    The Workstation service is not started.
  23534.  NERR_InvalidComputer  2351    The specified computername is invalid.
  23535.  ────────────────────────────────────────────────────────────────────────────
  23536.  
  23537.  
  23538.  
  23539.  
  23540.  
  23541.  
  23542.  Remote Utility Category Example
  23543.  
  23544.    /*
  23545.       NETREM.C -- sample program demonstrating NetRemote API functions.
  23546.  
  23547.       This program executes the NetRemote APIs with the supplied parameters.
  23548.       To execute NetRemoteCopy: supply the parameters starting with -c.
  23549.       To execute NetRemoteMove: supply the parameters starting with -m.
  23550.       To execute NetRemoteExec: supply the parameters starting with -e.
  23551.       To execute NetRemoteTOD:  supply a servername with a -ts switch.
  23552.       The source and destination for NetRemoteCopy and NetRemoteMove
  23553.       can be specified using either a UNC path or a redirected drive
  23554.       letter. NetRemoteExec is carried out on the computer connected
  23555.       to the current drive. NetRemoteTOD gets the current time from the
  23556.  
  23557.       specified server.
  23558.  
  23559.       usage:
  23560.  
  23561.        netrem [-cs copy source] [-cd copy dest] [-cf copy flag] [-co
  23562.    copy open]
  23563.               [-ms move source] [-md move dest] [-mf move flag] [-mo
  23564.    move open]
  23565.               [-ep executable] [-ea arguments] [-ts \\server]
  23566.  
  23567.        where  copy source = Complete path of the source file or directory
  23568.                             for NetRemoteCopy.
  23569.               copy dest   = Complete path of the destination file or
  23570.                             directory for NetRemoteCopy.
  23571.               copy flag   = Copy flag for NetRemoteCopy.
  23572.               copy open   = Open flag for NetRemoteCopy.
  23573.               move source = Complete path of the source file or directory
  23574.                             for NetRemoteMove.
  23575.               move dest   = Complete path of the destination file or
  23576.                             directory for NetRemoteMove.
  23577.               move flag   = Move flag for NetRemoteMove.
  23578.               move open   = Open flag for NetRemoteMove.
  23579.               executable  = Name of the program for NetRemoteExec.
  23580.               arguments   = Argument string for NetRemoteExec.
  23581.               \\server    = Name of the server for NetRemoteTOD.
  23582.                             A servername must be preceded by two
  23583.                             backslashes (\\).
  23584.  
  23585.    API               Used to...
  23586.       =============     =====================================================
  23587.       NetRemoteCopy     Copy a file or directory on a remote server to
  23588.                         another file or directory on a remote server
  23589.       NetRemoteMove     Move a file or directory on a remote server to
  23590.    a
  23591.                         new file or directory on a remote server
  23592.       NetRemoteExec     Execute a program
  23593.       NetRemoteTOD      Obtain time of day from a remote server
  23594.  
  23595.       This code sample is provided for demonstration purposes only.
  23596.       Microsoft makes no warranty, either express or implied,
  23597.       as to its usability in any given situation.
  23598.    */
  23599.  
  23600.    #define     INCL_NETERRORS
  23601.    #define     INCL_NETREMUTIL
  23602.    #include    <lan.h>          // LAN Manager header files
  23603.  
  23604.    #include    <stdio.h>        // C run-time header files
  23605.    #include    <stdlib.h>
  23606.    #include    <string.h>
  23607.  
  23608.    // Define mnemonic bit masks for the functions to execute.
  23609.    #define DO_NONE              0
  23610.    #define DO_COPY              0x01
  23611.    #define DO_MOVE              0x02
  23612.    #define DO_EXEC              0x04
  23613.    #define DO_TOD               0x08
  23614.  
  23615.    // Define mnemonic bit masks for copy and move flag words.
  23616.    #define REM_OPEN_APPEND      0x01     // If dest exists, append
  23617.    #define REM_OPEN_OVERWRITE   0x02     // If dest exists, overwrite
  23618.    #define REM_OPEN_CREATE      0x10     // If dest does not exist, create
  23619.  
  23620.    #define REM_ASYNCRESULT      0x02     // Equivalent of EXEC_ASYNCRESULT
  23621.    #define ARG_LEN              128
  23622.    #define OBJ_LEN              64
  23623.  
  23624.    void Usage(char *pszString);
  23625.  
  23626.    void main(int argc, char *argv[])
  23627.    {
  23628.       char   fToDo = DO_NONE;              // NetRemote API to perform
  23629.       char   achReturnCodes[OBJ_LEN];      // NetRemoteExec MS OS/2 ret
  23630.    codes
  23631.       char   achObjectName[OBJ_LEN];       // NetRemoteExec object name
  23632.       char   achArgs[ARG_LEN];             // NetRemoteExec argument
  23633.    string
  23634.       char   achEnvs[ARG_LEN];             // NetRemoteExec environment
  23635.    string
  23636.       char * pszCopySrc = NULL;            // Can be file or directory
  23637.       char * pszCopyDest = NULL;           // Can be file or directory
  23638.       char * pszMoveSrc = NULL;            // Can be file or directory
  23639.       char * pszMoveDest = NULL;           // Can be file or directory
  23640.       char * pszPgmName = NULL;            // Program to be executed
  23641.       char * pszArgs;                      // Arguments for program
  23642.       char * pszServer = NULL;             // Time servername
  23643.       unsigned short fsCopy = 0;           // Copy flag
  23644.       unsigned short fsMove = 0;           // Move flag
  23645.       unsigned short fsCopyOpen = REM_OPEN_OVERWRITE | REM_OPEN_CREATE;
  23646.       unsigned short fsMoveOpen = REM_OPEN_OVERWRITE | REM_OPEN_CREATE;
  23647.       int            iCount;               // Index counter
  23648.       struct copy_info CopyBuf;            // Return data from NetRemoteCopy
  23649.       struct move_info MoveBuf;            // Return data from NetRemoteMove
  23650.       struct time_of_day_info TimeBuf;     // Time-of-day struct in REMUTIL.H
  23651.       API_RET_TYPE uRet;                   // Return code from API calls
  23652.  
  23653.       for (iCount = 1; iCount < argc; iCount++) // Get command-line switches
  23654.       {
  23655.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  23656.          {
  23657.             switch (tolower(*(argv[iCount]+1))) // Process switches
  23658.             {
  23659.                case 'c':                        // -c copy
  23660.                   fToDo |= DO_COPY;
  23661.                   switch (tolower(*(argv[iCount]+2)))
  23662.                   {
  23663.                      case 's':                  // -cs copy source
  23664.                         pszCopySrc = argv[++iCount];
  23665.                         break;
  23666.                      case 'd':                  // -cd copy destination
  23667.                         pszCopyDest = argv[++iCount];
  23668.                         break;
  23669.                      case 'f':                  // -cf copy flag
  23670.                         fsCopy = atoi(argv[++iCount]);
  23671.                         break;
  23672.                      case 'o':                  // -co copy open flag
  23673.                         fsCopyOpen = atoi(argv[++iCount]);
  23674.                         break;
  23675.                      default:
  23676.                         Usage(argv[0]);         // Display usage and
  23677.    exit
  23678.                   }
  23679.                   break;
  23680.                case 'm':                        // -m move
  23681.                   fToDo |= DO_MOVE;
  23682.                   switch (tolower(*(argv[iCount]+2)))
  23683.  
  23684.    {
  23685.                      case 's':                  // -ms move source
  23686.                         pszMoveSrc = argv[++iCount];
  23687.                         break;
  23688.                      case 'd':                  // -md move destination
  23689.                         pszMoveDest = argv[++iCount];
  23690.                         break;
  23691.                      case 'f':                  // -mf move flag
  23692.                         fsMove = atoi(argv[++iCount]);
  23693.                         break;
  23694.                      case 'o':                  // -mo move open flag
  23695.                         fsMoveOpen = atoi(argv[++iCount]);
  23696.                         break;
  23697.                      default:
  23698.                         Usage(argv[0]);         // Display usage and
  23699.    exit
  23700.                   }
  23701.                   break;
  23702.                case 'e':                        // -e exec
  23703.                   fToDo |= DO_EXEC;
  23704.                   switch (tolower(*(argv[iCount]+2)))
  23705.                   {
  23706.                      case 'p':                  // -ep exec executable
  23707.    program
  23708.                         pszPgmName = argv[++iCount];
  23709.                         achArgs[0] = '\0'; // Set double NUL terminator
  23710.                         achArgs[1] = '\0';
  23711.                         achEnvs[0] = '\0'; // Set double NUL terminator
  23712.                         achEnvs[1] = '\0';
  23713.                         break;
  23714.                      case 'a':                  // -ea exec argument
  23715.    string
  23716.                         pszArgs = achArgs;
  23717.                         strcpy(pszArgs, pszPgmName);      // Program
  23718.    name
  23719.                         pszArgs += strlen(pszArgs) + 1;   // NUL terminator
  23720.                         strcpy(pszArgs, argv[++iCount]);  // Argument
  23721.    string
  23722.                         pszArgs += strlen(pszArgs) + 1;   // NUL terminator
  23723.                         *pszArgs = '\0';                  // Extra NUL
  23724.                         break;
  23725.                      default:
  23726.                         Usage(argv[0]);         // Display usage and
  23727.    exit
  23728.                   }
  23729.                   break;
  23730.                case 't':                        // -t time of day
  23731.                   fToDo |= DO_TOD;
  23732.                   if (tolower(*(argv[iCount]+2)) == 's')
  23733.                      pszServer = argv[++iCount];// -ts servername
  23734.                   else
  23735.                      Usage(argv[0]);            // Display usage and
  23736.    exit
  23737.                   break;
  23738.  
  23739.    case 'h':
  23740.                default:
  23741.                   Usage(argv[0]);               // Display usage and
  23742.    exit
  23743.             }
  23744.          }
  23745.          else
  23746.             Usage(argv[0]);                     // Display usage and
  23747.    exit
  23748.       }
  23749.  
  23750.       if (fToDo == DO_NONE)
  23751.       {
  23752.          printf("No operation specified.\n");
  23753.          Usage(argv[0]);                        // Display usage and
  23754.    exit
  23755.       }
  23756.  
  23757.    //========================================================================
  23758.    //  NetRemoteCopy
  23759.    //
  23760.    //  This API copies a file or directory on the specified server.
  23761.    //  The source is copied to the destination according to the flags.
  23762.  
  23763.    //  Information about the operation is returned in the CopyBuf structure.
  23764.    //========================================================================
  23765.  
  23766.       if (fToDo & DO_COPY)
  23767.       {
  23768.          uRet = NetRemoteCopy(pszCopySrc,   // Source path
  23769.                   pszCopyDest,              // Destination path
  23770.                   NULL,                     // No password for source
  23771.    path
  23772.                   NULL,                     // No password for dest path
  23773.                   fsCopyOpen,               // Open flags
  23774.                   fsCopy,                   // Copy flags
  23775.                   (char far *)&CopyBuf,     // Return data
  23776.                   sizeof(struct copy_info));// Return data size, in bytes
  23777.  
  23778.          printf("NetRemoteCopy returned %u\n", uRet);
  23779.          if (uRet == NERR_Success)
  23780.          {
  23781.              printf("   Copied %s to %s\n",pszCopySrc, pszCopyDest);
  23782.              printf("   Files copied = %hu\n", CopyBuf.ci_num_copied);
  23783.          }
  23784.       }
  23785.  
  23786.    //========================================================================
  23787.    //  NetRemoteMove
  23788.    //
  23789.    //  This API moves a file on the remote server. The source file is
  23790.    renamed
  23791.    //  to the name specified by the destination file. After the operation,
  23792.    //  only one file exists, and its name is the destination filename.
  23793.    //========================================================================
  23794.  
  23795.       if (fToDo & DO_MOVE)
  23796.       {
  23797.          uRet = NetRemoteMove(pszMoveSrc,    // Source path
  23798.                   pszMoveDest,               // Destination path
  23799.                   NULL,                      // No password for source
  23800.    path
  23801.                   NULL,                      // No password for dest
  23802.    path
  23803.                   fsMoveOpen,                // Open flags
  23804.                   fsMove,                    // Move flags
  23805.                   (char far *) &MoveBuf,     // Return data
  23806.                   sizeof(struct move_info)); // Return data size, in
  23807.    bytes
  23808.  
  23809.          printf("NetRemoteMove returned %u\n",uRet);
  23810.          if (uRet == NERR_Success)
  23811.          {
  23812.              printf("   Moved %s to %s\n", pszMoveSrc, pszMoveDest);
  23813.              printf("   Number of files moved = %hu\n",MoveBuf.mi_num_moved);
  23814.          }
  23815.       }
  23816.  
  23817.    //========================================================================
  23818.    //  NetRemoteExec
  23819.    //
  23820.    //  This API executes the specified file on the computer connected
  23821.  
  23822.    //  to the current drive. If the current drive is connected to a
  23823.    //  remote server, the file is executed on that server. If the current
  23824.  
  23825.    //  drive is local, the file is executed locally. When NETREM.EXE
  23826.    reads
  23827.    //  the arguments for the NetRemoteExec call, it adds the name of
  23828.    the
  23829.    //  program to be executed to the front of that program's argument
  23830.    string.
  23831.    //========================================================================
  23832.  
  23833.       if (fToDo & DO_EXEC)
  23834.       {
  23835.          uRet = NetRemoteExec((char far *)-1L, // Reserved; must be -1
  23836.                   achObjectName,               // Contains data if error
  23837.                   OBJ_LEN,                     // Length of error data
  23838.    buffer
  23839.                   REM_ASYNCRESULT,             // Asynchronous with result
  23840.    code
  23841.                   achArgs,                     // Argument strings
  23842.                   achEnvs,                     // Environment strings
  23843.                   achReturnCodes,              // DosExecPgm return codes
  23844.                   pszPgmName,                  // Program to execute
  23845.                   NULL,                        // Reserved; must be NULL
  23846.                   0);                          // Remote exec flags
  23847.  
  23848.          if (uRet == NERR_Success)
  23849.              printf("\nNetRemoteExec executed %s\n", pszPgmName);
  23850.          else
  23851.          {
  23852.              printf("\nNetRemoteExec returned error %u\n", uRet);
  23853.              if (achObjectName[0] != '\0')
  23854.                 printf("   Error buffer = %s\n", achObjectName);
  23855.          }
  23856.       }
  23857.  
  23858.    //=======================================================================
  23859.    //  NetRemoteTOD
  23860.    //
  23861.    //  This API obtains the time of day from the specified server.
  23862.    //  The time-of-day structure is defined in the REMUTIL.H header file.
  23863.    //=======================================================================
  23864.  
  23865.       if (fToDo & DO_TOD)
  23866.       {
  23867.          uRet = NetRemoteTOD(pszServer,            // Servername
  23868.                  (char far *) &TimeBuf,            // Data returned here
  23869.                  sizeof(struct time_of_day_info)); // Size of buffer
  23870.  
  23871.          printf("NetRemoteTOD returned %u\n", uRet);
  23872.          if (uRet == NERR_Success)                 // Call completed
  23873.    OK
  23874.          {
  23875.              printf("   Time ");
  23876.              if ((pszServer != NULL) && (*pszServer != '\0'))
  23877.                 printf("on server %s = ",pszServer);
  23878.              printf("%02u:%02u:%02u ", TimeBuf.tod_hours,
  23879.                                        TimeBuf.tod_mins,
  23880.                                        TimeBuf.tod_secs);
  23881.              printf("%02u/%02u/%u \n", TimeBuf.tod_month,
  23882.                                        TimeBuf.tod_day,
  23883.                                        TimeBuf.tod_year);
  23884.          }
  23885.       }
  23886.       exit(0);
  23887.    }
  23888.  
  23889.    void Usage(char * pszString)
  23890.    {
  23891.       printf("Usage: %s [-cs copy source] [-cd copy dest] [-cf copy flag]"
  23892.              " [-co copy open]\n\t   [-ms move source] [-md move dest]"
  23893.              " [-mf move flag] [-mo move open]\n\t   [-ep executable]"
  23894.              " [-ea arguments]\n\t   [-ts \\\\server for TOD]\n",
  23895.              pszString);
  23896.       exit(1);
  23897.    }
  23898.  
  23899.  
  23900.  
  23901.  
  23902.  
  23903.  Server Category
  23904.  
  23905.  Server API functions perform administrative tasks on a local or remote
  23906.  server. They require that the Workstation service be started.
  23907.  NetServerAdminCommand, NetServerGetInfo, and NetServerSetInfo also require
  23908.  that the Server service be started on the specified server.
  23909.  
  23910.  The Server category functions, datatypes, structures, and constants are
  23911.  defined in the NETCONS.H, NETERR.H, and SERVER.H header files. A source
  23912.  program can access these definitions by defining the constants
  23913.  INCL_NETERRORS and INCL_NETSERVER, and including the master header file,
  23914.  LAN.H. For more information, see the "Example" section, later in this
  23915.  category.
  23916.  
  23917.  These are the Server API functions:
  23918.  
  23919.  
  23920.    ■   NetServerAdminCommand
  23921.  
  23922.    ■   NetServerDiskEnum
  23923.  
  23924.    ■   NetServerEnum2
  23925.  
  23926.    ■   NetServerGetInfo
  23927.  
  23928.    ■   NetServerSetInfo
  23929.  
  23930.  
  23931.  
  23932.  Description
  23933.  
  23934.  Any user or application with admin privilege on a local or remote server can
  23935.  perform administrative tasks on that server to control its operation, user
  23936.  access, and resource sharing. You can examine and modify low-level
  23937.  parameters that affect a server's operation by calling NetServerGetInfo and
  23938.  NetServerSetInfo. The parameters, elements of the server_info_X data
  23939.  structures (where X is 0, 1, 2, or 3, depending on the level of detail
  23940.  requested), take their default values from the [server] section of the
  23941.  LANMAN.INI file.
  23942.  
  23943.  Another way to change a server's operation is by using the LAN Manager net
  23944.  command. An application can call the NetServerAdminCommand function to
  23945.  execute a LAN Manager net command on a server. For a list of net commands
  23946.  (such as net use, net share, and net access), see your LAN Manager
  23947.  administrator's manual(s).
  23948.  
  23949.  NetServerEnum2 lists all visible servers of specific types in the specified
  23950.  domains. Visible servers are those servers that have not set the svX_hidden
  23951.  element of the server_info_X data structure, where X is 2 or 3.
  23952.  
  23953.  NetServerDiskEnum lists the local drives on the specified server.
  23954.  
  23955.  With MS-DOS, most Server category API functions can be executed only on a
  23956.  remote server. NetServerDiskEnum and NetServerEnum2 can be executed on
  23957.  either a local workstation or a remote server, but all other Server category
  23958.  API functions executed on a local workstation return the NERR_RemoteOnly
  23959.  error code.
  23960.  
  23961.  
  23962.  Data Structures
  23963.  
  23964.  NetServerGetInfo uses the server_info_X data structure, where X is 0, 1, 2,
  23965.  or 3, to return server configuration information.
  23966.  
  23967.  NetServerSetInfo allows the user to change server parameters in the
  23968.  server_info_X data structure, where X is 1, 2, or 3.
  23969.  
  23970.  NetServerEnum2 lists server information using the server_info_X data
  23971.  structure, where X is 0 or 1.
  23972.  
  23973.  NetServerDiskEnum returns a list of all disk drives on a server. The data is
  23974.  returned in the form of consecutive ASCIIZ strings. Each disk drive name
  23975.  string is terminated by a NUL character. The next disk drive name string
  23976.  starts in the byte immediately following  the terminating NUL. Level 0 must
  23977.  be specified.
  23978.  
  23979.  
  23980.  Server Information (level 0)
  23981.  
  23982.  The server_info_0 data structure has this format:
  23983.  
  23984.    struct server_info_0 {
  23985.        char  sv0_name[CNLEN + 1];
  23986.    };
  23987.  
  23988.  where
  23989.  
  23990.  sv0_name
  23991.    Specifies an ASCIIZ string that contains the name of a server. The
  23992.    constant CNLEN is defined in the NETCONS.H header file.
  23993.  
  23994.  
  23995.  Server Information (level 1)
  23996.  
  23997.  The server_info_1 data structure has this format:
  23998.  
  23999.    struct server_info_1 {
  24000.        char           sv1_name[CNLEN + 1];
  24001.        unsigned char  sv1_version_major;
  24002.        unsigned char  sv1_version_minor;
  24003.        unsigned long  sv1_type;
  24004.        char far *     sv1_comment;
  24005.    };
  24006.  
  24007.  where
  24008.  
  24009.  sv1_name
  24010.    Contains an ASCIIZ string that specifies the name of a server. The
  24011.    constant CNLEN is defined in the NETCONS.H header file.
  24012.  
  24013.  sv1_version_major
  24014.    The least significant nibble (rightmost nibble) specifies the major
  24015.    release version number of LAN Manager. The most significant nibble
  24016.    (leftmost nibble) specifies server type. The bits have the following
  24017.    values:
  24018.  
  24019.  Code                Value  Bits  Meaning
  24020.  ────────────────────────────────────────────────────────────────────────────
  24021.  MAJOR_VERSION_MASK  0x0F   0-3   Major version number.
  24022.  ─                   0x10   4-7   Unlimited server.
  24023.  ─                   0x10   4-7   Limited server.
  24024.  ─                   0x20   4-7   Peer server.
  24025.  ────────────────────────────────────────────────────────────────────────────
  24026.  
  24027.    The mask MAJOR_VERSION_MASK, defined in the SERVER.H header file, should
  24028.    be used to ensure correct results.
  24029.  
  24030.  sv1_version_minor
  24031.    Specifies the minor release version number of LAN Manager.
  24032.  
  24033.  sv1_type
  24034.    Specifies the type of software the computer is running. The SERVER.H
  24035.    header file defines these possible values:
  24036.  
  24037. ╓┌───────────────────────┌───────────┌───────────────────────────────────────╖
  24038.  Code                    Bit Mask    Type of Software
  24039.  ────────────────────────────────────────────────────────────────────────────
  24040.  SV_TYPE_WORKSTATION     0x00000001  Workstation.
  24041.  SV_TYPE_SERVER          0x00000002  Server.
  24042.  SV_TYPE_SQLSERVER       0x00000004  SQL server.
  24043.  SV_TYPE_DOMAIN_CTRL     0x00000008  Primary domain controller.
  24044.  SV_TYPE_DOMAIN_BAKCTRL  0x00000010  Backup domain controller.
  24045.  SV_TYPE_TIME_SOURCE     0x00000020  Time server.
  24046.  SV_TYPE_AFP             0x00000040  Apple(R) File Protocol (AFP) service.
  24047.  Code                    Bit Mask    Type of Software
  24048.  ────────────────────────────────────────────────────────────────────────────
  24049. SV_TYPE_AFP             0x00000040  Apple(R) File Protocol (AFP) service.
  24050.  SV_TYPE_NOVELL          0x00000080  Novell(R) service.
  24051.  SV_TYPE_ALL             0xFFFFFFFF  All types of servers.
  24052.  ────────────────────────────────────────────────────────────────────────────
  24053.  
  24054.  
  24055.  sv1_comment
  24056.    Points to an ASCIIZ string that contains a comment describing the server.
  24057.    The comment can be a null string or a null pointer.
  24058.  
  24059.  
  24060.  Server Information (level 2)
  24061.  
  24062.  The server_info_2 data structure has this format:
  24063.  
  24064.    struct server_info_2 {
  24065.        char            sv2_name[CNLEN+1];
  24066.        unsigned char   sv2_version_major;
  24067.        unsigned char   sv2_version_minor;
  24068.        unsigned long   sv2_type;
  24069.        char far *      sv2_comment;
  24070.        unsigned long   sv2_ulist_mtime;
  24071.        unsigned long   sv2_glist_mtime;
  24072.        unsigned long   sv2_alist_mtime;
  24073.        unsigned short  sv2_users;
  24074.        unsigned short  sv2_disc;
  24075.        char far *      sv2_alerts;
  24076.        unsigned short  sv2_security;
  24077.        unsigned short  sv2_auditing;
  24078.        unsigned short  sv2_numadmin;
  24079.        unsigned short  sv2_lanmask;
  24080.        unsigned short  sv2_hidden;
  24081.        unsigned short  sv2_announce;
  24082.        unsigned short  sv2_anndelta;
  24083.        char            sv2_guestacct[UNLEN + 1];
  24084.        unsigned char   sv2_pad1;
  24085.        char far *      sv2_userpath;
  24086.        unsigned short  sv2_chdevs;
  24087.        unsigned short  sv2_chdevq;
  24088.        unsigned short  sv2_chdevjobs;
  24089.        unsigned short  sv2_connections;
  24090.        unsigned short  sv2_shares;
  24091.        unsigned short  sv2_openfiles;
  24092.        unsigned short  sv2_sessopens;
  24093.        unsigned short  sv2_sessvcs;
  24094.        unsigned short  sv2_sessreqs;
  24095.        unsigned short  sv2_opensearch;
  24096.        unsigned short  sv2_activelocks;
  24097.        unsigned short  sv2_numreqbuf;
  24098.        unsigned short  sv2_sizreqbuf;
  24099.        unsigned short  sv2_numbigbuf;
  24100.        unsigned short  sv2_numfiletasks;
  24101.  
  24102.    unsigned short  sv2_alertsched;
  24103.        unsigned short  sv2_erroralert;
  24104.        unsigned short  sv2_logonalert;
  24105.        unsigned short  sv2_accessalert;
  24106.        unsigned short  sv2_diskalert;
  24107.        unsigned short  sv2_netioalert;
  24108.        unsigned short  sv2_maxauditsz;
  24109.        char far *      sv2_srvheuristics;
  24110.    };
  24111.  
  24112.  where
  24113.  
  24114.  sv2_name through sv2_comment
  24115.    Are the same as the corresponding elements in the server_info_1 data
  24116.    structure. For a complete description, see the preceding section.
  24117.  
  24118.  sv2_ulist_mtime
  24119.    Specifies the time when the user list (for a server that has user-level
  24120.    security) was last modified. This value is stored as the number of seconds
  24121.    elapsed since 00:00:00, January 1, 1970.
  24122.  
  24123.  sv2_glist_mtime
  24124.    Specifies the time when the group list (for a server that has user-level
  24125.    security) was last modified. This value is stored as the number of seconds
  24126.    elapsed since 00:00:00, January 1, 1970.
  24127.  
  24128.  sv2_alist_mtime
  24129.    Specifies the time when the access control list (for a server that has
  24130.    user-level security) was last modified. This value is stored as the number
  24131.    of seconds elapsed since 00:00:00, January 1, 1970.
  24132.  
  24133.  sv2_users
  24134.    Specifies how many users are allowed on the server.
  24135.  
  24136.  sv2_disc
  24137.    Specifies the time (in minutes) when the session is automatically
  24138.    disconnected. A session is disconnected if it is idle longer than the time
  24139.    specified by sv2_disc. If sv2_disc is SV_NODISC, the autodisconnect
  24140.    feature is not enabled.
  24141.  
  24142.  sv2_alerts
  24143.    Points to an ASCIIZ string that contains the usernames listed in the
  24144.    server's alert table. The usernames are separated by spaces.
  24145.  
  24146.  sv2_security
  24147.    Specifies the security type of the server. The SERVER.H header file
  24148.    defines these possible values:
  24149.  
  24150.  Code              Value  Type of Security
  24151.  ────────────────────────────────────────────────────────────────────────────
  24152.  SV_SHARESECURITY  0      Share-level.
  24153.  SV_USERSECURITY   1      User-level.
  24154.  ────────────────────────────────────────────────────────────────────────────
  24155.  
  24156.  sv2_auditing
  24157.    Specifies whether auditing is enabled on the server. If sv_auditing is 0,
  24158.    auditing is disabled. If it is any other defined value, the server audits
  24159.    LAN Manager activities. For more information about auditing, see the
  24160.    Auditing category API functions.
  24161.  
  24162.  sv2_numadmin
  24163.    Specifies how many users with admin privilege can administer the server at
  24164.    the same time.
  24165.  
  24166.  sv2_lanmask
  24167.    Indicates the network device drivers active on this server. Each bit
  24168.    corresponds to an entry in the [networks] section of the LANMAN. INI file.
  24169.    If sv2_lanmask is 0, the network device driver is not active. If it is 1,
  24170.    the network device driver is active.
  24171.  
  24172.  sv2_hidden
  24173.    Specifies whether the server is visible to other computers in the same
  24174.    network domain. The SERVER.H header file defines these possible values:
  24175.  
  24176.  Code        Value  Meaning
  24177.  ────────────────────────────────────────────────────────────────────────────
  24178.  SV_VISIBLE  0      Server is visible.
  24179.  SV_HIDDEN   1      Server is hidden (not visible).
  24180.  ────────────────────────────────────────────────────────────────────────────
  24181.  
  24182.  sv2_announce
  24183.    Specifies the network announce rate (in seconds). This value and the value
  24184.    of sv2_anndelta determine how often the server is announced to other
  24185.    computers on the network.
  24186.  
  24187.  sv2_anndelta
  24188.    Specifies the delta, or change, of the announce rate (in milliseconds).
  24189.    This value specifies how much the announce rate can vary from the time
  24190.    specified in sv2_announce. The delta value allows randomly varied announce
  24191.    rates. For example, if sv2_announce has the value 10, and sv2_anndelta has
  24192.    the value 1, the announce rate can vary from 9.999 seconds to 10.001
  24193.    seconds.
  24194.  
  24195.  sv2_guestacct
  24196.    Specifies an ASCIIZ string that contains the name of the reserved guests
  24197.    account on a server. The constant UNLEN is defined in the NETCONS.H header
  24198.    file.
  24199.  
  24200.  sv2_pad1
  24201.    Aligns the next data structure element on a word boundary.
  24202.  
  24203.  sv2_userpath
  24204.    Points to an ASCIIZ string that contains the pathname to user directories.
  24205.  
  24206.  sv2_chdevs
  24207.    Specifies how many communication devices can be shared on the server at
  24208.    any one time.
  24209.  
  24210.  sv2_chdevq
  24211.    Specifies how many communication-device queues can be defined on the
  24212.    server at any one time.
  24213.  
  24214.  sv2_chdevjobs
  24215.    Specifies how many communication device jobs can be pending on a server.
  24216.  
  24217.  sv2_connections
  24218.    Specifies how many connections to sharenames are allowed on a server.
  24219.  
  24220.  sv2_shares
  24221.    Specifies how many sharenames can be defined on the server at any one
  24222.    time.
  24223.  
  24224.  sv2_openfiles
  24225.    Specifies how many files can be open at any one time on the server.
  24226.  
  24227.  sv2_sessopens
  24228.    Specifies how many files can be open per session.
  24229.  
  24230.  sv2_sessvcs
  24231.    Specifies how many virtual circuits are allowed for each client process.
  24232.  
  24233.  sv2_sessreqs
  24234.    Specifies how many simultaneous requests a client process can make.
  24235.  
  24236.  sv2_opensearch
  24237.    Specifies how many searches can be open at any one time.
  24238.  
  24239.  sv2_activelocks
  24240.    Specifies how many file locks can be active at any one time.
  24241.  
  24242.  sv2_numreqbuf
  24243.    Specifies how many server buffers are provided.
  24244.  
  24245.  sv2_sizreqbuf
  24246.    Specifies the size (in bytes) of each server buffer.
  24247.  
  24248.  sv2_numbigbuf
  24249.    Specifies how many 64K server buffers are provided.
  24250.  
  24251.  sv2_numfiletasks
  24252.    Specifies how many server processes can perform file I/O simultaneously.
  24253.  
  24254.  sv2_alertsched
  24255.    Specifies the alert interval (in minutes) for notifying an administrator
  24256.    of a network event.
  24257.  
  24258.  sv2_erroralert
  24259.    Specifies how many entries can be written to the error log during a
  24260.    sv2_alertsched interval before an administrator is notified.
  24261.  
  24262.  sv2_logonalert
  24263.    Specifies how many invalid logon attempts can be made before an
  24264.    administrator is notified.
  24265.  
  24266.  sv2_accessalert
  24267.    Specifies how many invalid file accesses can be made before an
  24268.    administrator is notified.
  24269.  
  24270.  sv2_diskalert
  24271.    Specifies at what point (the number of kilobytes of free disk space) an
  24272.    administrator should be notified that available space on a disk is low.
  24273.  
  24274.  sv2_netioalert
  24275.    Specifies the network I/O error ratio (in tenths of a percent) to allow
  24276.    before an administrator is notified.
  24277.  
  24278.  sv2_maxauditsz
  24279.    Specifies the maximum audit file size (in kilobytes).
  24280.  
  24281.  sv2_srvheuristics
  24282.    Points to an ASCIIZ string of flags used to control a server's operations
  24283.    and optimize server performance. The server heuristics are 20 digits that
  24284.    configure how a server processes network requests. Digits read from left
  24285.    (0) to right (19). For a complete description of these digits, see
  24286.    Appendix G, "Workstation and Server Heuristics."
  24287.  
  24288.  
  24289.  Server Information (level 3)
  24290.  
  24291.  The server_info_3 data structure has this format:
  24292.  
  24293.    struct server_info_3 {
  24294.        char            sv3_name[CNLEN+1];
  24295.        unsigned char   sv3_version_major;
  24296.        unsigned char   sv3_version_minor;
  24297.        unsigned long   sv3_type;
  24298.        char far *      sv3_comment;
  24299.        unsigned long   sv3_ulist_mtime;
  24300.        unsigned long   sv3_glist_mtime;
  24301.        unsigned long   sv3_alist_mtime;
  24302.        unsigned short  sv3_users;
  24303.        unsigned short  sv3_disc;
  24304.        char far *      sv3_alerts;
  24305.        unsigned short  sv3_security;
  24306.        unsigned short  sv3_auditing;
  24307.        unsigned short  sv3_numadmin;
  24308.        unsigned short  sv3_lanmask;
  24309.        unsigned short  sv3_hidden;
  24310.        unsigned short  sv3_announce;
  24311.        unsigned short  sv3_anndelta;
  24312.        char            sv3_guestacct[UNLEN + 1];
  24313.        unsigned char   sv3_pad1;
  24314.        char far *      sv3_userpath;
  24315.        unsigned short  sv3_chdevs;
  24316.        unsigned short  sv3_chdevq;
  24317.        unsigned short  sv3_chdevjobs;
  24318.        unsigned short  sv3_connections;
  24319.        unsigned short  sv3_shares;
  24320.        unsigned short  sv3_openfiles;
  24321.        unsigned short  sv3_sessopens;
  24322.        unsigned short  sv3_sessvcs;
  24323.        unsigned short  sv3_sessreqs;
  24324.        unsigned short  sv3_opensearch;
  24325.        unsigned short  sv3_activelocks;
  24326.        unsigned short  sv3_numreqbuf;
  24327.        unsigned short  sv3_sizreqbuf;
  24328.        unsigned short  sv3_numbigbuf;
  24329.        unsigned short  sv3_numfiletasks;
  24330.        unsigned short  sv3_alertsched;
  24331.        unsigned short  sv3_erroralert;
  24332.        unsigned short  sv3_logonalert;
  24333.        unsigned short  sv3_accessalert;
  24334.        unsigned short  sv3_diskalert;
  24335.        unsigned short  sv3_netioalert;
  24336.        unsigned short  sv3_maxauditsz;
  24337.        char far *      sv3_srvheuristics;
  24338.        unsigned long   sv3_auditedevents;
  24339.        unsigned short  sv3_autoprofile;
  24340.        char far *      sv3_autopath;
  24341.    };
  24342.  
  24343.  where
  24344.  
  24345.  sv3_name through sv3_srvheuristics
  24346.    Are the same as the corresponding elements of the server_info_2 data
  24347.    structure. For a complete description, see the preceding section.
  24348.  
  24349.  sv3_auditedevents
  24350.    Specifies the audit event control mask. Bits 18 through 31 are reserved.
  24351.    Bits 0 through 16 have the following meaning:
  24352.  
  24353. ╓┌──────────────┌─────────┌──────────────────────────────────────────────────╖
  24354.  Event Name     Bit Mask  Meaning
  24355.  ────────────────────────────────────────────────────────────────────────────
  24356.  service        0x0001    Disable auditing of service state changes.
  24357.  
  24358.  goodsesslogon  0x0006    Disable auditing of successful session logon
  24359.                           requests.
  24360.  
  24361.  badsesslogon   0x0018    Disable auditing of failed session logon requests.
  24362.  Event Name     Bit Mask  Meaning
  24363.  ────────────────────────────────────────────────────────────────────────────
  24364. badsesslogon   0x0018    Disable auditing of failed session logon requests.
  24365.  
  24366.  sesslogon      0x001E    Disable auditing of all session logon/logoff
  24367.                           attempts.
  24368.  
  24369.  goodnetlogon   0x0060    Disable auditing of successful network logon
  24370.                           requests.
  24371.  
  24372.  badnetlogon    0x0180    Disable auditing of failed network logon requests.
  24373.  
  24374.  netlogon       0x01E0    Disable auditing of all network logon/logoff
  24375.                           attempts.
  24376.  
  24377.  logon          0x01FE    Disable auditing of all logon/logoff attempts
  24378.                           (network and session). This mask produces the
  24379.                           same effect as goodnetlogon/badnetlogon and
  24380.                           goodsesslogon/badsesslogon masks.
  24381.  
  24382.  gooduse        0x0600    Disable auditing of successful requests to use a
  24383.  Event Name     Bit Mask  Meaning
  24384.  ────────────────────────────────────────────────────────────────────────────
  24385. gooduse        0x0600    Disable auditing of successful requests to use a
  24386.                           shared resource.
  24387.  
  24388.  baduse         0x0800    Disable auditing of failed attempts to access a
  24389.                           shared resource.
  24390.  
  24391.  use            0x1E00    Disable auditing of all access requests to a
  24392.                           shared resource regardless of gooduse or baduse
  24393.                           masks. This mask produces the same effect as both
  24394.                           the gooduse/baduse masks.
  24395.  
  24396.  userlist       0x2000    Disable auditing of changes to the user/domain
  24397.                           account database.
  24398.  
  24399.  permissions    0x4000    Disable auditing of changes to the access control
  24400.                           list (ACL) database.
  24401.  
  24402.  resource       0x8000    Disable auditing of resource access as defined by
  24403.                           the per-resource auditing options, specified in
  24404.  Event Name     Bit Mask  Meaning
  24405.  ────────────────────────────────────────────────────────────────────────────
  24406.                          the per-resource auditing options, specified in
  24407.                           the ACL.
  24408.  
  24409.  logonlimit     0x10000   Disable auditing of logon limit violations.
  24410.  
  24411.  ────────────────────────────────────────────────────────────────────────────
  24412.  
  24413.  
  24414.  
  24415.  sv3_autoprofile
  24416.    Controls how the server acts on the profile. The SERVER.H header file
  24417.    defines these possible values:
  24418.  
  24419.  Code                   Value  Meaning
  24420.  ────────────────────────────────────────────────────────────────────────────
  24421.  SW_AUTOPROF_LOAD_MASK  0x1    Server loads the profile.
  24422.  SW_AUTOPROF_SAVE_MASK  0x2    Server saves the profile.
  24423.  ────────────────────────────────────────────────────────────────────────────
  24424.  
  24425.    Both flags can be set simultaneously.
  24426.  
  24427.  sv3_autopath
  24428.    Points to the pathname for the profile.
  24429.  
  24430.  See Also
  24431.  
  24432.  For information about             See
  24433.  ────────────────────────────────────────────────────────────────────────────
  24434.  Domains                           LAN Manager administrator's manual(s)
  24435.  
  24436.  Remote administration of net      LAN Manager administrator's manual(s)
  24437.  commands
  24438.  
  24439.  
  24440.  NetServerAdminCommand
  24441.  ────────────────────────────────────────────────────────────────────────────
  24442.  
  24443.  NetServerAdminCommand executes a command on a server.
  24444.  
  24445.  
  24446.  Operating Systems Supported
  24447.  
  24448.  
  24449.    ■   MS OS/2 version 1.2, local and remote
  24450.  
  24451.    ■   MS OS/2 version 1.1, remote only
  24452.  
  24453.    ■   MS-DOS, remote only
  24454.  
  24455.  
  24456.  
  24457.  Privilege Level
  24458.  
  24459.  Admin privilege is required to successfully execute NetServerAdminCommand on
  24460.  a remote server or on a computer that has local security enabled.
  24461.  
  24462.  
  24463.  Syntax
  24464.  
  24465.    #define INCL_NETSERVER
  24466.    #define INCL_NETERRORS
  24467.    #include <lan.h>
  24468.  
  24469.    API_FUNCTION
  24470.    NetServerAdminCommand (const char far *      pszServer,
  24471.                           const char far *      pszCommand,
  24472.                           short far *           psResult,
  24473.                           char far *            pbBuffer,
  24474.                           unsigned short        cbBuffer,
  24475.                           unsigned short far *  pcbReturned,
  24476.                           unsigned short far *  pcbTotalAvail
  24477.                          );
  24478.  
  24479.  where
  24480.  
  24481.  pszServer
  24482.    Points to an ASCIIZ string that contains the name of the server on which
  24483.    to execute NetServerAdminCommand. A null pointer or null string specifies
  24484.    the local computer.
  24485.  
  24486.  pszCommand
  24487.    Points to an ASCIIZ string that contains the command string to execute on
  24488.    the specified server.
  24489.  
  24490.  psResult
  24491.    Points to the returned exit code of the command executed on the specified
  24492.    server.
  24493.  
  24494.  pbBuffer
  24495.    Points to a buffer in which a string that contains the output returned by
  24496.    the command executed on the specified server is returned.
  24497.  
  24498.  cbBuffer
  24499.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  24500.  
  24501.  pcbReturned
  24502.    Points to an unsigned short integer that specifies the number of bytes
  24503.    returned in the buffer pointed to by pbBuffer.
  24504.  
  24505.  pcbTotalAvail
  24506.    Points to an unsigned short integer that specifies the number of bytes of
  24507.    return information available.
  24508.  
  24509.  Return Codes
  24510.  
  24511. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  24512.  Code                              Value   Meaning
  24513.  ────────────────────────────────────────────────────────────────────────────
  24514.  NERR_Success                      0       The function encountered no
  24515.                                            errors.
  24516.  
  24517.  ERROR_ACCESS_DENIED               5       The user has insufficient
  24518.                                            privilege for this operation.
  24519.  
  24520.  ERROR_BAD_NETPATH                 53      The network path was not found.
  24521.  
  24522.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  24523.  
  24524.  ERROR_INVALID_NAME                123     The character or file system
  24525.                                            name is invalid.
  24526.  
  24527.  ERROR_FILENAME_EXCED_RANGE        206     The filename specified is
  24528.                                            invalid for the file system.
  24529.                                            This code is returned when
  24530.  Code                              Value   Meaning
  24531.  ────────────────────────────────────────────────────────────────────────────
  24532.                                           This code is returned when
  24533.                                            checking a FAT disk partition
  24534.                                            only. It cannot be returned for
  24535.                                            an HPFS partition.
  24536.  
  24537.  ERROR_MORE_DATA                   234     Additional data is available.
  24538.  
  24539.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  24540.                                            is not installed.
  24541.  
  24542.  NERR_RemoteOnly                   2106    This operation can be performed
  24543.                                            only on a server.
  24544.  
  24545.  NERR_ServerNotStarted             2114    The Server service is not
  24546.                                            started.
  24547.  
  24548.  NERR_NoRoom                       2119    The server could not access
  24549.                                            enough of a resource, such as
  24550.                                            memory, to complete the task.
  24551.  Code                              Value   Meaning
  24552.  ────────────────────────────────────────────────────────────────────────────
  24553.                                           memory, to complete the task.
  24554.  
  24555.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  24556.  
  24557.  NERR_BadTransactConfig            2141    The server is not configured for
  24558.                                            this transaction: IPC$ is not
  24559.                                            shared.
  24560.  
  24561.  NERR_ExecFailure                  2315    A failure occurred when
  24562.                                            executing a remote
  24563.                                            administration command, probably
  24564.                                            because of a problem with the
  24565.                                            server's operating system
  24566.                                            configuration.
  24567.  
  24568.  NERR_TmpFile                      2316    A failure occurred when opening
  24569.                                            a remote temporary file.
  24570.  
  24571.  NERR_TooMuchData                  2317    The data returned from a remote
  24572.  Code                              Value   Meaning
  24573.  ────────────────────────────────────────────────────────────────────────────
  24574. NERR_TooMuchData                  2317    The data returned from a remote
  24575.                                            administration command was
  24576.                                            truncated to 64K.
  24577.  
  24578.  NERR_InvalidComputer              2351    The specified computername is
  24579.                                            invalid.
  24580.  
  24581.  ────────────────────────────────────────────────────────────────────────────
  24582.  
  24583.  
  24584.  
  24585.  
  24586.  Remarks
  24587.  
  24588.  NetServerAdminCommand is a remote form of the C-library system function.
  24589.  
  24590.  The command string pointed to by pszCommand can contain multiple commands
  24591.  linked by the following characters, as recognized by the operating system
  24592.  command shell:
  24593.  
  24594.  & && | || ;
  24595.  
  24596.  If multiple commands are specified, only the output of the last command is
  24597.  returned in the buffer pointed to by pbBuffer.
  24598.  
  24599.  If executed remotely, NetServerAdminCommand sets the server environment as
  24600.  follows:
  24601.  
  24602.  
  24603.    ■   The default drive and directory is LANMAN\NETPROG.
  24604.  
  24605.    ■   The PATH environment variable is set to no path.
  24606.  
  24607.  
  24608.  If executed locally, NetServerAdminCommand uses the following:
  24609.  
  24610.  
  24611.    ■   Current drive and directory of the caller.
  24612.  
  24613.    ■   Server's default PATH variable.
  24614.  
  24615.  
  24616.  See Also
  24617.  
  24618.  For information about             See
  24619.  ────────────────────────────────────────────────────────────────────────────
  24620.  Executing a program on a remote   NetRemoteExec
  24621.  server
  24622.  
  24623.  Listing available servers         NetServerEnum2
  24624.  
  24625.  
  24626.  NetServerDiskEnum
  24627.  ────────────────────────────────────────────────────────────────────────────
  24628.  
  24629.  NetServerDiskEnum retrieves a list of disk drives on a server.
  24630.  
  24631.  
  24632.  Operating Systems Supported
  24633.  
  24634.  
  24635.    ■   MS OS/2 version 1.2, local and remote
  24636.  
  24637.    ■   MS OS/2 version 1.1, local and remote
  24638.  
  24639.    ■   MS-DOS, local and remote
  24640.  
  24641.  
  24642.  
  24643.  Privilege Level
  24644.  
  24645.  Admin privilege or server operator privilege is required to successfully
  24646.  execute NetServerDiskEnum on a remote computer. No special privilege is
  24647.  required for local calls.
  24648.  
  24649.  
  24650.  Syntax
  24651.  
  24652.    #define INCL_NETSERVER
  24653.    #define INCL_NETERRORS
  24654.    #include <lan.h>
  24655.  
  24656.    API_FUNCTION
  24657.    NetServerDiskEnum (const char far *      pszServer,
  24658.                       short                 sLevel,
  24659.                       char far *            pbBuffer,
  24660.                       unsigned short        cbBuffer,
  24661.                       unsigned short far *  pcEntriesRead,
  24662.                       unsigned short far *  pcTotalAvail
  24663.                      );
  24664.  
  24665.  where
  24666.  
  24667.  pszServer
  24668.    Points to an ASCIIZ string that contains the name of the server on which
  24669.    to execute NetServerDiskEnum. A null pointer or null string specifies the
  24670.    local computer.
  24671.  
  24672.  sLevel
  24673.    Specifies the level of detail requested; must be 0.
  24674.  
  24675.  pbBuffer
  24676.    Points to consecutive ASCIIZ strings that specify the returned list of
  24677.    disk drive names. Each disk drive name string is terminated by the
  24678.    character NUL. The next disk drive name string, if defined, starts in the
  24679.    byte immediately following the terminating NUL. The list is terminated by
  24680.    a null string.
  24681.  
  24682.  cbBuffer
  24683.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  24684.  
  24685.  pcEntriesRead
  24686.    Points to an unsigned short integer in which a count of the number of disk
  24687.    drive name strings enumerated in the buffer is returned. This count is
  24688.    valid only if NetServerDiskEnum returns NERR_Success or ERROR_MORE_DATA.
  24689.  
  24690.  pcTotalAvail
  24691.    Points to an unsigned short integer in which a count of the total number
  24692.    of disk drive names available is returned. This count is valid only if
  24693.    NetServerDiskEnum returns NERR_Success or ERROR_MORE_DATA.
  24694.  
  24695.  Return Codes
  24696.  
  24697. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  24698.  Code                              Value   Meaning
  24699.  ────────────────────────────────────────────────────────────────────────────
  24700.  NERR_Success                      0       The function encountered no
  24701.                                            errors.
  24702.  
  24703.  ERROR_ACCESS_DENIED               5       The user has insufficient
  24704.                                            privilege for this operation.
  24705.  
  24706.  ERROR_BAD_NETPATH                 53      The network path was not found.
  24707.  
  24708.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  24709.  
  24710.  ERROR_INVALID_LEVEL               124     The level for information
  24711.                                            retrieval or setting is invalid.
  24712.  
  24713.  ERROR_MORE_DATA                   234     Additional data is available.
  24714.  
  24715.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  24716.                                            is not installed.
  24717.  
  24718.  NERR_WkstaNotStarted              2138    The Workstation service is not
  24719.  Code                              Value   Meaning
  24720.  ────────────────────────────────────────────────────────────────────────────
  24721. NERR_WkstaNotStarted              2138    The Workstation service is not
  24722.                                            started.
  24723.  
  24724.  NERR_BadTransactConfig            2141    The server is not configured for
  24725.                                            this transaction: IPC$ is not
  24726.                                            shared.
  24727.  
  24728.  NERR_InvalidComputer              2351    The specified computername is
  24729.                                            invalid.
  24730.  
  24731.  ────────────────────────────────────────────────────────────────────────────
  24732.  
  24733.  
  24734.  
  24735.  
  24736.  Remarks
  24737.  
  24738.  NetServerDiskEnum returns a list of local drive names for the specified
  24739.  server. The drive names in the list are consecutive strings, each containing
  24740.  a drive letter, a colon (:), and the character NUL that terminates the
  24741.  ASCIIZ string. For example, NetServerDiskEnum returns the following
  24742.  consecutive strings for a server with two floppy drives (A and B), one hard
  24743.  drive (C), and one RAM drive (E):
  24744.  
  24745.    A:\0B:\0C:\0E:\0\0
  24746.  
  24747.  NetServerDiskEnum works locally even if the server has not been started.
  24748.  
  24749.  See Also
  24750.  
  24751.  For information about             See
  24752.  ────────────────────────────────────────────────────────────────────────────
  24753.  Listing a server's shared         NetShareEnum
  24754.  resources
  24755.  
  24756.  Listing available servers         NetServerEnum2
  24757.  
  24758.  
  24759.  NetServerEnum2
  24760.  ────────────────────────────────────────────────────────────────────────────
  24761.  
  24762.  NetServerEnum2 lists all servers of the specified type(s) that are visible
  24763.  in the specified domain(s). For example, an application can call
  24764.  NetServerEnum2 to list all domain controllers only or all SQL servers only.
  24765.  
  24766.  
  24767.  
  24768.  Operating Systems Supported
  24769.  
  24770.  
  24771.    ■   MS OS/2 version 1.2, local and remote
  24772.  
  24773.    ■   MS OS/2 version 1.1, remote only
  24774.  
  24775.    ■   MS-DOS, local and remote
  24776.  
  24777.  
  24778.  
  24779.  Privilege Level
  24780.  
  24781.  No special privilege level is required to successfully execute
  24782.  NetServerEnum2.
  24783.  
  24784.  
  24785.  Syntax
  24786.  
  24787.    #define INCL_NETSERVER
  24788.    #define INCL_NETERRORS
  24789.    #include <lan.h>
  24790.  
  24791.    API_FUNCTION
  24792.    NetServerEnum2 (const char far *      pszServer,
  24793.                    short                 sLevel,
  24794.                    char far *            pbBuffer,
  24795.                    unsigned short        cbBuffer,
  24796.                    unsigned short far *  pcEntriesRead,
  24797.                    unsigned short far *  pcTotalAvail,
  24798.                    unsigned long         flServerType,
  24799.                    char far *            pszDomain
  24800.                   );
  24801.  
  24802.  where
  24803.  
  24804.  pszServer
  24805.    Points to an ASCIIZ string that contains the name of the server on which
  24806.    to execute NetServerEnum2. A null pointer or string specifies the local
  24807.    computer.
  24808.  
  24809.  sLevel
  24810.    Specifies the level of detail (0 or 1) requested.
  24811.  
  24812.  pbBuffer
  24813.    Points to the buffer in which to store the returned data. On a successful
  24814.    return, the buffer contains a sequence of server_info_X data structures,
  24815.    where X is 0 or 1, depending on the level of detail requested.
  24816.  
  24817.  cbBuffer
  24818.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  24819.  
  24820.  pcEntriesRead
  24821.    Points to an unsigned short integer in which a count of the number of
  24822.    servers enumerated in the buffer is returned. This count is valid only if
  24823.    NetServerEnum2 returns NERR_Success or ERROR_MORE_DATA.
  24824.  
  24825.  pcTotalAvail
  24826.    Points to an unsigned short integer in which a count of the total number
  24827.    of available entries is returned. This count is valid only if
  24828.    NetServerEnum2 returns NERR_Success or ERROR_MORE_DATA.
  24829.  
  24830.  flServerType
  24831.    Specifies the type(s) of servers to enumerate. The flServerType parameter
  24832.    is tested against the svX_type element of each entry. Entries that match
  24833.    at least one of the specified bits are included in the entries returned in
  24834.    the buffer and in the counts returned in pcEntriesRead and pcTotalAvail.
  24835.  
  24836.    The SERVER.H header file defines these flag bits:
  24837.  
  24838. ╓┌───────────────────────┌───────────┌───────────────────────────────────────╖
  24839.  Code                    Bit Mask    Type of Software
  24840.  ────────────────────────────────────────────────────────────────────────────
  24841.  SV_TYPE_WORKSTATION     0x00000001  Workstation.
  24842.  SV_TYPE_SERVER          0x00000002  Server.
  24843.  SV_TYPE_SQLSERVER       0x00000004  SQL server.
  24844.  SV_TYPE_DOMAIN_CTRL     0x00000008  Domain controller.
  24845.  Code                    Bit Mask    Type of Software
  24846.  ────────────────────────────────────────────────────────────────────────────
  24847. SV_TYPE_DOMAIN_CTRL     0x00000008  Domain controller.
  24848.  SV_TYPE_DOMAIN_BAKCTRL  0x00000010  Backup domain controller.
  24849.  SV_TYPE_TIME_SOURCE     0x00000020  Time server.
  24850.  SV_TYPE_AFP             0x00000040  Apple File Protocol (AFP) service.
  24851.  SV_TYPE_NOVELL          0x00000080  Novell service.
  24852.  SV_TYPE_ALL             0xFFFFFFFF  All types of servers.
  24853.  ────────────────────────────────────────────────────────────────────────────
  24854.  
  24855.  
  24856.  pszDomain
  24857.    Points to an ASCIIZ string that contains the name of the domain in which
  24858.    to enumerate servers of the specified type(s). The specified domain must
  24859.    be the primary domain, the logon domain, or a domain listed as one of the
  24860.    other domains for the computer specified by pszServer. (The domain name
  24861.    must appear in the wkiX_langroup, wkiX_logon_domain, or wkiX_oth_domains
  24862.    element of the wksta_info_X workstation data structure, where X is the
  24863.    level of detail specified.) If the domain does not meet these conditions,
  24864.    NetServerEnum2 returns NERR_NotLocalDomain.
  24865.  
  24866.    If pszDomain is a null string or a null pointer, servers are enumerated
  24867.    for the primary domain, logon domain, and other domains.
  24868.  
  24869.  Return Codes
  24870.  
  24871. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  24872.  Code                              Value   Meaning
  24873.  ────────────────────────────────────────────────────────────────────────────
  24874.  NERR_Success                      0       The function encountered no
  24875.                                            errors.
  24876.  
  24877.  ERROR_BAD_NETPATH                 53      The network path was not found.
  24878.  
  24879.  ERROR_INVALID_LEVEL               124     The level for information
  24880.                                            retrieval or setting is invalid.
  24881.  
  24882.  ERROR_MORE_DATA                   234     Additional data is available.
  24883.  
  24884.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  24885.                                            is not installed.
  24886.  
  24887.  Code                              Value   Meaning
  24888.  ────────────────────────────────────────────────────────────────────────────
  24889. 
  24890.  NERR_ServerNotStarted             2114    The Server service is not
  24891.                                            started.
  24892.  
  24893.  NERR_WkstaNotStarted              2138    The Workstation service is not
  24894.                                            started.
  24895.  
  24896.  NERR_BrowserNotStarted            2139    The mailslots entry of the
  24897.                                            workstation's LANMAN.INI file is
  24898.                                            incorrect.
  24899.  
  24900.  NERR_InvalidAPI                   2142    The requested API is not
  24901.                                            supported on the remote server.
  24902.  
  24903.  NERR_BrowserTableIncomplete       2319    The information in the list of
  24904.                                            servers may be incorrect.
  24905.  
  24906.  NERR_NotLocalDomain               2320    The computer is not active in
  24907.                                            this domain.
  24908.  Code                              Value   Meaning
  24909.  ────────────────────────────────────────────────────────────────────────────
  24910.                                           this domain.
  24911.  
  24912.  NERR_InvalidComputer              2351    The specified computername is
  24913.                                            invalid.
  24914.  
  24915.  ────────────────────────────────────────────────────────────────────────────
  24916.  
  24917.  
  24918.  
  24919.  
  24920.  Remarks
  24921.  
  24922.  If SV_TYPE_NOVELL or SV_TYPE_AFP is specified in the flServerType parameter,
  24923.  all servers running a service called "NOVELL" or "AFP," respectively, will
  24924.  be listed.
  24925.  
  24926.  If the workstation has been started with the mailslots = no entry in the
  24927.  LANMAN.INI file, NetServerEnum2 returns the NERR_BrowserNotStarted error
  24928.  code.
  24929.  
  24930.  NetServerEnum2 supersedes NetServerEnum (used in earlier versions of LAN
  24931.  Manager). These functions are the same except that NetServerEnum2 includes
  24932.  the flServerType and pszDomain parameters, which specify the type of server
  24933.  and the domain in which to enumerate that type of server. For more
  24934.  information, see Appendix B, "Upgrading LAN Manager 1.0 Applications."
  24935.  
  24936.  
  24937.  NetServerGetInfo
  24938.  ────────────────────────────────────────────────────────────────────────────
  24939.  
  24940.  NetServerGetInfo retrieves information about the specified server.
  24941.  
  24942.  
  24943.  Operating Systems Supported
  24944.  
  24945.  
  24946.    ■   MS OS/2 version 1.2, local and remote
  24947.  
  24948.    ■   MS OS/2 version 1.1, remote only
  24949.  
  24950.    ■   MS-DOS, remote only
  24951.  
  24952.  
  24953.  
  24954.  Privilege Level
  24955.  
  24956.  Admin privilege or accounts, comm, print, or server operator privilege is
  24957.  required to successfully execute NetServerGetInfo at levels 2 or 3 on a
  24958.  remote server or on a computer that has local security enabled. No special
  24959.  privilege is required for level 0 or level 1 calls.
  24960.  
  24961.  
  24962.  Syntax
  24963.  
  24964.    #define INCL_NETSERVER
  24965.    #define INCL_NETERRORS
  24966.    #include <lan.h>
  24967.  
  24968.    API_FUNCTION
  24969.    NetServerGetInfo (const char far *      pszServer,
  24970.                      short                 sLevel,
  24971.                      char far *            pbBuffer,
  24972.                      unsigned short        cbBuffer,
  24973.                      unsigned short far *  pcbTotalAvail
  24974.                     );
  24975.  
  24976.  where
  24977.  
  24978.  pszServer
  24979.    Points to an ASCIIZ string that contains the name of the server on which
  24980.    to execute NetServerGetInfo. A null pointer or null string specifies the
  24981.    local computer.
  24982.  
  24983.  sLevel
  24984.    Specifies the level of detail (0, 1, 2, or 3) requested.
  24985.  
  24986.  pbBuffer
  24987.    Points to the buffer in which to store the returned data. On a successful
  24988.    return, the buffer contains a server_info_X data structure, where X is 0,
  24989.    1, 2, or 3, depending on the level of detail requested.
  24990.  
  24991.  cbBuffer
  24992.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  24993.  
  24994.  pcbTotalAvail
  24995.    Points to an unsigned short integer in which a count of the total number
  24996.    of bytes of information available is returned. This count is valid only if
  24997.    NetServerGetInfo returns NERR_Success, ERROR_MORE_DATA, or
  24998.    NERR_BufTooSmall.
  24999.  
  25000.  Return Codes
  25001.  
  25002. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  25003.  Code                              Value   Meaning
  25004.  ────────────────────────────────────────────────────────────────────────────
  25005.  NERR_Success                      0       The function encountered no
  25006.                                            errors.
  25007.  
  25008.  ERROR_ACCESS_DENIED               5       The user has insufficient
  25009.                                            privilege for this operation.
  25010.  
  25011.  ERROR_BAD_NETPATH                 53      The network path was not found.
  25012.  
  25013.  Code                              Value   Meaning
  25014.  ────────────────────────────────────────────────────────────────────────────
  25015. 
  25016.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  25017.  
  25018.  ERROR_INVALID_LEVEL               124     The level for information
  25019.                                            retrieval or setting is invalid.
  25020.  
  25021.  ERROR_MORE_DATA                   234     Additional data is available.
  25022.  
  25023.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  25024.                                            is not installed.
  25025.  
  25026.  NERR_RemoteOnly                   2106    This operation can be performed
  25027.                                            only on a server.
  25028.  
  25029.  NERR_ServerNotStarted             2114    The Server service is not
  25030.                                            started.
  25031.  
  25032.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  25033.  
  25034.  Code                              Value   Meaning
  25035.  ────────────────────────────────────────────────────────────────────────────
  25036. 
  25037.  NERR_WkstaNotStarted              2138    The Workstation service is not
  25038.                                            started.
  25039.  
  25040.  NERR_BadTransactConfig            2141    The server is not configured for
  25041.                                            this transaction: IPC$ is not
  25042.                                            shared.
  25043.  
  25044.  NERR_InvalidComputer              2351    The specified computername is
  25045.                                            invalid.
  25046.  
  25047.  ────────────────────────────────────────────────────────────────────────────
  25048.  
  25049.  
  25050.  
  25051.  See Also
  25052.  
  25053.  For information about             See
  25054.  ────────────────────────────────────────────────────────────────────────────
  25055.  Configuring a server              NetServerSetInfo
  25056.  
  25057.  
  25058.  NetServerSetInfo
  25059.  ────────────────────────────────────────────────────────────────────────────
  25060.  
  25061.  NetServerSetInfo sets a server's operating parameters; it can set them
  25062.  individually or collectively.
  25063.  
  25064.  
  25065.  Operating Systems Supported
  25066.  
  25067.  
  25068.    ■   MS OS/2 version 1.2, local and remote
  25069.  
  25070.    ■   MS OS/2 version 1.1, remote only
  25071.  
  25072.    ■   MS-DOS, remote only
  25073.  
  25074.  
  25075.  
  25076.  Privilege Level
  25077.  
  25078.  Admin privilege or server operator privilege is required to successfully
  25079.  execute NetServerSetInfo on a remote server or on a computer that has local
  25080.  security enabled.
  25081.  
  25082.  
  25083.  Syntax
  25084.  
  25085.    #define INCL_NETSERVER
  25086.    #define INCL_NETERRORS
  25087.    #include <lan.h>
  25088.  
  25089.    API_FUNCTION
  25090.    NetServerSetInfo (const char far *  pszServer,
  25091.                      short             sLevel,
  25092.                      const char far *  pbBuffer,
  25093.                      unsigned short    cbBuffer,
  25094.                      short             sParmNum
  25095.                     );
  25096.  
  25097.  where
  25098.  
  25099.  pszServer
  25100.    Points to an ASCIIZ string that contains the name of the server on which
  25101.    to execute NetServerSetInfo. A null pointer or null string specifies the
  25102.    local computer.
  25103.  
  25104.  sLevel
  25105.    Specifies the level of detail (1, 2, or 3) provided in the buffer pointed
  25106.    to by pbBuffer.
  25107.  
  25108.  pbBuffer
  25109.    Points to the data to be set.
  25110.  
  25111.  cbBuffer
  25112.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  25113.  
  25114.  sParmNum
  25115.    Specifies whether to set all the server information or to change only a
  25116.    part of it. If sParmNum is PARMNUM_ALL, pbBuffer must point to a
  25117.    server_info_X data structure (where X is 1, 2, or 3, depending on the
  25118.    level of detail being set). If sParmNum is any other defined value, only
  25119.    one element of the server information is changed, and pbBuffer must point
  25120.    to a valid value for that element.
  25121.  
  25122.    Not all elements can be set. Only those elements that have a specific
  25123.    PARMNUM constant value defined can be set. The SERVER.H header file
  25124.    defines these possible values for sParmNum:
  25125.  
  25126. ╓┌───────────────────────┌──────┌────────────────────────────────────────────╖
  25127.  Code                    Value  Element of server_info_X
  25128.  ────────────────────────────────────────────────────────────────────────────
  25129.  PARMNUM_ALL             0      All elements.
  25130.  SV_COMMENT_PARMNUM      5      svX_comment
  25131.  SV_DISC_PARMNUM         10     svX_disc
  25132.  SV_ALERTS_PARMNUM       11     svX_alerts
  25133.  SV_HIDDEN_PARMNUM       16     svX_hidden
  25134.  SV_ANNOUNCE_PARMNUM     17     svX_announce
  25135.  SV_ANNDELTA_PARMNUM     18     svX_anndelta
  25136.  SV_ALERTSCHED_PARMNUM   37     svX_alertsched
  25137.  SV_ERRORALERT_PARMNUM   38     svX_erroralert
  25138.  SV_LOGONALERT_PARMNUM   39     svX_logonalert
  25139.  Code                    Value  Element of server_info_X
  25140.  ────────────────────────────────────────────────────────────────────────────
  25141. SV_LOGONALERT_PARMNUM   39     svX_logonalert
  25142.  SV_ACCESSALERT_PARMNUM  40     svX_accessalert
  25143.  SV_DISKALERT_PARMNUM    41     svX_diskalert
  25144.  SV_NETIOALERT_PARMNUM   42     svX_netioalert
  25145.  SV_MAXAUDITSZ_PARMNUM   43     svX_maxauditsz
  25146.  ────────────────────────────────────────────────────────────────────────────
  25147.  
  25148.  
  25149.  Return Codes
  25150.  
  25151. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  25152.  Code                              Value   Meaning
  25153.  ────────────────────────────────────────────────────────────────────────────
  25154.  NERR_Success                      0       The function encountered no
  25155.                                            errors.
  25156.  
  25157.  ERROR_ACCESS_DENIED               5       The user has insufficient
  25158.                                            privilege for this operation.
  25159.  
  25160.  Code                              Value   Meaning
  25161.  ────────────────────────────────────────────────────────────────────────────
  25162. 
  25163.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  25164.  
  25165.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  25166.                                            invalid.
  25167.  
  25168.  ERROR_INVALID_LEVEL               124     The level for information
  25169.                                            retrieval or setting is invalid.
  25170.  
  25171.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  25172.                                            is not installed.
  25173.  
  25174.  NERR_RemoteOnly                   2106    This operation can be performed
  25175.                                            only on a server.
  25176.  
  25177.  NERR_ServerNotStarted             2114    The Server service is not
  25178.                                            started.
  25179.  
  25180.  NERR_NoRoom                       2119    The server could not access
  25181.  Code                              Value   Meaning
  25182.  ────────────────────────────────────────────────────────────────────────────
  25183. NERR_NoRoom                       2119    The server could not access
  25184.                                            enough of a resource, such as
  25185.                                            memory, to complete the task.
  25186.  
  25187.  NERR_WkstaNotStarted              2138    The Workstation service is not
  25188.                                            started.
  25189.  
  25190.  NERR_BadTransactConfig            2141    The server is not configured for
  25191.                                            this transaction: IPC$ is not
  25192.                                            shared.
  25193.  
  25194.  NERR_InvalidComputer              2351    The specified computername is
  25195.                                            invalid.
  25196.  
  25197.  ────────────────────────────────────────────────────────────────────────────
  25198.  
  25199.  
  25200.  
  25201.  See Also
  25202.  
  25203.  For information about             See
  25204.  ────────────────────────────────────────────────────────────────────────────
  25205.  Remote calls                      Chapter 1, "Overview of the LAN Manager
  25206.                                    API"
  25207.  
  25208.  Retrieving information about the  NetServerGetInfo
  25209.  configuration of a server
  25210.  
  25211.  
  25212.  
  25213.  
  25214.  
  25215.  Server Category Example
  25216.  
  25217.    /*
  25218.       NETSERV.C -- a sample program demonstrating NetServer API functions.
  25219.  
  25220.          usage:  netserv  [-s \\servername] [-c comment] [-l level]
  25221.                           [-t type] [-a admin command] [-d domain]
  25222.          where  \\server = Name of the server. A servername must be preceded
  25223.                            by two backslashes (\\).
  25224.                 comment  = New comment for the server.
  25225.                 level    = Level of detail to be provided/supplied.
  25226.                 type     = Types of servers to enumerate.
  25227.                 admin command = Command line for remote admin.
  25228.                 domain   = List of domains to count.
  25229.  
  25230.       API                       Used to...
  25231.       =====================     ============================================
  25232.       NetServerGetInfo          Return information about the server
  25233.                                 configuration
  25234.       NetServerSetInfo          Change the configuration of the server
  25235.       NetServerEnum2            List the servers visible on the network
  25236.       NetServerDiskEnum         List the disk drives on the server
  25237.       NetServerAdminCommand     Execute a sequence of commands on the
  25238.    server
  25239.  
  25240.       This code sample is provided for demonstration purposes only.
  25241.       Microsoft makes no warranty, either express or implied,
  25242.       as to its usability in any given situation.
  25243.    */
  25244.  
  25245.    #define  INCL_BASE
  25246.    #include <os2.h>                        // MS OS/2 base header files
  25247.  
  25248.    #define  INCL_NETERRORS
  25249.    #define  INCL_NETSERVER
  25250.    #include <lan.h>                        // LAN Manager header files
  25251.  
  25252.    #include <stdio.h>                      // C run-time header files
  25253.    #include <stdlib.h>
  25254.    #include <string.h>
  25255.    #include <malloc.h>
  25256.  
  25257.    #include "samples.h"                    // Internal routine header
  25258.    file
  25259.  
  25260.    #define A_CMD_STRING       "c: & cd \\ & dir"
  25261.    #define A_COMMENT          "This is a new comment"
  25262.    #define BIG_BUFFER_SIZE    32768
  25263.  
  25264.    void Usage(char *pszString);
  25265.    void main(int argc, char * argv[])
  25266.    {
  25267.       char * pszServer = "";             // NULL or null string = local
  25268.       char * pbBuffer;                   // Pointer to data buffer
  25269.       char * pszDisk;                    // Return string NetServerDiskEnum
  25270.       char * pszComment = A_COMMENT;     // New comment string
  25271.       char * pszCommand = A_CMD_STRING;  // Cmd for NetServerAdminCommand
  25272.       char far * pszDomain = NULL;       // Input to NetServerEnum2
  25273.       int iCount;                        // Index and loop counter
  25274.       short sLevel = 0;                  // Level of detail requested
  25275.       API_RET_TYPE uReturnCode;          // API return code
  25276.       unsigned short usRemoteRetCode;    // Return code of remote command
  25277.       unsigned short cbBuffer;           // Size of buffer, in bytes
  25278.       unsigned short cEntriesRead;       // Count of records returned
  25279.       unsigned short cTotalEntries;      // Count of records available
  25280.  
  25281.       unsigned short cbReturned;         // Count of bytes returned
  25282.       unsigned short cbTotalAvail;       // Count of bytes available
  25283.  
  25284.       unsigned long flServerType = SV_TYPE_SERVER;  // List of servers
  25285.  
  25286.       struct server_info_0 *pServer0;    // Pointer to level 0 structure
  25287.       struct server_info_1 *pServer1;    // Pointer to level 1 structure
  25288.       struct server_info_2 *pServer2;    // Pointer to level 2 structure
  25289.       struct server_info_3 *pServer3;    // Pointer to level 3 structure
  25290.  
  25291.       for (iCount = 1; iCount < argc; iCount++)
  25292.       {
  25293.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  25294.          {
  25295.             switch (tolower(*(argv[iCount]+1))) // Process switches
  25296.             {
  25297.                case 's':                        // -s servername
  25298.                   pszServer = argv[++iCount];
  25299.                   break;
  25300.                case 'a':                        // -a admin command
  25301.                   pszCommand = argv[++iCount];
  25302.                   break;
  25303.                case 'c':                        // -c comment
  25304.                   pszComment = argv[++iCount];
  25305.                   break;
  25306.                case 'l':                        // -l level
  25307.                   sLevel = (short)(atoi(argv[++iCount]));
  25308.                   break;
  25309.                case 'd':                        // -d domain
  25310.                   pszDomain = argv[++iCount];
  25311.                   break;
  25312.  
  25313.    case 't':                        // -t type
  25314.                   flServerType = (unsigned long)(atoi(argv[++iCount]));
  25315.                   break;
  25316.                default:
  25317.                   Usage(argv[0]);
  25318.                }
  25319.             }
  25320.          else
  25321.             Usage(argv[0]);
  25322.       } // End for loop
  25323.  
  25324.    //========================================================================
  25325.    //  NetServerGetInfo
  25326.    //
  25327.    //  This API returns information about the server's configuration
  25328.  
  25329.    //  components. The returned data reflects the current configuration,
  25330.  
  25331.    //  including any modifications made by calls to NetServerSetInfo.
  25332.  
  25333.    //  The results returned by this API will not necessarily match the
  25334.    //  contents of the LANMAN.INI file; use NetConfigGet2 to get the
  25335.    //  default values stored in the LANMAN.INI file.
  25336.    //========================================================================
  25337.  
  25338.      /*
  25339.       *  The structure returned by NetServerGetInfo is a combination
  25340.       *  of data elements and pointers to variable-size elements within
  25341.    the
  25342.       *  returned data. Because of this, the size of the data buffer
  25343.    passed
  25344.       *  to the API must be larger than the size of the structure. The
  25345.    extra
  25346.       *  space is needed for variable-length strings such as comment
  25347.    elements.
  25348.       *  The first call is used to determine how large a buffer is needed;
  25349.       *  the second call is used to obtain the data.
  25350.       */
  25351.  
  25352.       uReturnCode = NetServerGetInfo(pszServer, // Servername
  25353.                   sLevel,                       // Reporting level (0,1,2,3)
  25354.                   NULL,                         // Target buffer for
  25355.    info
  25356.                   0,                            // Size of target buffer
  25357.                   &cbTotalAvail);               // Total info available
  25358.       cbBuffer = cbTotalAvail;
  25359.       pbBuffer = SafeMalloc(cbBuffer);
  25360.  
  25361.       uReturnCode = NetServerGetInfo(pszServer, // Servername
  25362.                   sLevel,                       // Reporting level (0,1,2,3)
  25363.                   pbBuffer,                     // Target buffer for
  25364.    info
  25365.                   cbBuffer,                     // Size of target buffer
  25366.                   &cbTotalAvail);               // Total amount of info
  25367.       printf("NetServerGetInfo returned %u\n", uReturnCode);
  25368.  
  25369.       if (uReturnCode == NERR_Success)
  25370.       {
  25371.          switch (sLevel)
  25372.          {
  25373.             case 3:
  25374.                pServer3 = (struct server_info_3 *) pbBuffer;
  25375.                printf("   Audited events : 0x%lX\n",
  25376.                           pServer3->sv3_auditedevents);
  25377.             case 2:
  25378.                pServer2 = (struct server_info_2 *) pbBuffer;
  25379.                printf("   Heuristics     : %Fs\n",
  25380.                           pServer2->sv2_srvheuristics);
  25381.             case 1:
  25382.                pServer1 = (struct server_info_1 *) pbBuffer;
  25383.                printf("   Major version #: %hu\n",
  25384.                           pServer1->sv1_version_major & MAJOR_VERSION_MASK);
  25385.                printf("   Type           : 0x%X\n", pServer1->sv1_type);
  25386.                printf("   Comment        : %Fs\n", pServer1->sv1_comment);
  25387.             case 0:
  25388.                pServer0 = (struct server_info_0 *) pbBuffer;
  25389.                printf("   Computer Name  : %s\n", pServer0->sv0_name);
  25390.                break;
  25391.             default:
  25392.                printf("   Level %hu is not supported\n", sLevel);
  25393.                break;
  25394.          }
  25395.       }
  25396.       free(pbBuffer);
  25397.  
  25398.    //========================================================================
  25399.    //  NetServerSetInfo
  25400.    //
  25401.    //  This API function sets configuration components for the specified
  25402.  
  25403.    //  server. Note that the function does not change default configuration
  25404.  
  25405.    //  parameters in the LANMAN.INI file.
  25406.    //
  25407.    //  All SetInfo API functions can be called in two ways: to set all
  25408.    //  parameters, or to set a single parameter. To set all parameters,
  25409.    //  call NetServerGetInfo to obtain the current values of all
  25410.    //  parameters, modify the components to change, and then call
  25411.    //  NetServerSetInfo. To set one parameter, set the buffer pointer
  25412.  
  25413.    //  to point to the new value for that parameter, and then call
  25414.    //  NetServerSetInfo using the corresponding sParmNum value. In this
  25415.  
  25416.    //  example, NetServerSetInfo sets the server's comment field.
  25417.    //========================================================================
  25418.  
  25419.    uReturnCode = NetServerSetInfo(pszServer,    // Servername
  25420.                               sLevel,              // Level of detail
  25421.    (0,1)
  25422.                               pszComment,          // Pointer to input
  25423.    data
  25424.                               strlen(pszComment)+1,// String length +
  25425.    NUL
  25426.                               SV_COMMENT_PARMNUM); // Change comment
  25427.    only
  25428.  
  25429.       printf("NetServerSetInfo returned %u\n", uReturnCode);
  25430.       printf("   Set comment to \"%s\" ", pszComment);
  25431.       printf(" %s\n", uReturnCode ? "failed" : "succeeded");
  25432.  
  25433.    //========================================================================
  25434.    //  NetServerEnum2
  25435.    //
  25436.    //  This API lists all servers visible on the network in the given
  25437.    domain.
  25438.    //  In this example, the domain argument is NULL, indicating to list
  25439.  
  25440.    //  servers in the workstation's domain, its logon domain, and its
  25441.    other
  25442.    //  domains.
  25443.    //========================================================================
  25444.  
  25445.       cbBuffer = BIG_BUFFER_SIZE;                // Can be up to 64K
  25446.       pbBuffer = SafeMalloc(cbBuffer);           // Allocate space for
  25447.    buffer
  25448.  
  25449.       uReturnCode = NetServerEnum2(pszServer,    // Servername
  25450.                                   sLevel,        // Reporting level (0,1)
  25451.                                   pbBuffer,      // Buffer containing
  25452.    data
  25453.                                   cbBuffer,      // Size of buffer, in
  25454.    bytes
  25455.                                   &cEntriesRead, // Entries in buffer
  25456.                                   &cTotalEntries,// Count of entries
  25457.    available
  25458.                                   flServerType,  // Type(s) to enumerate
  25459.                                   pszDomain);    // Server's domain(s)
  25460.  
  25461.       printf("NetServerEnum2 returned %u\n", uReturnCode);
  25462.  
  25463.       if (uReturnCode == NERR_Success)
  25464.       {
  25465.          pServer0 = (struct server_info_0 *) pbBuffer;
  25466.          pServer1 = (struct server_info_1 *) pbBuffer;
  25467.          pServer2 = (struct server_info_2 *) pbBuffer;
  25468.          pServer3 = (struct server_info_3 *) pbBuffer;
  25469.  
  25470.    for (iCount = 0; iCount < (int) cEntriesRead; iCount++)
  25471.          {
  25472.             switch (sLevel)
  25473.             {
  25474.                case 0:
  25475.                   printf("   Computer Name : %s\n", pServer0->sv0_name);
  25476.                   pServer0++;
  25477.                   break;
  25478.                case 1:
  25479.                   printf("   Computer Name : %s\n", pServer1->sv1_name);
  25480.                   printf("   Type          : 0x%X\n", pServer1->sv1_type);
  25481.                   pServer1++;
  25482.                   break;
  25483.                case 2:
  25484.                   printf("  Computer Name : %s\n", pServer2->sv2_name);
  25485.                   printf("  Type          : 0x%X\n", pServer2->sv2_type);
  25486.                   pServer2++;
  25487.                   break;
  25488.                case 3:
  25489.                   printf("  Computer Name : %s\n", pServer3->sv3_name);
  25490.                   printf("  Type          : 0x%X\n", pServer3->sv3_type);
  25491.                   pServer3++;
  25492.                   break;
  25493.                default:
  25494.                   break;
  25495.             } // End switch (sLevel)
  25496.          } // End for loop
  25497.          printf("%hu entries returned out of ", cEntriesRead);
  25498.          printf("%hu available\n", cTotalEntries);
  25499.       } // End if successful return
  25500.  
  25501.    //========================================================================
  25502.    //  NetServerDiskEnum
  25503.    //
  25504.    //  This API lists all the local disk drives for the specified server,
  25505.  
  25506.    //  including hard disk drives, floppy disk drives, and RAM drives.
  25507.    //========================================================================
  25508.  
  25509.       uReturnCode = NetServerDiskEnum(pszServer,  // Servername
  25510.                                  0,               // Level; must be 0
  25511.                                  pbBuffer,        // Results buffer
  25512.                                  cbBuffer,        // Size of buffer,
  25513.    in bytes
  25514.                                  &cEntriesRead,   // Count of entries
  25515.    read
  25516.                                  &cTotalEntries); // Count of entries
  25517.    available
  25518.  
  25519.       printf("NetServerDiskEnum returned %u\n", uReturnCode);
  25520.  
  25521.       if (uReturnCode == NERR_Success)        // Print returned info
  25522.       {
  25523.          pszDisk = pbBuffer;
  25524.          printf("   Disk drives on server %s : \n", pszServer);
  25525.          for (iCount = 0; iCount < (int) cEntriesRead; iCount++)
  25526.  
  25527.    {
  25528.             printf("   %s\n", pszDisk);
  25529.             pszDisk += (strlen(pszDisk) + 1); // Skip NUL, get next string
  25530.          }
  25531.          printf("%hu entries returned out of ", cEntriesRead);
  25532.          printf("%hu available\n", cTotalEntries);
  25533.       }
  25534.  
  25535.    //========================================================================
  25536.    //  NetServerAdminCommand
  25537.    //
  25538.    //  This API executes a sequence of commands on the specified server.
  25539.    //  The default command string, "c: & cd \\ & dir", changes the current
  25540.    //  drive to the C: drive, changes the directory to the root C:\,
  25541.    //  and performs a list directory DIR command. The results returned
  25542.    //  in the buffer are displayed.
  25543.    //========================================================================
  25544.  
  25545.       if ((pszServer != NULL) && (pszServer[0] != '\0'))
  25546.          printf("On server %s", pszServer);
  25547.       else
  25548.          printf("On local computer");
  25549.       printf(" execute command string \"%s\"\n", pszCommand);
  25550.  
  25551.       uReturnCode = NetServerAdminCommand(pszServer, // Servername
  25552.                                  pszCommand,         // Commands to execute
  25553.                                  &usRemoteRetCode,   // Ret code of last
  25554.    cmd
  25555.                                  pbBuffer,           // Results buffer
  25556.                                  cbBuffer,           // Size of buffer
  25557.                                  &cbReturned,        // Count of bytes
  25558.    returned
  25559.                                  &cbTotalAvail);     // Count of bytes
  25560.    avail
  25561.  
  25562.    printf("NetServerAdminCommand returned %u\n", uReturnCode);
  25563.       if (uReturnCode == NERR_Success)               // Print returned
  25564.    info
  25565.       {
  25566.          printf("Return code of last command : %hu\n", usRemoteRetCode);
  25567.  
  25568.          printf("%hu out of %hu bytes returned\n", cbReturned, cbTotalAvail);
  25569.          printf("Buffer contents:\n");
  25570.          for (iCount = 0; iCount < (int) cbReturned; iCount++)
  25571.             printf("%c", *((char *)pbBuffer++) );
  25572.       }
  25573.  
  25574.       free(pbBuffer);
  25575.       exit(0);
  25576.       }
  25577.  
  25578.  
  25579.    //  Usage
  25580.    //
  25581.    //  Display possible command-line switches for this example.
  25582.  
  25583.    void Usage(char *pszString)
  25584.    {
  25585.       fprintf(stderr, "Usage: %s [-s \\\\server]", pszString);
  25586.       fprintf(stderr, " [-c comment] [-l level]\n [-t type]");
  25587.       fprintf(stderr, " [-a admin command] [-d domain(s)]\n");
  25588.       exit(1);
  25589.    }
  25590.  
  25591.  
  25592.  
  25593.  
  25594.  
  25595.  
  25596.  
  25597.  Session Category
  25598.  
  25599.  Session API functions control network sessions established between
  25600.  workstations and servers. They require that the Server service be started on
  25601.  the specified server.
  25602.  
  25603.  The Session category functions, datatypes, structures, and constants are
  25604.  defined in the NETCONS.H, NETERR.H, and SHARES.H header files. A source
  25605.  program can access these definitions by defining the constants
  25606.  INCL_NETERRORS and INCL_NETSESSION, and including the master header file,
  25607.  LAN.H. For more information, see the "Example" section, later in this
  25608.  category.
  25609.  
  25610.  These are the Session API functions:
  25611.  
  25612.  
  25613.    ■   NetSessionDel
  25614.  
  25615.    ■   NetSessionEnum
  25616.  
  25617.    ■   NetSessionGetInfo
  25618.  
  25619.  
  25620.  
  25621.  Description
  25622.  
  25623.  A session is a link between a workstation and a server. It is established
  25624.  the first time a workstation makes a connection with a shared resource on
  25625.  the server. Until the session ends, all further connections between the
  25626.  workstation and the server are part of this same session.
  25627.  
  25628.  To end a session, an application on the server end of a connection calls
  25629.  NetSessionDel. This deletes all current connections between the workstation
  25630.  and the server.
  25631.  
  25632.  NetSessionEnum returns information about all sessions established for a
  25633.  server. NetSessionGetInfo returns information about a particular session.
  25634.  
  25635.  
  25636.  Data Structures
  25637.  
  25638.  NetSessionEnum and NetSessionGetInfo return session_info_X data structures,
  25639.  where X is 0, 1, 2, or 10, depending on the level of data requested.
  25640.  
  25641.  
  25642.  Session Information (level 0)
  25643.  
  25644.  The session_info_0 data structure has this format:
  25645.  
  25646.    struct session_info_0 {
  25647.        char far *  sesi0_cname;
  25648.    };
  25649.  
  25650.  where
  25651.  
  25652.  sesi0_cname
  25653.    Points to an ASCIIZ string that contains the computername of the
  25654.    workstation that established the session.
  25655.  
  25656.  
  25657.  Session Information (level 1)
  25658.  
  25659.  The session_info_1 data structure has this format:
  25660.  
  25661.    struct session_info_1 {
  25662.        char far *      sesi1_cname;
  25663.        char far *      sesi1_username;
  25664.        unsigned short  sesi1_num_conns;
  25665.        unsigned short  sesi1_num_opens;
  25666.        unsigned short  sesi1_num_users;
  25667.        unsigned long   sesi1_time;
  25668.        unsigned long   sesi1_idle_time;
  25669.        unsigned long   sesi1_user_flags;
  25670.    };
  25671.  
  25672.  where
  25673.  
  25674.  sesi1_cname
  25675.    Points to an ASCIIZ string that contains the computername of the
  25676.    workstation that established the session.
  25677.  
  25678.  sesi1_username
  25679.    Points to an ASCIIZ string that contains the name of the user who
  25680.    established the session.
  25681.  
  25682.  sesi1_num_conns
  25683.    Specifies how many connections have been made during the session.
  25684.  
  25685.  sesi1_num_opens
  25686.    Specifies how many files, devices, and pipes have been opened during the
  25687.    session.
  25688.  
  25689.  sesi1_num_users
  25690.    Specifies how many users have made connections via the session.
  25691.  
  25692.  sesi1_time
  25693.    Specifies how long (in seconds) a session has been active.
  25694.  
  25695.  sesi1_idle_time
  25696.    Specifies how long (in seconds) a session has been idle.
  25697.  
  25698.  sesi1_user_flags
  25699.    Specifies how the user established the session. The SHARES.H header file
  25700.    defines this bit mask for sesi1_user_flags:
  25701.  
  25702.  Code               Bit  Meaning
  25703.  ────────────────────────────────────────────────────────────────────────────
  25704.  SESS_GUEST         1    User specified by sesi1_username established the
  25705.                          session using a guest account.
  25706.  
  25707.  SESS_NOENCRYPTION  2    User specified by sesi1_username established the
  25708.                          session without using password encryption.
  25709.  
  25710.  ────────────────────────────────────────────────────────────────────────────
  25711.  
  25712.  
  25713.  
  25714.  Session Information (level 2)
  25715.  
  25716.  The session_info_2 data structure has this format:
  25717.  
  25718.    struct session_info_2 {
  25719.        char far *      sesi2_cname;
  25720.        char far *      sesi2_username;
  25721.        unsigned short  sesi2_num_conns;
  25722.        unsigned short  sesi2_num_opens;
  25723.        unsigned short  sesi2_num_users;
  25724.        unsigned long   sesi2_time;
  25725.        unsigned long   sesi2_idle_time;
  25726.        unsigned long   sesi2_user_flags;
  25727.        char far *      sesi2_cltype_name;
  25728.    };
  25729.  
  25730.  where
  25731.  
  25732.  sesi2_cname through sesi2_user_flags
  25733.    Are the same as the corresponding elements of the session_info_1 data
  25734.    structure. For a complete description, see the preceding section.
  25735.  
  25736.  sesi2_cltype_name
  25737.    Points to an ASCIIZ string that specifies the type of client that
  25738.    established the session. These are the defined types for LAN Manager
  25739.    servers:
  25740.  
  25741. ╓┌─────────────────────────────────┌─────────────────────────────────────────╖
  25742.  Name                              Type
  25743.  ────────────────────────────────────────────────────────────────────────────
  25744.  DOWN LEVEL                        Old clients (for example, Microsoft
  25745.                                    Networks, PC LAN, XENIX(R)).
  25746.  
  25747.  DOS LM                            LAN Manager 1.0 for MS-DOS clients
  25748.  Name                              Type
  25749.  ────────────────────────────────────────────────────────────────────────────
  25750. DOS LM                            LAN Manager 1.0 for MS-DOS clients
  25751.                                    (Basic and Enhanced) and LAN Manager 2.0
  25752.                                    for MS-DOS Basic clients.
  25753.  
  25754.  DOS LM 2.0                        LAN Manager 2.0 for MS-DOS Enhanced
  25755.                                    clients.
  25756.  
  25757.  OS/2 LM 1.0                       LAN Manager 1.0 for MS OS/2 clients, or
  25758.                                    LAN Manager 2.0 for MS OS/2 with MS OS/2
  25759.                                    1.1.
  25760.  
  25761.  OS/2 LM 2.0                       LAN Manager 2.0 for MS OS/2 clients.
  25762.  
  25763.  ────────────────────────────────────────────────────────────────────────────
  25764.  
  25765.  
  25766.  
  25767.  
  25768.  Session Information (level 10)
  25769.  
  25770.  The session_info_10 data structure has this format:
  25771.  
  25772.    struct session_info_10 {
  25773.        char far *     sesi10_cname;
  25774.        char far *     sesi10_username;
  25775.        unsigned long  sesi10_time;
  25776.        unsigned long  sesi10_idle_time;
  25777.    };
  25778.  
  25779.  where
  25780.  
  25781.  sesi10_cname through sesi10_idle_time
  25782.    Are the same as the corresponding elements of the session_info_1 data
  25783.    structure. For a complete description, see "Session Information (level
  25784.    1)," earlier in this category.
  25785.  
  25786.  See Also
  25787.  
  25788.  For information about             See
  25789.  ────────────────────────────────────────────────────────────────────────────
  25790.  Guest accounts                    User Category
  25791.  
  25792.  
  25793.  NetSessionDel
  25794.  ────────────────────────────────────────────────────────────────────────────
  25795.  
  25796.  NetSessionDel ends a session between a server and a workstation.
  25797.  
  25798.  
  25799.  Operating Systems Supported
  25800.  
  25801.  
  25802.    ■   MS OS/2 version 1.2, local and remote
  25803.  
  25804.    ■   MS OS/2 version 1.1, remote only
  25805.  
  25806.    ■   MS-DOS, remote only
  25807.  
  25808.  
  25809.  
  25810.  Privilege Level
  25811.  
  25812.  Admin privilege or server operator privilege is required to successfully
  25813.  execute NetSessionDel on a remote server or on a computer that has local
  25814.  security enabled.
  25815.  
  25816.  
  25817.  Syntax
  25818.  
  25819.    #define INCL_NETSESSION
  25820.    #define INCL_NETERRORS
  25821.    #include <lan.h>
  25822.  
  25823.    API_FUNCTION
  25824.    NetSessionDel (const char far *  pszServer,
  25825.                   const char far *  pszClientName,
  25826.                   short             sReserved
  25827.                  );
  25828.  
  25829.  where
  25830.  
  25831.  pszServer
  25832.    Points to an ASCIIZ string that contains the name of the server on which
  25833.    to execute NetSessionDel. A null pointer or null string specifies the
  25834.    local server.
  25835.  
  25836.  pszClientName
  25837.    Points to an ASCIIZ string that contains the remote name of the computer
  25838.    whose session is being discontinued. The name must be preceded by two
  25839.    backslashes (for example, \\client).
  25840.  
  25841.  sReserved
  25842.    Reserved; must be 0.
  25843.  
  25844.  Return Codes
  25845.  
  25846. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  25847.  Code                              Value   Meaning
  25848.  ────────────────────────────────────────────────────────────────────────────
  25849.  NERR_Success                      0       The function encountered no
  25850.                                            errors.
  25851.  
  25852.  ERROR_ACCESS_DENIED               5       The user has insufficient
  25853.  Code                              Value   Meaning
  25854.  ────────────────────────────────────────────────────────────────────────────
  25855. ERROR_ACCESS_DENIED               5       The user has insufficient
  25856.                                            privilege for this operation.
  25857.  
  25858.  ERROR_BAD_NETPATH                 53      The network path was not found.
  25859.  
  25860.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  25861.  
  25862.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  25863.                                            invalid.
  25864.  
  25865.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  25866.                                            is not installed.
  25867.  
  25868.  NERR_RemoteOnly                   2106    This operation can be performed
  25869.                                            only on a server.
  25870.  
  25871.  NERR_ServerNotStarted             2114    The Server service is not
  25872.                                            started.
  25873.  
  25874.  Code                              Value   Meaning
  25875.  ────────────────────────────────────────────────────────────────────────────
  25876. 
  25877.  NERR_WkstaNotStarted              2138    The Workstation service is not
  25878.                                            started.
  25879.  
  25880.  NERR_BadTransactConfig            2141    The server is not configured for
  25881.                                            this transaction: IPC$ is not
  25882.                                            shared.
  25883.  
  25884.  NERR_ClientNameNotFound           2312    The specified computer does not
  25885.                                            have a session with the server.
  25886.  
  25887.  NERR_InvalidComputer              2351    The specified computername is
  25888.                                            invalid.
  25889.  
  25890.  NERR_NoSuchServer                 2460    The server ID does not specify a
  25891.                                            valid server.
  25892.  
  25893.  NERR_NoSuchSession                2461    The session ID does not specify
  25894.                                            a valid session.
  25895.  Code                              Value   Meaning
  25896.  ────────────────────────────────────────────────────────────────────────────
  25897.                                           a valid session.
  25898.  
  25899.  ────────────────────────────────────────────────────────────────────────────
  25900.  
  25901.  
  25902.  
  25903.  
  25904.  Remarks
  25905.  
  25906.  When NetSessionDel ends a session, it disconnects all connections
  25907.  established via the session and closes any files that were opened via the
  25908.  session. Data can be lost if any process on the workstation is communicating
  25909.  with the server when NetSessionDel is called.
  25910.  
  25911.  See Also
  25912.  
  25913.  For information about             See
  25914.  ────────────────────────────────────────────────────────────────────────────
  25915.  Retrieving the status of a        NetSessionGetInfo
  25916.  server session
  25917.  
  25918.  
  25919.  NetSessionEnum
  25920.  ────────────────────────────────────────────────────────────────────────────
  25921.  
  25922.  NetSessionEnum provides information about all current sessions.
  25923.  
  25924.  
  25925.  Operating Systems Supported
  25926.  
  25927.  
  25928.    ■   MS OS/2 version 1.2, local and remote
  25929.  
  25930.    ■   MS OS/2 version 1.1, remote only
  25931.  
  25932.    ■   MS-DOS, remote only
  25933.  
  25934.  
  25935.  
  25936.  Privilege Level
  25937.  
  25938.  Admin privilege or server operator privilege is required to successfully
  25939.  execute NetSessionEnum at level 1 or level 2 on a remote server or on a
  25940.  computer that has local security enabled. No special privilege is required
  25941.  for level 0 or level 10 calls.
  25942.  
  25943.  
  25944.  Syntax
  25945.  
  25946.    #define INCL_NETSESSION
  25947.    #define INCL_NETERRORS
  25948.    #include <lan.h>
  25949.  
  25950.    API_FUNCTION
  25951.    NetSessionEnum (const char far *      pszServer,
  25952.                    short                 sLevel,
  25953.                    char far *            pbBuffer,
  25954.                    unsigned short        cbBuffer,
  25955.                    unsigned short far *  pcEntriesRead,
  25956.                    unsigned short far *  pcTotalAvail
  25957.                   );
  25958.  
  25959.  where
  25960.  
  25961.  pszServer
  25962.    Points to an ASCIIZ string that specifies the name of the server on which
  25963.    to execute NetSessionEnum. A null pointer or null string specifies the
  25964.    local server.
  25965.  
  25966.  sLevel
  25967.    Specifies the level of detail (0, 1, 2, or 10) requested.
  25968.  
  25969.  pbBuffer
  25970.    Points to the buffer in which to store the returned data. On a successful
  25971.    return, the buffer contains a sequence of session_info_X data structures,
  25972.    where X is 0, 1, 2, or 10, depending on the level of detail requested.
  25973.  
  25974.  cbBuffer
  25975.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  25976.  
  25977.  pcEntriesRead
  25978.    Points to an unsigned short integer in which a count of the number of
  25979.    sessions enumerated in the buffer is returned. This count is valid only if
  25980.    NetSessionEnum returns NERR_Success or ERROR_MORE_DATA.
  25981.  
  25982.  pcTotalAvail
  25983.    Points to an unsigned short integer in which a count of the total number
  25984.    of sessions is returned. This count is valid only if NetSessionEnum
  25985.    returns NERR_Success or ERROR_MORE_DATA.
  25986.  
  25987.  Return Codes
  25988.  
  25989. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  25990.  Code                              Value   Meaning
  25991.  ────────────────────────────────────────────────────────────────────────────
  25992.  NERR_Success                      0       The function encountered no
  25993.                                            errors.
  25994.  
  25995.  ERROR_ACCESS_DENIED               5       The user has insufficient
  25996.                                            privilege for this operation.
  25997.  
  25998.  ERROR_BAD_NETPATH                 53      The network path was not found.
  25999.  
  26000.  Code                              Value   Meaning
  26001.  ────────────────────────────────────────────────────────────────────────────
  26002. 
  26003.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  26004.  
  26005.  ERROR_INVALID_LEVEL               124     The level for information
  26006.                                            retrieval or setting is invalid.
  26007.  
  26008.  ERROR_MORE_DATA                   234     Additional data is available.
  26009.  
  26010.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  26011.                                            is not installed.
  26012.  
  26013.  NERR_RemoteOnly                   2106    This operation can be performed
  26014.                                            only on a server.
  26015.  
  26016.  NERR_ServerNotStarted             2114    The Server service is not
  26017.                                            started.
  26018.  
  26019.  NERR_WkstaNotStarted              2138    The Workstation service is not
  26020.                                            started.
  26021.  Code                              Value   Meaning
  26022.  ────────────────────────────────────────────────────────────────────────────
  26023.                                           started.
  26024.  
  26025.  NERR_BadTransactConfig            2141    The server is not configured for
  26026.                                            this transaction: IPC$ is not
  26027.                                            shared.
  26028.  
  26029.  NERR_InvalidComputer              2351    The specified computername is
  26030.                                            invalid.
  26031.  
  26032.  ────────────────────────────────────────────────────────────────────────────
  26033.  
  26034.  
  26035.  
  26036.  See Also
  26037.  
  26038.  For information about             See
  26039.  ────────────────────────────────────────────────────────────────────────────
  26040.  Deleting a session                NetSessionDel
  26041.  
  26042.  Listing information about a       NetConnectionEnum
  26043.  session between a particular
  26044.  workstation and server
  26045.  
  26046.  Retrieving information about a    NetSessionGetInfo
  26047.  session between a particular
  26048.  server and workstation.
  26049.  
  26050.  
  26051.  NetSessionGetInfo
  26052.  ────────────────────────────────────────────────────────────────────────────
  26053.  
  26054.  NetSessionGetInfo retrieves information about a session established between
  26055.  a particular server and workstation.
  26056.  
  26057.  
  26058.  Operating Systems Supported
  26059.  
  26060.  
  26061.    ■   MS OS/2 version 1.2, local and remote
  26062.  
  26063.    ■   MS OS/2 version 1.1, remote only
  26064.  
  26065.    ■   MS-DOS, remote only
  26066.  
  26067.  
  26068.  
  26069.  Privilege Level
  26070.  
  26071.  Admin privilege or server operator privilege is required to successfully
  26072.  execute NetSessionGetInfo at level 1 or level 2 on a remote server or on a
  26073.  computer that has local security enabled. No special privilege is required
  26074.  for level 0 or level 10 calls.
  26075.  
  26076.  
  26077.  Syntax
  26078.  
  26079.    #define INCL_NETSESSION
  26080.    #define INCL_NETERRORS
  26081.    #include <lan.h>
  26082.  
  26083.    API_FUNCTION
  26084.    NetSessionGetInfo (const char far *      pszServer,
  26085.                       const char far *      pszClientName,
  26086.                       short                 sLevel,
  26087.                       char far *            pbBuffer,
  26088.                       unsigned short        cbBuffer,
  26089.                       unsigned short far *  pcbTotalAvail
  26090.                      );
  26091.  
  26092.  where
  26093.  
  26094.  pszServer
  26095.    Points to an ASCIIZ string that contains the name of the server on which
  26096.    to execute NetSessionGetInfo. A null pointer or null string specifies the
  26097.    local server.
  26098.  
  26099.  pszClientName
  26100.    Points to an ASCIIZ string that contains the name of the computer whose
  26101.    session is to be monitored. The name must be preceded by two backslashes
  26102.    (for example, \\client).
  26103.  
  26104.  sLevel
  26105.    Specifies the level of detail (0, 1, 2, or 10) requested.
  26106.  
  26107.  pbBuffer
  26108.    Points to the buffer in which to store the returned data. On a successful
  26109.    return, the buffer contains a session_info_X data structure, where X is 0,
  26110.    1, 2, or 10, depending on the level of detail requested.
  26111.  
  26112.  cbBuffer
  26113.    Specifies the size (in bytes) of the data buffer pointed to by pbBuffer.
  26114.  
  26115.  pcbTotalAvail
  26116.    Points to an unsigned short integer in which a count of the total number
  26117.    of bytes of information available is returned. This count is valid only if
  26118.    NetSessionGetInfo returns NERR_Success, ERROR_MORE_DATA, or
  26119.    NERR_BufTooSmall.
  26120.  
  26121.  Return Codes
  26122.  
  26123. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  26124.  Code                              Value   Meaning
  26125.  ────────────────────────────────────────────────────────────────────────────
  26126.  Code                              Value   Meaning
  26127.  ────────────────────────────────────────────────────────────────────────────
  26128.  NERR_Success                      0       The function encountered no
  26129.                                            errors.
  26130.  
  26131.  ERROR_ACCESS_DENIED               5       The user has insufficient
  26132.                                            privilege for this operation.
  26133.  
  26134.  ERROR_BAD_NETPATH                 53      The network path was not found.
  26135.  
  26136.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  26137.  
  26138.  ERROR_INVALID_LEVEL               124     The level for information
  26139.                                            retrieval or setting is invalid.
  26140.  
  26141.  ERROR_MORE_DATA                   234     Additional data is available.
  26142.  
  26143.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  26144.                                            is not installed.
  26145.  
  26146.  NERR_RemoteOnly                   2106    This operation can be performed
  26147.  Code                              Value   Meaning
  26148.  ────────────────────────────────────────────────────────────────────────────
  26149. NERR_RemoteOnly                   2106    This operation can be performed
  26150.                                            only on a server.
  26151.  
  26152.  NERR_ServerNotStarted             2114    The Server service is not
  26153.                                            started.
  26154.  
  26155.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  26156.  
  26157.  NERR_WkstaNotStarted              2138    The Workstation service is not
  26158.                                            started.
  26159.  
  26160.  NERR_BadTransactConfig            2141    The server is not configured for
  26161.                                            this transaction: IPC$ is not
  26162.                                            shared.
  26163.  
  26164.  NERR_ClientNameNotFound           2312    The specified computer does not
  26165.                                            have a session with the server.
  26166.  
  26167.  NERR_InvalidComputer              2351    The specified computername is
  26168.  Code                              Value   Meaning
  26169.  ────────────────────────────────────────────────────────────────────────────
  26170. NERR_InvalidComputer              2351    The specified computername is
  26171.                                            invalid.
  26172.  
  26173.  ────────────────────────────────────────────────────────────────────────────
  26174.  
  26175.  
  26176.  
  26177.  See Also
  26178.  
  26179.  For information about             See
  26180.  ────────────────────────────────────────────────────────────────────────────
  26181.  Deleting a session                NetSessionDel
  26182.  
  26183.  Listing all sessions redirected   NetSessionEnum
  26184.  to a resource
  26185.  
  26186.  Listing information about a       NetConnectionEnum
  26187.  session between a particular
  26188.  workstation and server
  26189.  
  26190.  
  26191.  
  26192.  
  26193.  
  26194.  Session Category Example
  26195.  
  26196.    /*
  26197.       NETSESS.C -- a sample program demonstrating NetSession API functions.
  26198.  
  26199.       This program requires that you have admin privilege or server
  26200.       operator privilege on the specified server.
  26201.  
  26202.          usage:  netsess [-s \\server] [-w \\workstation]
  26203.  
  26204.          where  \\server      = Name of the server. A servername must
  26205.    be
  26206.                                 preceded by two backslashes (\\).
  26207.                 \\workstation = Name of the client machine to check.
  26208.  
  26209.       API                   Used to...
  26210.       =================     ================================================
  26211.       NetSessionEnum        Display list of workstations connected to
  26212.    server
  26213.       NetSessionGetInfo     Check that a particular workstation is connected
  26214.       NetSessionDel         Delete a session for a particular workstation
  26215.  
  26216.       This code sample is provided for demonstration purposes only.
  26217.       Microsoft makes no warranty, either express or implied,
  26218.       as to its usability in any given situation.
  26219.    */
  26220.  
  26221.    #define     INCL_BASE
  26222.    #include    <os2.h>        // MS OS/2 base header files
  26223.  
  26224.    #define     INCL_NETERRORS
  26225.    #define     INCL_NETSESSION
  26226.    #include    <lan.h>        // LAN Manager header files
  26227.  
  26228.    #include    <stdio.h>      // C run-time header files
  26229.    #include    <stdlib.h>
  26230.    #include    <string.h>
  26231.  
  26232.    #include    "samples.h"    // Internal routine header file
  26233.  
  26234.    #define     STRINGLEN 256
  26235.    #define     NETWKSTAGETINFOSIZE 1048
  26236.  
  26237.    // Function prototypes
  26238.    void Usage  (char * pszProgram);
  26239.  
  26240.    void main(int argc, char *argv[])
  26241.    {
  26242.       char *         pszServer = "";            // Servername
  26243.       char *         pszClientName = "";        // Workstation name
  26244.       char *         pbBuffer;                  // Pointer to data buffer
  26245.       int            iCount;                    // Index counter
  26246.       unsigned short cbBuffer;                  // Size of data buffer
  26247.       unsigned short cEntriesRead;              // Count of entries read
  26248.       unsigned short cTotalAvail;               // Count of entries available
  26249.       API_RET_TYPE   uReturnCode;               // API return code
  26250.       struct session_info_2 *  pSessInfo2;      // Session info; level
  26251.    2
  26252.       struct session_info_10 * pSessInfo10;     // Session info; level
  26253.    10
  26254.  
  26255.       for (iCount = 1; iCount < argc; iCount++)
  26256.       {
  26257.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  26258.          {
  26259.             switch (tolower(*(argv[iCount]+1))) // Process switches
  26260.             {
  26261.                case 's':                        // -s servername
  26262.                   pszServer = argv[++iCount];
  26263.                   break;
  26264.                case 'w':                        // -w workstation name
  26265.                   pszClientName = argv[++iCount];
  26266.                   break;
  26267.                case 'h':
  26268.                default:
  26269.                   Usage(argv[0]);
  26270.             }
  26271.          }
  26272.          else
  26273.             Usage(argv[0]);
  26274.       }
  26275.  
  26276.    //========================================================================
  26277.    //  NetSessionEnum
  26278.    //
  26279.    //  This API lists the workstations connected to the server.
  26280.    //  Calculate the buffer size needed by determining the number
  26281.    //  of sessions and multiplying this value by the size needed
  26282.    //  to store the data for one session.
  26283.    //========================================================================
  26284.  
  26285.    // Supply a zero-length buffer and get back the number of
  26286.    sessions.
  26287.  
  26288.       uReturnCode = NetSessionEnum(pszServer,     // "" or NULL means
  26289.    local
  26290.                                   10,             // Level (0,1,2,10)
  26291.                                   NULL,           // Return buffer
  26292.                                   0,              // Size of return buffer
  26293.                                   &cEntriesRead,  // Count of entries
  26294.    read
  26295.                                   &cTotalAvail);  // Count of total available
  26296.       if (uReturnCode != NERR_Success && uReturnCode != ERROR_MORE_DATA)
  26297.          printf("NetSessionEnum returned %u\n", uReturnCode);
  26298.       else
  26299.       {
  26300.          printf("There are %hu session(s)\n", cTotalAvail);
  26301.          if (cTotalAvail != 0 )
  26302.          {
  26303.             cbBuffer = cTotalAvail * (sizeof (struct session_info_10)
  26304.    +
  26305.                             CNLEN+1+              // Space for sesi10_cname
  26306.                             CNLEN+1);             // Space for
  26307.  sesi10_username
  26308.             pbBuffer = SafeMalloc(cbBuffer);
  26309.  
  26310.             // Buffer is large enough unless new sessions have been created.
  26311.  
  26312.             uReturnCode = NetSessionEnum(pszServer, // "" or NULL means
  26313.    local
  26314.                                    10,              // Level (0,1,2,10)
  26315.                                    pbBuffer,        // Return buffer
  26316.                                    cbBuffer,        // Size of return
  26317.    buffer
  26318.                                    &cEntriesRead,   // Count of entries
  26319.    read
  26320.                                    &cTotalAvail);   // Count of total
  26321.    available
  26322.  
  26323.             // Display information returned by the Enum call.
  26324.  
  26325.             if (uReturnCode == NERR_Success || uReturnCode ==
  26326.  ERROR_MORE_DATA)
  26327.             {
  26328.                pSessInfo10 = (struct session_info_10 *) pbBuffer;
  26329.                for (iCount = 0; iCount++ < (int) cEntriesRead; pSessInfo10++)
  26330.                   printf("   \"%Fs\"\n", pSessInfo10->sesi10_cname);
  26331.             // May be NULL if uReturnCode != NERR_Success.
  26332.             }
  26333.             else
  26334.                printf("NetSessionEnum returned %u\n", uReturnCode);
  26335.  
  26336.             free(pbBuffer);
  26337.          }
  26338.       }
  26339.  
  26340.    //========================================================================
  26341.    //  NetSessionGetInfo
  26342.    //
  26343.    //  This API displays information about sessions at level 2 (maximum
  26344.  
  26345.    //  information). Call NetSessionGetInfo with a zero-length buffer
  26346.    to
  26347.    //  determine the size of buffer required, and then call it again
  26348.    with
  26349.    //  the correct buffer size.
  26350.    //========================================================================
  26351.  
  26352.    uReturnCode = NetSessionGetInfo(pszServer,  // "" or NULL
  26353.    means local
  26354.                                    pszClientName, // Client to get info
  26355.    on
  26356.                                    2,             // Level (0,1,2,10)
  26357.                                    NULL,          // Return buffer
  26358.                                    0,             // Size of return buffer
  26359.                                    &cbBuffer);    // Count of bytes available
  26360.  
  26361.       if (uReturnCode != NERR_BufTooSmall)
  26362.          printf("NetSessionGetInfo with 0 byte buffer returned %u\n",
  26363.                 uReturnCode);
  26364.       else
  26365.       {
  26366.          pbBuffer = SafeMalloc(cbBuffer);
  26367.  
  26368.          uReturnCode = NetSessionGetInfo(pszServer, // "" or NULL means
  26369.    local
  26370.                                    pszClientName,   // Client to get
  26371.    info on
  26372.                                    2,               // Level (0,1,2,10)
  26373.                                    pbBuffer,        // Return buffer
  26374.                                    cbBuffer,        // Size of return
  26375.    buffer
  26376.                                    &cTotalAvail);   // Count of bytes
  26377.    available
  26378.  
  26379.          printf("\nNetSessionGetInfo with %hu byte buffer returned %u\n\n",
  26380.                     cTotalAvail, uReturnCode);
  26381.  
  26382.    if (uReturnCode == NERR_Success )
  26383.          {
  26384.             pSessInfo2 = (struct session_info_2 *) pbBuffer;
  26385.             printf ("  Computer name :  %Fs\n", pSessInfo2->sesi2_cname);
  26386.             printf ("  User name     :  %Fs\n", pSessInfo2->sesi2_username);
  26387.             printf ("  # Connections :  %hu\n", pSessInfo2->sesi2_num_conns);
  26388.             printf ("  # Opens       :  %hu\n", pSessInfo2->sesi2_num_opens);
  26389.             printf ("  # Users       :  %hu\n", pSessInfo2->sesi2_num_users);
  26390.             printf ("  Seconds active:  %lu\n", pSessInfo2->sesi2_time);
  26391.             printf ("  Seconds idle  :  %lu\n", pSessInfo2->sesi2_idle_time);
  26392.             printf ("  User flags    :  %lu\n",
  26393.  pSessInfo2->sesi2_user_flags);
  26394.             printf ("  Client version:  %Fs\n",
  26395.  pSessInfo2->sesi2_cltype_name);
  26396.          }
  26397.          free(pbBuffer);
  26398.       }
  26399.  
  26400.    //========================================================================
  26401.    //  NetSessionDel
  26402.    //
  26403.    //  This API deletes the session with the specified workstation.
  26404.    //========================================================================
  26405.  
  26406.    uReturnCode = NetSessionDel(pszServer,      // "" or NULL
  26407.    means local
  26408.                                   pszClientName,  // Clientname
  26409.                                   0);             // Reserved; must be
  26410.    0
  26411.  
  26412.       printf("NetSessionDel returned %u\n", uReturnCode );
  26413.  
  26414.       exit(0);
  26415.    }
  26416.  
  26417.    void Usage (char * pszProgram)
  26418.    {
  26419.       fprintf(stderr, "Usage: %s [-s \\\\server] [-w \\\\workstation]\n",
  26420.                  pszProgram);
  26421.       exit(1);
  26422.    }
  26423.  
  26424.  
  26425.  
  26426.  
  26427.  
  26428.  Share Category
  26429.  
  26430.  Share API functions control shared resources. They require that the
  26431.  Workstation service be started, and that the Server service be started on
  26432.  the specified server.
  26433.  
  26434.  The Share category functions, datatypes, structures, and constants are
  26435.  defined in the NETCONS.H, NETERR.H, and SHARES.H header files. A source
  26436.  program can access these definitions by defining the constants
  26437.  INCL_NETERRORS and INCL_NETSHARE, and including the master header file,
  26438.  LAN.H. For more information, see the "Example" section, later in this
  26439.  category.
  26440.  
  26441.  These are the Share API functions:
  26442.  
  26443.  
  26444.    ■   NetShareAdd
  26445.  
  26446.    ■   NetShareCheck
  26447.  
  26448.    ■   NetShareDel
  26449.  
  26450.    ■   NetShareEnum
  26451.  
  26452.    ■   NetShareGetInfo
  26453.  
  26454.    ■   NetShareSetInfo
  26455.  
  26456.  
  26457.  
  26458.  Description
  26459.  
  26460.  A shared resource is a local resource on a server (for example, a disk
  26461.  directory, print device, or named pipe) that can be accessed by users and
  26462.  applications on the network.
  26463.  
  26464.  NetShareAdd allows a user or application to share a resource of a specific
  26465.  type using the specified sharename.
  26466.  
  26467.  On a server that has share-level security, NetShareAdd also assigns a
  26468.  password and permissions to the shared resource. A user or application can
  26469.  access the shared resource only by supplying the correct password.
  26470.  
  26471.  On a server that has user-level security, NetShareAdd requires only the
  26472.  sharename and local devicename to share the resource. A user or application
  26473.  must have an account on the server to access the resource. For information
  26474.  about accounts on servers that have user-level security, see the User
  26475.  category API functions. For information about assigning permissions in
  26476.  user-level security, see the Access Permissions category API functions.
  26477.  
  26478.  LAN Manager defines three types of special sharenames for interprocess
  26479.  communication (IPC) and remote administration of the server:
  26480.  
  26481.  
  26482.    ■   IPC$, reserved for interprocess communication
  26483.  
  26484.    ■   ADMIN$, reserved for remote administration
  26485.  
  26486.    ■   A$, B$, C$ (and other local disk names followed by a dollar sign),
  26487.        assigned to local disk devices
  26488.  
  26489.  
  26490.  
  26491.  Data Structures
  26492.  
  26493.  The Share API functions use the share_info_X data structures, where X is 0,
  26494.  1, or 2, depending on the level of detail specified by the sLevel parameter.
  26495.  
  26496.  
  26497.  NetShareEnum and NetShareGetInfo return data at levels 0, 1, and 2.
  26498.  NetShareSetInfo supports data supplied at levels 1 and 2. NetShareAdd
  26499.  supports data supplied at level 2.
  26500.  
  26501.  
  26502.  Share Information (level 0)
  26503.  
  26504.  The share_info_0 data structure has this format:
  26505.  
  26506.    struct share_info_0 {
  26507.        char shi0_netname[NNLEN+1];
  26508.    };
  26509.  
  26510.  where
  26511.  
  26512.  shi0_netname
  26513.    Contains an ASCIIZ string that specifies the sharename of a resource. The
  26514.    constant NNLEN is defined in the NETCONS.H header file.
  26515.  
  26516.  
  26517.  Share Information (level 1)
  26518.  
  26519.  The share_info_1 data structure has this format:
  26520.  
  26521.    struct share_info_1 {
  26522.        char           shi1_netname[NNLEN+1];
  26523.        char           shi1_pad1;
  26524.        unsigned short shi1_type;
  26525.        char far *     shi1_remark;
  26526.    };
  26527.  
  26528.  where
  26529.  
  26530.  shi1_netname
  26531.    Contains an ASCIIZ string that specifies the sharename of the resource.
  26532.    The constant NNLEN is defined in the NETCONS.H header file.
  26533.  
  26534.  shi1_pad1
  26535.    Aligns the next data structure element on a word boundary.
  26536.  
  26537.  shi1_type
  26538.    Contains an integer that specifies the type of shared resource. The
  26539.    SHARES.H header file defines these possible values:
  26540.  
  26541.  Code            Value  Share Type
  26542.  ────────────────────────────────────────────────────────────────────────────
  26543.  STYPE_DISKTREE  0      Disk directory tree.
  26544.  STYPE_PRINTQ    1      Printer queue.
  26545.  STYPE_DEVICE    2      Communication device.
  26546.  STYPE_IPC       3      Interprocess communication (IPC).
  26547.  ────────────────────────────────────────────────────────────────────────────
  26548.  
  26549.  shi1_remark
  26550.    Points to an ASCIIZ string that contains a comment about the shared
  26551.    resource. The remark element must be set to NULL when NetShareAdd is
  26552.    called to add the ADMIN$ or IPC$ sharenames; the remark is supplied by
  26553.    NetShareAdd.
  26554.  
  26555.  
  26556.  Share Information (level 2)
  26557.  
  26558.  The share_info_2 data structure has this format:
  26559.  
  26560.    struct share_info_2 {
  26561.        char            shi2_netname[NNLEN+1];
  26562.        char            shi2_pad1;
  26563.        unsigned short  shi2_type;
  26564.        char far *      shi2_remark;
  26565.        unsigned short  shi2_permissions;
  26566.        unsigned short  shi2_max_uses;
  26567.        unsigned short  shi2_current_uses;
  26568.        char far *      shi2_path;
  26569.        char            shi2_passwd[SHPWLEN+1];
  26570.        char            shi2_pad2;
  26571.    };
  26572.  
  26573.  where
  26574.  
  26575.  shi2_netname through shi2_remark
  26576.    Are the same as the corresponding elements of the share_info_1 data
  26577.    structure. For a complete description, see the preceding section.
  26578.  
  26579.  shi2_permissions
  26580.    Specifies the permissions for the shared resource on a server that has
  26581.    share-level security. This element is ignored on servers with user-level
  26582.    security. For servers that have share-level security, the ACCESS.H header
  26583.    file defines the bit mask for shi2_permissions:
  26584.  
  26585. ╓┌──────────────┌─────────┌──────────────────────────────────────────────────╖
  26586.  Code           Bit Mask  Meaning
  26587.  ────────────────────────────────────────────────────────────────────────────
  26588.  Code           Bit Mask  Meaning
  26589.  ────────────────────────────────────────────────────────────────────────────
  26590.  ACCESS_READ    0x01      Permission to read data from a resource and, by
  26591.                           default, to execute the resource.
  26592.  
  26593.  ACCESS_WRITE   0x02      Permission to write data to the resource.
  26594.  
  26595.  ACCESS_CREATE  0x04      Permission to create an instance of the resource
  26596.                           (such as a file); data can be written to the
  26597.                           resource as the resource is created.
  26598.  
  26599.  ACCESS_EXEC    0x08      Permission to execute the resource.
  26600.  
  26601.  ACCESS_DELETE  0x10      Permission to delete the resource.
  26602.  
  26603.  ACCESS_ATRIB   0x20      Permission to modify the resource's attributes
  26604.                           (such as the date and time when a file was last
  26605.                           modified).
  26606.  
  26607.  ACCESS_PERM    0x40      Permission to modify the permissions (read, write,
  26608.                           create, execute, and delete) assigned to a
  26609.  Code           Bit Mask  Meaning
  26610.  ────────────────────────────────────────────────────────────────────────────
  26611.                          create, execute, and delete) assigned to a
  26612.                           resource for a user or application.
  26613.  
  26614.  ACCESS_ALL     0x7F      Permission to read, write, create, execute, and
  26615.                           delete data from a resource, and to modify
  26616.                           attributes and permissions.
  26617.  
  26618.  ────────────────────────────────────────────────────────────────────────────
  26619.  
  26620.  
  26621.  
  26622.  shi2_max_uses
  26623.    Specifies the maximum number of concurrent connections that the shared
  26624.    resource can accommodate. If shi2_max_uses is -1, the connections are
  26625.    unlimited.
  26626.  
  26627.  shi2_current_uses
  26628.    Specifies the number of connections to the resource.
  26629.  
  26630.  shi2_path
  26631.    Points to an ASCIIZ string that contains the local pathname of the shared
  26632.    resource. For disks, shi2_path is the path being shared. For printer
  26633.    queues, shi2_path is the name of the printer queue being shared. For
  26634.    communication-device queues, shi2_path is a string of one or more
  26635.    communication-device names. In this case, the devicenames are separated by
  26636.    spaces (for example, COM1 COM2 COM6). For ADMIN$ or IPC$ resources,
  26637.    shi2_path must be a null pointer.
  26638.  
  26639.  shi2_passwd
  26640.    Specifies the sharename's password for a server that has share-level
  26641.    security. For a server that has user-level security, shi2_passwd is NULL
  26642.    and is ignored. The constant SHPWLEN is defined in the NETCONS.H header
  26643.    file.
  26644.  
  26645.  shi2_pad2
  26646.    Aligns the next data structure element on a word boundary.
  26647.  
  26648.  See Also
  26649.  
  26650.  For information about             See
  26651.  ────────────────────────────────────────────────────────────────────────────
  26652.  ADMIN$ and IPC$ resources         Chapter 1, "Overview of the LAN Manager
  26653.                                    API"
  26654.  
  26655.  User accounts                     User Category
  26656.  
  26657.  
  26658.  NetShareAdd
  26659.  ────────────────────────────────────────────────────────────────────────────
  26660.  
  26661.  NetShareAdd shares a server resource.
  26662.  
  26663.  
  26664.  Operating Systems Supported
  26665.  
  26666.  
  26667.    ■   MS OS/2 version 1.2, local and remote
  26668.  
  26669.    ■   MS OS/2 version 1.1, remote only
  26670.  
  26671.    ■   MS-DOS, remote only
  26672.  
  26673.  
  26674.  
  26675.  Privilege Level
  26676.  
  26677.  Admin privilege or comm, print, or server operator privilege is required to
  26678.  successfully execute NetShareAdd on a remote server or on a computer that
  26679.  has local security enabled. The print operator can add only printer queues.
  26680.  The comm operator can add only communication-device queues.
  26681.  
  26682.  
  26683.  Syntax
  26684.  
  26685.    #define INCL_NETSHARE
  26686.    #define INCL_NETERRORS
  26687.    #include <lan.h>
  26688.  
  26689.    API_FUNCTION
  26690.    NetShareAdd (const char far *  pszServer,
  26691.                 short             sLevel,
  26692.                 const char far *  pbBuffer,
  26693.                 unsigned short    cbBuffer
  26694.                );
  26695.  
  26696.  where
  26697.  
  26698.  pszServer
  26699.    Points to an ASCIIZ string that contains the name of the server on which
  26700.    to execute NetShareAdd. A null pointer or null string specifies the local
  26701.    computer.
  26702.  
  26703.  sLevel
  26704.    Specifies the level of detail provided; must be 2.
  26705.  
  26706.  pbBuffer
  26707.    Points to the buffer that contains the share_info_2 data structure
  26708.    provided.
  26709.  
  26710.  cbBuffer
  26711.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  26712.  
  26713.  Return Codes
  26714.  
  26715. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  26716.  Code                              Value   Meaning
  26717.  ────────────────────────────────────────────────────────────────────────────
  26718.  NERR_Success                      0       The function encountered no
  26719.                                            errors.
  26720.  
  26721.  ERROR_ACCESS_DENIED               5       The user has insufficient
  26722.                                            privilege for this operation.
  26723.  
  26724.  ERROR_NOT_SUPPORTED               50      This network request is not
  26725.                                            supported.
  26726.  
  26727.  ERROR_BAD_NETPATH                 53      The network path was not found.
  26728.  
  26729.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  26730.  
  26731.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  26732.                                            invalid.
  26733.  
  26734.  ERROR_INVALID_NAME                123     The character or file system
  26735.  Code                              Value   Meaning
  26736.  ────────────────────────────────────────────────────────────────────────────
  26737. ERROR_INVALID_NAME                123     The character or file system
  26738.                                            name is invalid.
  26739.  
  26740.  ERROR_INVALID_LEVEL               124     The level for information
  26741.                                            retrieval or setting is invalid.
  26742.  
  26743.  ERROR_FILENAME_EXCED_RANGE        206     The filename specified is
  26744.                                            invalid for the file system.
  26745.                                            This code is returned when
  26746.                                            checking a FAT disk partition
  26747.                                            only. It cannot be returned for
  26748.                                            an HPFS partition.
  26749.  
  26750.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  26751.                                            is not installed.
  26752.  
  26753.  NERR_UnknownServer                2103    The server was not found.
  26754.  
  26755.  NERR_ServerNotStarted             2114    The Server service is not
  26756.  Code                              Value   Meaning
  26757.  ────────────────────────────────────────────────────────────────────────────
  26758. NERR_ServerNotStarted             2114    The Server service is not
  26759.                                            started.
  26760.  
  26761.  NERR_UnknownDevDir                2116    The device or directory does not
  26762.                                            exist.
  26763.  
  26764.  NERR_RedirectedPath               2117    The operation is invalid for a
  26765.                                            redirected resource. The
  26766.                                            devicename specified is assigned
  26767.                                            to a shared resource.
  26768.  
  26769.  NERR_DuplicateShare               2118    The sharename is already in use
  26770.                                            on this server.
  26771.  
  26772.  NERR_NoRoom                       2119    The server could not access
  26773.                                            enough of a resource, such as
  26774.                                            memory, to complete the task.
  26775.  
  26776.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  26777.  Code                              Value   Meaning
  26778.  ────────────────────────────────────────────────────────────────────────────
  26779. NERR_BufTooSmall                  2123    The supplied buffer is too small.
  26780.  
  26781.  NERR_WkstaNotStarted              2138    The Workstation service is not
  26782.                                            started.
  26783.  
  26784.  NERR_BadTransactConfig            2141    The server is not configured for
  26785.                                            this transaction: IPC$ is not
  26786.                                            shared.
  26787.  
  26788.  NERR_QNotFound                    2150    The queuename specified is
  26789.                                            invalid.
  26790.  
  26791.  NERR_DeviceShareConflict          2318    Requests cannot be routed from
  26792.                                            both a printer queue and a
  26793.                                            communication-device queue to
  26794.                                            the same device.
  26795.  
  26796.  NERR_BadDevString                 2340    The list of devices is invalid.
  26797.  
  26798.  Code                              Value   Meaning
  26799.  ────────────────────────────────────────────────────────────────────────────
  26800. 
  26801.  NERR_BadDev                       2341    The devicename is invalid
  26802.                                            because it does not represent a
  26803.                                            physical device, or because the
  26804.                                            device hardware is faulty.
  26805.  
  26806.  NERR_InvalidComputer              2351    The specified computername is
  26807.                                            invalid.
  26808.  
  26809.  ────────────────────────────────────────────────────────────────────────────
  26810.  
  26811.  
  26812.  
  26813.  
  26814.  Remarks
  26815.  
  26816.  NetShareAdd requires a level 2 data structure (share_info_2). Depending on
  26817.  the type of shared resource specified by the shi2_type element of the
  26818.  share_info_2 data structure, you can specify other elements in the data
  26819.  structure, as follows:
  26820.  
  26821.  Code            Value  Element Requirements
  26822.  ────────────────────────────────────────────────────────────────────────────
  26823.  STYPE_DISKTREE  0      The shi2_path element must specify a file system
  26824.                         pathname, or it must be NULL for ADMIN$.
  26825.  
  26826.  STYPE_PRINTQ    1      The shi2_netname element must specify the name of
  26827.                         an existing printer queue.
  26828.  
  26829.  STYPE_DEVICE    2      The shi2_path element must be passed as a null
  26830.                         pointer, or it must point to a list of
  26831.                         communication devices (the devicenames must be
  26832.                         separated by spaces).
  26833.  
  26834.  STYPE_IPC       3      The shi2_netname element must specify an IPC$
  26835.                         resource, and shi2_path must point to a null string.
  26836.  
  26837.  ────────────────────────────────────────────────────────────────────────────
  26838.  
  26839.  
  26840.  NetShareAdd ignores the value specified in the shi2_current_uses element of
  26841.  share_info_2.
  26842.  
  26843.  If there is a conflict between the server_info_X element svX_numadmin and
  26844.  the share_info_2 element shi2_max_uses for the sharename ADMIN$, LAN Manager
  26845.  gives priority to the shi2_max_uses value. For more information, see your
  26846.  LAN Manager administrator's manual(s).
  26847.  
  26848.  See Also
  26849.  
  26850.  For information about             See
  26851.  ────────────────────────────────────────────────────────────────────────────
  26852.  Listing the resources that can    NetShareEnum
  26853.  be shared on a server
  26854.  
  26855.  Remote calls                      Chapter 1, "Overview of the LAN Manager
  26856.                                    API"
  26857.  
  26858.  Removing a list of resources      NetShareDel
  26859.  that can be shared
  26860.  
  26861.  
  26862.  NetShareCheck
  26863.  ────────────────────────────────────────────────────────────────────────────
  26864.  
  26865.  NetShareCheck checks whether or not a server is sharing a device.
  26866.  
  26867.  
  26868.  Operating Systems Supported
  26869.  
  26870.  
  26871.    ■   MS OS/2 version 1.2, local and remote
  26872.  
  26873.    ■   MS OS/2 version 1.1, remote only
  26874.  
  26875.    ■   MS-DOS, remote only
  26876.  
  26877.  
  26878.  
  26879.  Privilege Level
  26880.  
  26881.  No special privilege level is required to successfully execute
  26882.  NetShareCheck.
  26883.  
  26884.  
  26885.  Syntax
  26886.  
  26887.    #define INCL_NETSHARE
  26888.    #define INCL_NETERRORS
  26889.    #include <lan.h>
  26890.  
  26891.    API_FUNCTION
  26892.    NetShareCheck (const char far *      pszServer,
  26893.                   const char far *      pszDeviceName,
  26894.                   unsigned short far *  pusType
  26895.                  );
  26896.  
  26897.  where
  26898.  
  26899.  pszServer
  26900.    Points to an ASCIIZ string that contains the name of the server on which
  26901.    to execute NetShareCheck. A null pointer or null string specifies the
  26902.    local computer.
  26903.  
  26904.  pszDeviceName
  26905.    Points to an ASCIIZ string that contains the name of the character device,
  26906.    print destination, or disk to check.
  26907.  
  26908.  pusType
  26909.    Points to an unsigned short integer that contains the returned data. The
  26910.    returned value specifies the type of the shared device specified by
  26911.    pszDeviceName. The SHARES.H header file defines these possible values:
  26912.  
  26913.  Code            Value  Meaning
  26914.  ────────────────────────────────────────────────────────────────────────────
  26915.  STYPE_DISKTREE  0      Disk directory tree.
  26916.  STYPE_PRINTQ    1      Printer queue.
  26917.  STYPE_DEVICE    2      Communication device.
  26918.  ────────────────────────────────────────────────────────────────────────────
  26919.  
  26920.  Return Codes
  26921.  
  26922. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  26923.  Code                              Value   Meaning
  26924.  Code                              Value   Meaning
  26925.  ────────────────────────────────────────────────────────────────────────────
  26926.  NERR_Success                      0       The function encountered no
  26927.                                            errors.
  26928.  
  26929.  ERROR_BAD_NETPATH                 53      The network path was not found.
  26930.  
  26931.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  26932.  
  26933.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  26934.                                            invalid.
  26935.  
  26936.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  26937.                                            is not installed.
  26938.  
  26939.  NERR_RemoteOnly                   2106    This operation can be performed
  26940.                                            only on a server.
  26941.  
  26942.  NERR_ServerNotStarted             2114    The Server service is not
  26943.                                            started.
  26944.  
  26945.  Code                              Value   Meaning
  26946.  ────────────────────────────────────────────────────────────────────────────
  26947. 
  26948.  NERR_WkstaNotStarted              2138    The Workstation service is not
  26949.                                            started.
  26950.  
  26951.  NERR_BadTransactConfig            2141    The server is not configured for
  26952.                                            this transaction: IPC$ is not
  26953.                                            shared.
  26954.  
  26955.  NERR_NetNameNotFound              2310    The sharename does not exist.
  26956.  
  26957.  NERR_DeviceNotShared              2311    The device is not shared.
  26958.  
  26959.  NERR_InvalidComputer              2351    The specified computername is
  26960.                                            invalid.
  26961.  
  26962.  ────────────────────────────────────────────────────────────────────────────
  26963.  
  26964.  
  26965.  
  26966.  
  26967.  Remarks
  26968.  
  26969.  The returned pusType value is valid only if NetShareCheck returns
  26970.  NERR_Success. If the device is not shared, NERR_DeviceNotShared is returned.
  26971.  
  26972.  
  26973.  NetShareCheck returns successfully if a specified device is in the routing
  26974.  list of a printer queue or a communication-device queue.
  26975.  
  26976.  See Also
  26977.  
  26978.  For information about             See
  26979.  ────────────────────────────────────────────────────────────────────────────
  26980.  Reconfiguring a server resource   NetShareSetInfo
  26981.  that can be shared
  26982.  
  26983.  Retrieving the status of a        NetShareGetInfo
  26984.  shared resource
  26985.  
  26986.  
  26987.  NetShareDel
  26988.  ────────────────────────────────────────────────────────────────────────────
  26989.  
  26990.  NetShareDel deletes a sharename from a server's list of shared resources,
  26991.  disconnecting all connections to the shared resource.
  26992.  
  26993.  
  26994.  Operating Systems Supported
  26995.  
  26996.  
  26997.    ■   MS OS/2 version 1.2, local and remote
  26998.  
  26999.    ■   MS OS/2 version 1.1, remote only
  27000.  
  27001.    ■   MS-DOS, remote only
  27002.  
  27003.  
  27004.  
  27005.  Privilege Level
  27006.  
  27007.  Admin privilege or comm, print, or server operator privilege is required to
  27008.  successfully execute NetShareDel on a remote server or on a computer that
  27009.  has local security enabled. The print operator can delete only printer
  27010.  queues. The comm operator can delete only communication-device queues.
  27011.  
  27012.  
  27013.  Syntax
  27014.  
  27015.    #define INCL_NETSHARE
  27016.    #define INCL_NETERRORS
  27017.    #include <lan.h>
  27018.  
  27019.    API_FUNCTION
  27020.    NetShareDel (const char far *  pszServer,
  27021.                 const char far *  pszNetName,
  27022.                 unsigned short    usReserved
  27023.                );
  27024.  
  27025.  where
  27026.  
  27027.  pszServer
  27028.    Points to an ASCIIZ string that contains the name of the server on which
  27029.    to execute NetShareDel. A null pointer or null string specifies the local
  27030.    computer.
  27031.  
  27032.  pszNetName
  27033.    Points to an ASCIIZ string that contains the sharename to be deleted.
  27034.  
  27035.  usReserved
  27036.    Reserved; must be 0.
  27037.  
  27038.  Return Codes
  27039.  
  27040. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  27041.  Code                              Value   Meaning
  27042.  ────────────────────────────────────────────────────────────────────────────
  27043.  NERR_Success                      0       The function encountered no
  27044.                                            errors.
  27045.  
  27046.  ERROR_ACCESS_DENIED               5       The user has insufficient
  27047.                                            privilege for this operation.
  27048.  
  27049.  ERROR_BAD_NETPATH                 53      The network path was not found.
  27050.  Code                              Value   Meaning
  27051.  ────────────────────────────────────────────────────────────────────────────
  27052. ERROR_BAD_NETPATH                 53      The network path was not found.
  27053.  
  27054.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  27055.  
  27056.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  27057.                                            is not installed.
  27058.  
  27059.  NERR_ServerNotStarted             2114    The Server service is not
  27060.                                            started.
  27061.  
  27062.  NERR_BadTransactConfig            2141    The server is not configured for
  27063.                                            this transaction: IPC$ is not
  27064.                                            shared.
  27065.  
  27066.  NERR_NetNameNotFound              2310    The sharename does not exist.
  27067.  
  27068.  NERR_InvalidComputer              2351    The specified computername is
  27069.                                            invalid.
  27070.  
  27071.  Code                              Value   Meaning
  27072.  ────────────────────────────────────────────────────────────────────────────
  27073. 
  27074.  ────────────────────────────────────────────────────────────────────────────
  27075.  
  27076.  
  27077.  
  27078.  See Also
  27079.  
  27080.  For information about             See
  27081.  ────────────────────────────────────────────────────────────────────────────
  27082.  Adding a share on a server        NetShareAdd
  27083.  
  27084.  Listing all connections to a      NetConnectionEnum
  27085.  shared resource
  27086.  
  27087.  Listing the resources on a        NetShareEnum
  27088.  server that can be shared
  27089.  
  27090.  
  27091.  NetShareEnum
  27092.  ────────────────────────────────────────────────────────────────────────────
  27093.  
  27094.  NetShareEnum retrieves information about each shared resource on a server.
  27095.  
  27096.  
  27097.  Operating Systems Supported
  27098.  
  27099.  
  27100.    ■   MS OS/2 version 1.2, local and remote
  27101.  
  27102.    ■   MS OS/2 version 1.1, remote only
  27103.  
  27104.    ■   MS-DOS, remote only
  27105.  
  27106.  
  27107.  
  27108.  Privilege Level
  27109.  
  27110.  Admin privilege or comm, print, or server operator privilege is required to
  27111.  successfully execute NetShareEnum at level 2 on a remote server or on a
  27112.  computer that has local security enabled. No special privilege is required
  27113.  for level 0 or level 1 calls.
  27114.  
  27115.  
  27116.  Syntax
  27117.  
  27118.    #define INCL_NETSHARE
  27119.    #define INCL_NETERRORS
  27120.    #include <lan.h>
  27121.  
  27122.    API_FUNCTION
  27123.    NetShareEnum (const char far *      pszServer,
  27124.                  short                 sLevel,
  27125.                  char far *            pbBuffer,
  27126.                  unsigned short        cbBuffer,
  27127.                  unsigned short far *  pcEntriesRead,
  27128.                  unsigned short far *  pcTotalAvail
  27129.                 );
  27130.  
  27131.  where
  27132.  
  27133.  pszServer
  27134.    Points to an ASCIIZ string that contains the name of the server on which
  27135.    to execute NetShareEnum. A null pointer or null string specifies the local
  27136.    server.
  27137.  
  27138.  sLevel
  27139.    Specifies the level of detail (0, 1, or 2) returned.
  27140.  
  27141.  pbBuffer
  27142.    Points to the buffer in which to store the return data. On a successful
  27143.    return, the buffer contains a sequence of share_info_X data structures,
  27144.    where X is 0, 1, or 2, depending on the level of detail specified.
  27145.  
  27146.  cbBuffer
  27147.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  27148.  
  27149.  pcEntriesRead
  27150.    Points to an unsigned short integer in which a count of the number of
  27151.    shared resources enumerated in the buffer is returned. This count is valid
  27152.    only if NetShareEnum returns NERR_Success or ERROR_MORE_DATA.
  27153.  
  27154.  pcTotalAvail
  27155.    Points to an unsigned short integer in which a count of the total number
  27156.    of shared resources is returned. This count is valid only if NetShareEnum
  27157.    returns NERR_Success or ERROR_MORE_DATA.
  27158.  
  27159.  Return Codes
  27160.  
  27161. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  27162.  Code                              Value   Meaning
  27163.  ────────────────────────────────────────────────────────────────────────────
  27164.  NERR_Success                      0       The function encountered no
  27165.                                            errors.
  27166.  
  27167.  ERROR_ACCESS_DENIED               5       The user has insufficient
  27168.                                            privilege for this operation.
  27169.  
  27170.  ERROR_BAD_NETPATH                 53      The network path was not found.
  27171.  
  27172.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  27173.  
  27174.  ERROR_INVALID_LEVEL               124     The level for information
  27175.                                            retrieval or setting is invalid.
  27176.  Code                              Value   Meaning
  27177.  ────────────────────────────────────────────────────────────────────────────
  27178.                                           retrieval or setting is invalid.
  27179.  
  27180.  ERROR_MORE_DATA                   234     Additional data is available.
  27181.  
  27182.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  27183.                                            is not installed.
  27184.  
  27185.  NERR_RemoteOnly                   2106    This operation can be performed
  27186.                                            only on a server.
  27187.  
  27188.  NERR_ServerNotStarted             2114    The Server service is not
  27189.                                            started.
  27190.  
  27191.  NERR_WkstaNotStarted              2138    The Workstation service is not
  27192.                                            started.
  27193.  
  27194.  NERR_BadTransactConfig            2141    The server is not configured for
  27195.                                            this transaction: IPC$ is not
  27196.                                            shared.
  27197.  Code                              Value   Meaning
  27198.  ────────────────────────────────────────────────────────────────────────────
  27199.                                           shared.
  27200.  
  27201.  NERR_InvalidComputer              2351    The specified computername is
  27202.                                            invalid.
  27203.  
  27204.  ────────────────────────────────────────────────────────────────────────────
  27205.  
  27206.  
  27207.  
  27208.  See Also
  27209.  
  27210.  For information about             See
  27211.  ────────────────────────────────────────────────────────────────────────────
  27212.  Retrieving information about a    NetShareGetInfo
  27213.  particular shared resource
  27214.  
  27215.  
  27216.  NetShareGetInfo
  27217.  ────────────────────────────────────────────────────────────────────────────
  27218.  
  27219.  NetShareGetInfo retrieves information about a particular shared resource on
  27220.  a server.
  27221.  
  27222.  
  27223.  Operating Systems Supported
  27224.  
  27225.  
  27226.    ■   MS OS/2 version 1.2, local and remote
  27227.  
  27228.    ■   MS OS/2 version 1.1, remote only
  27229.  
  27230.    ■   MS-DOS, remote only
  27231.  
  27232.  
  27233.  
  27234.  Privilege Level
  27235.  
  27236.  Admin privilege or comm, print, or server operator privilege is required to
  27237.  successfully execute NetShareGetInfo at level 2 on a remote server or on a
  27238.  computer that has local security enabled. No special privilege is required
  27239.  for level 0 or level 1 calls.
  27240.  
  27241.  
  27242.  Syntax
  27243.  
  27244.    #define INCL_NETSHARE
  27245.    #define INCL_NETERRORS
  27246.    #include <lan.h>
  27247.  
  27248.    API_FUNCTION
  27249.    NetShareGetInfo (const char far *      pszServer,
  27250.                     const char far *      pszNetName,
  27251.                     short                 sLevel,
  27252.                     char far *            pbBuffer,
  27253.                     unsigned short        cbBuffer,
  27254.                     unsigned short far *  pcbTotalAvail
  27255.                    );
  27256.  
  27257.  where
  27258.  
  27259.  pszServer
  27260.    Points to an ASCIIZ string that contains the name of the server on which
  27261.    to execute NetShareGetInfo. A null pointer or null string specifies the
  27262.    local computer.
  27263.  
  27264.  pszNetName
  27265.    Points to an ASCIIZ string that contains the name of the shared resource.
  27266.  
  27267.  sLevel
  27268.    Specifies the level of detail (0, 1, or 2) requested.
  27269.  
  27270.  pbBuffer
  27271.    Points to the buffer in which to store the returned data. On a successful
  27272.    return, the buffer contains a share_info_X data structure, where X is 0,
  27273.    1, or 2, depending on the level of detail requested.
  27274.  
  27275.  cbBuffer
  27276.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  27277.  
  27278.  pcbTotalAvail
  27279.    Points to an unsigned short integer in which a count of the total number
  27280.    of bytes of information available is returned. This count is valid only if
  27281.    NetShareGetInfo returns NERR_Success, ERROR_MORE_DATA, or
  27282.    NERR_BufTooSmall.
  27283.  
  27284.  Return Codes
  27285.  
  27286. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  27287.  Code                              Value   Meaning
  27288.  ────────────────────────────────────────────────────────────────────────────
  27289.  NERR_Success                      0       The function encountered no
  27290.                                            errors.
  27291.  
  27292.  ERROR_ACCESS_DENIED               5       The user has insufficient
  27293.                                            privilege for this operation.
  27294.  
  27295.  ERROR_BAD_NETPATH                 53      The network path was not found.
  27296.  
  27297.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  27298.  
  27299.  ERROR_INVALID_LEVEL               124     The level for information
  27300.                                            retrieval or setting is invalid.
  27301.  
  27302.  Code                              Value   Meaning
  27303.  ────────────────────────────────────────────────────────────────────────────
  27304. 
  27305.  ERROR_MORE_DATA                   234     Additional data is available.
  27306.  
  27307.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  27308.                                            is not installed.
  27309.  
  27310.  NERR_RemoteOnly                   2106    This operation can be performed
  27311.                                            only on a server.
  27312.  
  27313.  NERR_ServerNotStarted             2114    The Server service is not
  27314.                                            started.
  27315.  
  27316.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  27317.  
  27318.  NERR_WkstaNotStarted              2138    The Workstation service is not
  27319.                                            started.
  27320.  
  27321.  NERR_BadTransactConfig            2141    The server is not configured for
  27322.                                            this transaction: IPC$ is not
  27323.  Code                              Value   Meaning
  27324.  ────────────────────────────────────────────────────────────────────────────
  27325.                                           this transaction: IPC$ is not
  27326.                                            shared.
  27327.  
  27328.  NERR_NetNameNotFound              2310    The sharename does not exist.
  27329.  
  27330.  NERR_InvalidComputer              2351    The specified computername is
  27331.                                            invalid.
  27332.  
  27333.  ────────────────────────────────────────────────────────────────────────────
  27334.  
  27335.  
  27336.  
  27337.  See Also
  27338.  
  27339.  For information about             See
  27340.  ────────────────────────────────────────────────────────────────────────────
  27341.  Reconfiguring a shareable server  NetShareSetInfo
  27342.  resource
  27343.  
  27344.  
  27345.  NetShareSetInfo
  27346.  ────────────────────────────────────────────────────────────────────────────
  27347.  
  27348.  NetShareSetInfo sets the parameters of a shared resource.
  27349.  
  27350.  
  27351.  Operating Systems Supported
  27352.  
  27353.  
  27354.    ■   MS OS/2 version 1.2, local and remote
  27355.  
  27356.    ■   MS OS/2 version 1.1, remote only
  27357.  
  27358.    ■   MS-DOS, remote only
  27359.  
  27360.  
  27361.  
  27362.  Privilege Level
  27363.  
  27364.  Admin privilege or comm, print, or server operator privilege is required to
  27365.  successfully execute NetShareSetInfo on a remote server or on a computer
  27366.  that has local security enabled. The print operator can set information only
  27367.  about printer queues. The comm operator can set information only about
  27368.  communication-device queues.
  27369.  
  27370.  
  27371.  Syntax
  27372.  
  27373.    #define INCL_NETSHARE
  27374.    #define INCL_NETERRORS
  27375.    #include <lan.h>
  27376.  
  27377.    API_FUNCTION
  27378.    NetShareSetInfo (const char far *  pszServer,
  27379.                     const char far *  pszNetName,
  27380.                     short             sLevel,
  27381.                     const char far *  pbBuffer,
  27382.                     unsigned short    cbBuffer,
  27383.                     short             sParmNum
  27384.                    );
  27385.  
  27386.  where
  27387.  
  27388.  pszServer
  27389.    Points to an ASCIIZ string that contains the name of the server on which
  27390.    to execute NetShareSetInfo. A null pointer or null string specifies the
  27391.    local computer.
  27392.  
  27393.  pszNetName
  27394.    Points to an ASCIIZ string that contains the sharename of the resource to
  27395.    be set.
  27396.  
  27397.  sLevel
  27398.    Specifies the level of detail (1 or 2) provided.
  27399.  
  27400.  pbBuffer
  27401.    Points to the data to be set.
  27402.  
  27403.  cbBuffer
  27404.    Specifies the size (in bytes) of the buffer pointed to by pbBuffer.
  27405.  
  27406.  sParmNum
  27407.    Specifies whether to set all share information or to change only a part of
  27408.    it. If sParmNum is PARMNUM_ALL, pbBuffer must point to a share_info_X data
  27409.    structure, where X is 1 or 2, depending on the level of detail provided.
  27410.    If sParmNum is any other defined value, only one element of the share
  27411.    information is changed, and pbBuffer must point to a valid value for that
  27412.    element.
  27413.  
  27414.    Not all fields can be set. Only those fields that have a specific PARMNUM
  27415.    constant value defined can be set. The SHARES.H header files define these
  27416.    possible values for sParmNum and the associated elements that must be
  27417.    supplied in the data buffer:
  27418.  
  27419. ╓┌────────────────────────┌──────┌───────────────────────────────────────────╖
  27420.  Code                     Value  Element of share_info_X
  27421.  ────────────────────────────────────────────────────────────────────────────
  27422.  PARMNUM_ALL              0      All elements.
  27423.  SHI_REMARK_PARMNUM       4      shiX_remark
  27424.  SHI_PERMISSIONS_PARMNUM  5      shi2_permissions
  27425.  SHI_MAX_USES_PARMNUM     6      shi2_max_uses
  27426.  SHI_PASSWD_PARMNUM       9      shi2_passwd
  27427.  ────────────────────────────────────────────────────────────────────────────
  27428.  Code                     Value  Element of share_info_X
  27429.  ────────────────────────────────────────────────────────────────────────────
  27430. ────────────────────────────────────────────────────────────────────────────
  27431.  
  27432.  
  27433.  Return Codes
  27434.  
  27435. ╓┌─────────────────────────────────┌───────┌─────────────────────────────────╖
  27436.  Code                              Value   Meaning
  27437.  ────────────────────────────────────────────────────────────────────────────
  27438.  NERR_Success                      0       The function encountered no
  27439.                                            errors.
  27440.  
  27441.  ERROR_ACCESS_DENIED               5       The user has insufficient
  27442.                                            privilege for this operation.
  27443.  
  27444.  ERROR_BAD_NETPATH                 53      The network path was not found.
  27445.  
  27446.  ERROR_NETWORK_ACCESS_DENIED       65      Network access is denied.
  27447.  
  27448.  ERROR_INVALID_PARAMETER           87      The parameter specified is
  27449.  Code                              Value   Meaning
  27450.  ────────────────────────────────────────────────────────────────────────────
  27451. ERROR_INVALID_PARAMETER           87      The parameter specified is
  27452.                                            invalid.
  27453.  
  27454.  ERROR_INVALID_NAME                123     The character or file system
  27455.                                            name is invalid.
  27456.  
  27457.  ERROR_INVALID_LEVEL               124     The level for information
  27458.                                            retrieval or setting is invalid.
  27459.  
  27460.  NERR_NetNotStarted                2102    The LAN Manager NETWKSTA driver
  27461.                                            is not installed.
  27462.  
  27463.  NERR_RemoteOnly                   2106    This operation can be performed
  27464.                                            only on a server.
  27465.  
  27466.  NERR_ServerNotStarted             2114    The Server service is not
  27467.                                            started.
  27468.  
  27469.  NERR_BufTooSmall                  2123    The supplied buffer is too small.
  27470.  Code                              Value   Meaning
  27471.  ────────────────────────────────────────────────────────────────────────────
  27472. NERR_BufTooSmall                  2123    The supplied buffer is too small.
  27473.  
  27474.  NERR_WkstaNotStarted              2138    The Workstation service is not
  27475.                                            started.
  27476.  
  27477.  NERR_BadTransactConfig            2141    The server is not configured for
  27478.                                            this transaction: IPC$ is not
  27479.                                            shared.
  27480.  
  27481.  NERR_NetNameNotFound              2310    The sharename does not exist.
  27482.  
  27483.  NERR_InvalidComputer              2351    The specified computername is
  27484.                                            invalid.
  27485.  
  27486.  ────────────────────────────────────────────────────────────────────────────
  27487.  
  27488.  
  27489.  
  27490.  
  27491.  Remarks
  27492.  
  27493.  If there is a conflict between the server_info_X element svX_numadmin and
  27494.  the share_info_2 element shi2_max_uses for the sharename ADMIN$, LAN Manager
  27495.  gives priority to the shi2_max_uses value. For more information, see your
  27496.  LAN Manager administrator's manual(s).
  27497.  
  27498.  See Also
  27499.  
  27500.  For information about             See
  27501.  ────────────────────────────────────────────────────────────────────────────
  27502.  Retrieving the status of a        NetShareGetInfo
  27503.  server resource that can be
  27504.  shared
  27505.  
  27506.  
  27507.  
  27508.  
  27509.  
  27510.  Share Category Example
  27511.  
  27512.    /*
  27513.       NETSHARE.C -- a sample program demonstrating NetShare API functions.
  27514.  
  27515.       This program requires that you have admin privilege or server
  27516.       operator privilege on the specified server.
  27517.  
  27518.          usage:  netshare [-s \\server] [-r sharename] [-p path]
  27519.                           [-d devicename] [-l level] [-t type] [-c comment]
  27520.          where  \\server   = Name of the server. A servername must be
  27521.                              preceded by two backslashes (\\).
  27522.                 sharename  = Name of the shared resource.
  27523.                 path       = Share path for directory tree shares.
  27524.                 devicename = Name of the device, such as LPT1, COM1,
  27525.    or C:
  27526.                 level      = Level of detail; 0, 1, or 2.
  27527.                 type       = Type of share; Directory=0, Printer Queue=1,
  27528.                                 Comm device=2, IPC=3.
  27529.                 comment    = Remark to be added to the share.
  27530.  
  27531.       API                 Used to...
  27532.       ===============     =================================================
  27533.       NetShareAdd         Add a shared resource
  27534.       NetShareGetInfo     Get the details of the shared resource just
  27535.    added
  27536.       NetShareSetInfo     Change the maximum users of the share
  27537.       NetShareDel         Delete the above share
  27538.       NetShareCheck       Check to see if the device has been shared
  27539.       NetShareEnum        Display the list of current shares
  27540.  
  27541.       This code sample is provided for demonstration purposes only.
  27542.       Microsoft makes no warranty, either express or implied,
  27543.       as to its usability in any given situation.
  27544.    */
  27545.  
  27546.    #define     INCL_NETERRORS
  27547.    #define     INCL_NETSHARE
  27548.    #include    <lan.h>            // LAN Manager header files
  27549.  
  27550.    #include    <stdio.h>          // C run-time header files
  27551.    #include    <stdlib.h>
  27552.    #include    <string.h>
  27553.  
  27554.    #include    "samples.h"        // Internal routine header file
  27555.  
  27556.    #define BIG_BUFFER_SIZE   32768
  27557.    #define A_SHAREPATH       "A:\\"
  27558.    #define A_SHARENAME       "FLOPPY"
  27559.    #define A_SHAREREMARK     "shared floppy drive"
  27560.    #define CHECK_RESOURCE    "LPT1"
  27561.    #define MAX_USERS         8
  27562.  
  27563.    void Usage(char *pszString);
  27564.  
  27565.    void main(int argc, char *argv[])
  27566.    {
  27567.       char * pszServer = NULL;                // Default to local server
  27568.       char * pbBuffer;                        // Return data buffer
  27569.       char * pszResShare = A_SHAREPATH;       // Share path
  27570.       char * pszResCheck = CHECK_RESOURCE;    // Device for NetShareCheck
  27571.  
  27572.       char * pszNetName = A_SHARENAME;        // Name for the shared
  27573.    resource
  27574.       char * pszRemark = A_SHAREREMARK;       // Default share comment
  27575.       int    iCount;                          // Index and loop counter
  27576.       unsigned short usMaxUses;               // For SetInfo call
  27577.       unsigned short cEntriesRead;            // Count of entries read
  27578.       unsigned short cTotalAvail;             // Count of entries available
  27579.       unsigned short cbBuffer;                // Size of buffer, in bytes
  27580.       unsigned short cbTotalAvail;            // Total available data
  27581.       unsigned short sLevel = 1;              // Level of detail
  27582.       unsigned short usType = STYPE_DISKTREE; // Share type for NetShareAdd
  27583.       API_RET_TYPE   uReturnCode;             // API return code
  27584.       struct share_info_0 *pBuf0;             // Pointer to returned
  27585.    data
  27586.       struct share_info_1 *pBuf1;             // Level 1 data
  27587.       struct share_info_2 *pBuf2;             // Level 2 data
  27588.  
  27589.       for (iCount = 1; iCount < argc; iCount++)
  27590.       {
  27591.          if ((*argv[iCount] == '-') || (*argv[iCount] == '/'))
  27592.          {
  27593.             switch (tolower(*(argv[iCount]+1))) // Process switches
  27594.             {
  27595.                case 's':                        // -s servername
  27596.                   pszServer = argv[++iCount];
  27597.                   break;
  27598.                case 'r':                        // -r sharename
  27599.                   pszNetName = argv[++iCount];
  27600.                   break;
  27601.                case 'l':                        // -l level
  27602.                   sLevel = (short)(atoi(argv[++iCount]));
  27603.                   break;
  27604.                case 'd':                        // -d devicename
  27605.                   pszResCheck = argv[++iCount];
  27606.                   break;
  27607.  
  27608.    case 't':                        // -t share type
  27609.                   usType = (unsigned short)(atoi(argv[++iCount]));
  27610.                   break;
  27611.                case 'c':                        // -c comment for share
  27612.                   pszRemark = argv[++iCount];
  27613.                   break;
  27614.                case 'p':                        // -p pathname for share
  27615.                   pszResShare = argv[++iCount];
  27616.                   break;
  27617.                default:
  27618.                   Usage(argv[0]);
  27619.                }
  27620.             }
  27621.          else
  27622.             Usage(argv[0]);
  27623.       } // End for loop
  27624.  
  27625.    //========================================================================
  27626.    //  NetShareAdd
  27627.    //
  27628.    //  This API adds a shared resource. The default is to share the
  27629.    //  A:\ drive using the sharename FLOPPY. The API must be called at
  27630.  
  27631.    //  level 2. The logged-on user must have admin privilege or server
  27632.    //  operator privilege, and the Server service must be started for
  27633.    //  this call to succeed.
  27634.    //========================================================================
  27635.  
  27636.       cbBuffer = sizeof(struct share_info_2);
  27637.       pbBuffer = SafeMalloc(cbBuffer);            // Allocate buffer
  27638.       pBuf2 = (struct share_info_2 *)pbBuffer;    // Start of memory
  27639.    block
  27640.  
  27641.       strcpy(pBuf2->shi2_netname, pszNetName);    // Sharename
  27642.       pBuf2->shi2_path = pszResShare;             // Local pathname
  27643.       pBuf2->shi2_type = usType;                  // Share type
  27644.       pBuf2->shi2_passwd[0] = '\0';               // No password
  27645.       pBuf2->shi2_remark = pszRemark;             // Share remark
  27646.       pBuf2->shi2_permissions = ACCESS_PERM;      // Admin privilege
  27647.       pBuf2->shi2_max_uses = MAX_USERS;           // Max. users of share
  27648.  
  27649.       uReturnCode = NetShareAdd(pszServer,        // Servername
  27650.                                 2,                // Info level; must
  27651.    be 2
  27652.                                 pbBuffer,         // Data structure
  27653.                                 cbBuffer);        // Size of buffer,
  27654.    in bytes
  27655.  
  27656.    printf("NetShareAdd returned %u\n", uReturnCode);
  27657.       switch (uReturnCode)
  27658.       {
  27659.          case NERR_DuplicateShare:
  27660.             printf("Resource %s is already shared\n\n", pszResShare);
  27661.             break;
  27662.          case NERR_ServerNotStarted:
  27663.             printf("The server is not started\n\n");
  27664.             exit(1);
  27665.             break;
  27666.          default:
  27667.             break;
  27668.       }
  27669.       free(pbBuffer);
  27670.  
  27671.    //========================================================================
  27672.    //  NetShareGetInfo
  27673.    //
  27674.    //  This API gets and displays information about the sharename just
  27675.    added.
  27676.    //========================================================================
  27677.  
  27678.       cbBuffer = BIG_BUFFER_SIZE;                 // Large enough buffer
  27679.       pbBuffer = SafeMalloc(cbBuffer);            // Allocate buffer
  27680.  
  27681.       uReturnCode = NetShareGetInfo(pszServer,    // Servername
  27682.                           pszNetName,             // Device to get info
  27683.    about
  27684.                           sLevel,                 // Info level
  27685.                           pbBuffer,               // Data returned here
  27686.                           cbBuffer,               // Size of buffer,
  27687.    in bytes
  27688.                           &cbTotalAvail);         // Bytes of data available
  27689.  
  27690.       printf("NetShareGetInfo of %s ", pszNetName);
  27691.       printf(" returned %u\n", uReturnCode);
  27692.       if (uReturnCode == NERR_Success)
  27693.       {
  27694.          switch (sLevel)
  27695.          {
  27696.             case 2:                               // Use level 2 structure
  27697.                pBuf2 = (struct share_info_2 *) pbBuffer;
  27698.                printf("   Permissions : 0x%x\n", pBuf2->shi2_permissions);
  27699.                printf("   Max. users  : %hu\n", pBuf2->shi2_max_uses);
  27700.                printf("   Curr. users : %hu\n", pBuf2->shi2_current_uses);
  27701.                printf("   Path        : %Fs\n", pBuf2->shi2_path);
  27702.             case 1:                               // Use level 1 structure
  27703.                pBuf1 = (struct share_info_1 *) pbBuffer;
  27704.                printf("   Type        : %hu\n", pBuf1->shi1_type);
  27705.                printf("   Remark      : %Fs\n", pBuf1->shi1_remark);
  27706.             case 0:                               // Use level 0 structure
  27707.                pBuf0 = (struct share_info_0 *) pbBuffer;
  27708.                printf("   Resource    : %s\n", pBuf0->shi0_netname);
  27709.                break;
  27710.             default:
  27711.                break;
  27712.          }
  27713.       }
  27714.  
  27715.  
  27716.    //  NetShareSetInfo
  27717.    //
  27718.    //  This API changes the maximum number of users allowed by the share
  27719.  
  27720.    //  to unlimited. There are two ways to call NetShareSetInfo. If
  27721.    //  sParmNum == PARMNUM_ALL, you must set the whole structure. Otherwise,
  27722.  
  27723.    //  you can set sParmNum to the element of the structure you want
  27724.    to
  27725.    //  change. This example sets only the "max uses" parameter by setting
  27726.    //  sParmNum to SHI_MAX_USES_PARMNUM.
  27727.  
  27728.       usMaxUses = SHI_USES_UNLIMITED;
  27729.  
  27730.       uReturnCode = NetShareSetInfo(pszServer,    // Servername
  27731.                           pszNetName,             // Device to set info
  27732.    on
  27733.                           2,                      // Info level
  27734.                           (char far *)&usMaxUses, // Data buffer address
  27735.                           sizeof(usMaxUses),      // Size of buffer,
  27736.    in bytes
  27737.                           SHI_MAX_USES_PARMNUM);  // Parameter to set
  27738.  
  27739.       printf("NetShareSetInfo of max. users returned %u\n", uReturnCode);
  27740.  
  27741.    //========================================================================
  27742.    //  NetShareDel
  27743.    //
  27744.    //  This API deletes the sharename established by the previous
  27745.    //  NetShareAdd call.
  27746.    //========================================================================
  27747.  
  27748.       uReturnCode = NetShareDel(pszServer,        // Servername
  27749.                                 pszNetName,       // Sharename to be
  27750.    deleted
  27751.                                 0);               // Reserved; must be
  27752.    0
  27753.  
  27754.       printf("NetShareDel of %s returned %u\n", pszNetName, uReturnCode);
  27755.  
  27756.    //========================================================================
  27757.    //  NetShareCheck
  27758.    //
  27759.    //  This API checks to see if the device is being shared.
  27760.    //========================================================================
  27761.  
  27762.       uReturnCode = NetShareCheck(pszServer,      // Servername
  27763.                                   pszResCheck,    // Device to check
  27764.                                   &usType);       // Return share type
  27765.  
  27766.       printf("NetShareCheck of %s returned %u\n", pszResCheck, uReturnCode);
  27767.       switch (uReturnCode)
  27768.       {
  27769.          case NERR_Success:
  27770.             printf("   Resource %s is shared as type %hu\n",
  27771.                        pszResCheck, usType);
  27772.             break;
  27773.          case NERR_DeviceNotShared:
  27774.             printf("   Resource %s is not shared\n", pszResCheck);
  27775.             break;
  27776.          default:
  27777.             break;
  27778.       }
  27779.  
  27780.    //========================================================================
  27781.    //  NetShareEnum
  27782.    //
  27783.    //  This API displays the current sharenames.
  27784.    //========================================================================
  27785.  
  27786.       uReturnCode = NetShareEnum(pszServer,      // Servername
  27787.                                sLevel,           // Info level
  27788.                                pbBuffer,         // Data returned here
  27789.                                cbBuffer,         // Size of buffer, in
  27790.    bytes
  27791.                                &cEntriesRead,    // Count of entries
  27792.    read
  27793.                                &cTotalAvail);    // Count of entries
  27794.    available
  27795.  
  27796.       printf("NetShareEnum returned %u \n", uReturnCode);
  27797.  
  27798.    if (uReturnCode == NERR_Success)
  27799.       {
  27800.          pBuf0 = (struct share_info_0 *) pbBuffer;
  27801.          pBuf1 = (struct share_info_1 *) pbBuffer;
  27802.          pBuf2 = (struct share_info_2 *) pbBuffer;
  27803.          for (iCount = 0; iCount < (int) cEntriesRead; iCount++)
  27804.          {
  27805.             switch (sLevel)
  27806.             {
  27807.                case 0:
  27808.                   printf("   %s\n", pBuf0->shi0_netname);
  27809.                   pBuf0++;
  27810.                   break;
  27811.                case 1:
  27812.                   printf("   %s\n", pBuf1->shi1_netname);
  27813.                   printf("      remark: %Fs\n", pBuf1->shi1_remark);
  27814.                   pBuf1++;
  27815.                   break;
  27816.                case 2:
  27817.                   printf("%s\n", pBuf2->shi2_netname);
  27818.                   printf("      remark: %Fs\n", pBuf1->shi1_remark);
  27819.                   printf("      path: %Fs\n\n", pBuf2->shi2_path);
  27820.                   pBuf2++;
  27821.                   break;
  27822.             }
  27823.          }
  27824.          printf("Entries read: %hu out of %hu \n", cEntriesRead,
  27825.  cTotalAvail);
  27826.       }
  27827.  
  27828.       free(pbBuffer);
  27829.       exit(0);
  27830.    }
  27831.  
  27832.    //========================================================================
  27833.    //  Usage
  27834.    //
  27835.    //  Display possible command-line switches for this example.
  27836.    //========================================================================
  27837.  
  27838.    void Usage(char *pszString)
  27839.    {
  27840.       fprintf(stderr, "Usage: %s [-s \\\\server]", pszString);
  27841.       fprintf(stderr, " [-r sharename] [-l level]\n\t\t[-d devicename]");
  27842.       fprintf(stderr, " [-t type] [-c comment] [-p path]\n");
  27843.       exit(1);
  27844.    }
  27845.  
  27846.  
  27847.  
  27848.  
  27849.  
  27850.  
  27851.  
  27852.  Statistics Category
  27853.  
  27854.  The Statistics API function, NetStatisticsGet2, retrieves and clears the
  27855.  operating statistics for workstations and servers. It requires that the
  27856.  Workstation service be started and, if server statistics are required, that
  27857.  the Server service be started.
  27858.  
  27859.  The Statistics category functions, datatypes, structures, and constants are
  27860.  defined in the NETCONS.H, NETERR.H, and NETSTATS.H header files. A source
  27861.  program can access these definitions by defining the constants
  27862.  INCL_NETERRORS and INCL_NETSTATS, and including the master header file,
  27863.  LAN.H. For more information, see the "Example" section, later in this
  27864.  category.
  27865.  
  27866.  
  27867.  Description
  27868.  
  27869.  LAN Manager accumulates a set of operating statistics for workstations and
  27870.  servers from the time that the Workstation or Server service is started.
  27871.  NetStatisticsGet2 is called to get, and optionally clear, those statistics.
  27872.  
  27873.  
  27874.  
  27875.  Data Structures
  27876.  
  27877.  NetStatisticsGet2 returns a stat_workstation_0 data structure when
  27878.  workstation statistics are requested; it returns a stat_server_0 data
  27879.  structure when server statistics are requested.
  27880.  
  27881.  
  27882.  Workstation Statistics
  27883.  
  27884.  The stat_workstation_0 data structure has this format:
  27885.  
  27886.    struct stat_workstation_0 {
  27887.        unsigned long stw0_start;
  27888.        unsigned long stw0_numNCB_r;
  27889.        unsigned long stw0_numNCB_s;
  27890.        unsigned long stw0_numNCB_a;
  27891.        unsigned long stw0_fiNCB_r;
  27892.        unsigned long stw0_fiNCB_s;
  27893.        unsigned long stw0_fiNCB_a;
  27894.        unsigned long stw0_fcNCB_r;
  27895.        unsigned long stw0_fcNCB_s;
  27896.        unsigned long stw0_fcNCB_a;
  27897.        unsigned long stw0_sesstart;
  27898.        unsigned long stw0_sessfailcon;
  27899.        unsigned long stw0_sessbroke;
  27900.        unsigned long stw0_uses;
  27901.        unsigned long stw0_usefail;
  27902.        unsigned long stw0_autorec;
  27903.        unsigned long stw0_bytessent_r_hi;
  27904.        unsigned long stw0_bytessent_r_lo;
  27905.        unsigned long stw0_bytesrcvd_r_hi;
  27906.        unsigned long stw0_bytesrcvd_r_lo;
  27907.        unsigned long stw0_bytessent_s_hi;
  27908.        unsigned long stw0_bytessent_s_lo;
  27909.        unsigned long stw0_bytesrcvd_s_hi;
  27910.        unsigned long stw0_bytesrcvd_s_lo;
  27911.        unsigned long stw0_bytessent_a_hi;
  27912.        unsigned long stw0_bytessent_a_lo;
  27913.        unsigned long stw0_bytesrcvd_a_hi;
  27914.        unsigned long stw0_bytesrcvd_a_lo;
  27915.        unsigned long stw0_reqbufneed;
  27916.        unsigned long stw0_bigbufneed;
  27917.    };
  27918.  
  27919.  where
  27920.  
  27921.  stw0_start
  27922.    Specifies the time statistics collection started. This element also
  27923.    indicates when the statistics were last cleared. The value is stored as
  27924.    the number of seconds elapsed since 00:00:00, January 1, 1970. To
  27925.    calculate the length of time that statistics have been collected, subtract
  27926.    this value from the present time.
  27927.  
  27928.  stw0_numNCB
  27929.    These three elements indicate the total number of network control blocks
  27930.    (NCBs) issued from each source (the counts include failed NCBs). To
  27931.    calculate the total number of successful NCBs, subtract the number of
  27932.    failed NCBs from stw0_numNCB. These numbers are held in the stw0_fiNCB and
  27933.    stw0_fcNCB elements, and are explained in the stw0_fiNCB and stw0_fcNCB
  27934.    descriptions following this list.
  27935.  
  27936.      stw0_numNCB_r
  27937.        Specifies the total number of NCBs issued by the redirector.
  27938.  
  27939.      stw0_numNCB_s
  27940.        Specifies the total number of NCBs issued by the server.
  27941.  
  27942.      stw0_numNCB_a
  27943.        Specifies the total number of NCBs issued by applications.
  27944.  
  27945.  stw0_fiNCB
  27946.    These three elements indicate the number of NCBs that failed for any
  27947.    reason when they were issued. These NCBs are included in the "total
  27948.    issued" count specified by stw0_numNCB.
  27949.  
  27950.      stw0_fiNCB_r
  27951.        Specifies the number of NCBs that failed when issued by the
  27952.        redirector.
  27953.  
  27954.      stw0_fiNCB_s
  27955.        Specifies the number of NCBs that failed when issued by the server.
  27956.  
  27957.      stw0_fiNCB_a
  27958.        Specifies the number of NCBs that failed when issued by applications.
  27959.  
  27960.  stw0_fcNCB
  27961.    These three elements indicate the number of NCBs that failed after issue,
  27962.    at or before completion. These NCBs are also included in the "total
  27963.    issued" count specified by stw0_numNCB.
  27964.  
  27965.      stw0_fcNCB_r
  27966.        Specifies the number of NCBs that were issued by the redirector and
  27967.        that failed before completion.
  27968.  
  27969.      stw0_fcNCB_s
  27970.        Specifies the number of NCBs that were issued by the server and that
  27971.        failed before completion.
  27972.  
  27973.      stw0_fcNCB_a
  27974.        Specifies the number of NCBs that were issued by applications and that
  27975.        failed before completion.
  27976.  
  27977.  stw0_sesstart
  27978.    Specifies the number of workstation sessions started.
  27979.  
  27980.  stw0_sessfailcon
  27981.    Specifies the number of workstation sessions that failed to connect, not
  27982.    counting those that failed due to "name not found."
  27983.  
  27984.  stw0_sessbroke
  27985.    Specifies the number of workstation sessions that failed after the session
  27986.    was established.
  27987.  
  27988.  stw0_uses
  27989.    Specifies the number of workstation uses.
  27990.  
  27991.  stw0_usefail
  27992.    Specifies the number of workstation use failures. This is a count of the
  27993.    times the tree connections failed, when a server is found but the
  27994.    resources are not found.
  27995.  
  27996.  stw0_autorec
  27997.    Specifies the number of workstation autoconnections.
  27998.  
  27999.  The following 12 elements form six quad-words that contain very large
  28000.  counters. (A quad-word is a data area twice as large as a double word.) The
  28001.  high double word (dword) of each is the value divided by 2
  28002.  sup 32; the low dword is the value modulo 2 sup 32. The counter value equals
  28003.  (high dword * 2 sup 32) + (low dword).
  28004.  
  28005.  These elements count total bytes in all NCBs sent and received for all
  28006.  categories.
  28007.  
  28008.  Note the following for all the NCB-related and byte-count counters:
  28009.  
  28010.  
  28011.    ■   Elements with the suffix _r are NCBs issued by the redirector as part
  28012.        of the typical process of maintaining remote network connections.
  28013.  
  28014.    ■   Elements with the suffix _s are server-related, sent by the redirector
  28015.        on behalf of the server to maintain shared resource connections.
  28016.  
  28017.    ■   Elements with the suffix _a are application-generated NCBs.
  28018.        Applications can generate these elements by calling NetBiosSubmit,
  28019.        using second-class mailslots, sending and receiving server
  28020.        announcements, and so on.
  28021.  
  28022.        stw0_bytessent_r_hi
  28023.    Specifies the number of workstation bytes sent to the network (high
  28024.    dword).
  28025.  
  28026.        stw0_bytessent_r_lo
  28027.    Specifies the number of workstation bytes sent to the network (low dword).
  28028.  
  28029.        stw0_bytesrcvd_r_hi
  28030.    Specifies the number of workstation bytes received from the network (high
  28031.    dword).
  28032.  
  28033.        stw0_bytesrcvd_r_lo
  28034.    Specifies the number of workstation bytes received from the network (low
  28035.    dword).
  28036.  
  28037.        stw0_bytessent_s_hi
  28038.    Specifies the number of server bytes sent to the network (high dword).
  28039.  
  28040.        stw0_bytessent_s_lo
  28041.    Specifies the number of server bytes sent to the network (low dword).
  28042.  
  28043.        stw0_bytesrcvd_s_hi
  28044.    Specifies the number of workstation bytes received from the network (high
  28045.    dword).
  28046.  
  28047.        stw0_bytesrcvd_s_lo
  28048.    Specifies the number of workstation bytes received from the network (low
  28049.    dword).
  28050.  
  28051.        stw0_bytessent_a_hi
  28052.    Specifies the number of application bytes sent to the network (high
  28053.    dword).
  28054.  
  28055.        stw0_bytessent_a_lo
  28056.    Specifies the number of application bytes sent to the network (low dword).
  28057.  
  28058.        stw0_bytesrcvd_a_hi
  28059.    Specifies the number of application bytes received from the network (high
  28060.    dword).
  28061.  
  28062.        stw0_bytesrcvd_a_lo
  28063.    Specifies the number of application bytes received from the network (low
  28064.    dword).
  28065.  
  28066.        stw0_reqbufneed
  28067.    Specifies the number of times the workstation required a request buffer
  28068.    but failed to allocate one. This element indicates that the workstation
  28069.    parameters may need adjustment.
  28070.  
  28071.        stw0_bigbufneed
  28072.    Specifies the number of times the workstation required a big buffer but
  28073.    failed to allocate one. This element indicates that the workstation
  28074.    parameters may need adjustment.
  28075.  
  28076.  ────────────────────────────────────────────────────────────────────────────
  28077.  NOTE
  28078.  A value of STATS_NO_VALUE for any element means that information is not
  28079.  available. A value of STATS_OVERFLOW means that the element has overflowed.
  28080.  The NETSTATS.H header file defines these
  28081.  constants.───────────────────────────────────────────────────────────────────
  28082.  
  28083.  
  28084.  
  28085.  
  28086.  Server Statistics
  28087.  
  28088.  The stat_server_0 data structure has this format:
  28089.  
  28090.    struct stat_server_0 {
  28091.        unsigned long sts0_start;
  28092.        unsigned long sts0_fopens;
  28093.        unsigned long sts0_devopens;
  28094.        unsigned long sts0_jobsqueued;
  28095.        unsigned long sts0_sopens;
  28096.        unsigned long sts0_stimedout;
  28097.        unsigned long sts0_serrorout;
  28098.        unsigned long sts0_pwerrors;
  28099.        unsigned long sts0_permerrors;
  28100.        unsigned long sts0_syserrors;
  28101.        unsigned long sts0_bytessent_low;
  28102.        unsigned long sts0_bytessent_high;
  28103.        unsigned long sts0_bytesrcvd_low;
  28104.        unsigned long sts0_bytesrcvd_high;
  28105.        unsigned long sts0_avresponse;
  28106.        unsigned long sts0_reqbufneed;
  28107.        unsigned long sts0_bigbufneed;
  28108.    };
  28109.  
  28110.  where
  28111.  
  28112.  sts0_start
  28113.    Specifies the time statistics collection started. This element also
  28114.    indicates when the statistics were last cleared. The value is stored as
  28115.    the number of seconds elapsed since 00:00:00, January 1, 1970. To
  28116.    calculate the length of time that statistics have been collected, subtract
  28117.    this value from the present time.
  28118.  
  28119.  sts0_fopens
  28120.    Specifies the number of server file opens. This includes opens of named
  28121.    pipes.
  28122.  
  28123.  sts0_devopens
  28124.    Specifies the number of server device opens.
  28125.  
  28126.  sts0_jobsqueued
  28127.    Specifies the number of server print jobs spooled.
  28128.  
  28129.  sts0_sopens
  28130.    Specifies the number of times the server session started.
  28131.  
  28132.  sts0_stimedout
  28133.    Specifies the number of times the server session automatically
  28134.    disconnected.
  28135.  
  28136.  sts0_serrorout
  28137.    Specifies the number of times the server sessions failed with an error.
  28138.  
  28139.  sts0_pwerrors
  28140.    Specifies the number of server password violations.
  28141.  
  28142.  sts0_permerrors
  28143.    Specifies the number of server access permission errors.
  28144.  
  28145.  sts0_syserrors
  28146.    Specifies the number of server system errors.
  28147.  
  28148.  The following four elements form two quad-words, which contain very large
  28149.  counters. (A quad-word is a data area twice as large as a double word.) The
  28150.  high dword of each is the value divided by 2 sup 32; the low dword is the
  28151.  value modulo 2 sup 32. The counter value equals (high dword * 2 sup 32) +
  28152.  (low dword).
  28153.  
  28154.  sts0_bytessent_low
  28155.    Specifies the number of server bytes sent to the network (low dword).
  28156.  
  28157.  sts0_bytessent_high
  28158.    Specifies the number of server bytes sent to the network (high dword).
  28159.  
  28160.  sts0_bytesrcvd_low
  28161.    Specifies the number of server bytes received from the network (low
  28162.    dword).
  28163.  
  28164.  sts0_bytesrcvd_high
  28165.    Specifies the number of server bytes received from the network (high
  28166.    dword).
  28167.  
  28168.  sts0_avresponse
  28169.    Specifies the average server response time (in milliseconds).
  28170.  
  28171.  sts0_reqbufneed
  28172.    Specifies the number of times the server required a request buffer but
  28173.    failed to allocate one. This value indicates that the server parameters
  28174.    may need adjustment.
  28175.  
  28176.  sts0_bigbufneed
  28177.    Specifies the number of times the server required a big buffer but failed
  28178.    to allocate one. This value indicates that the server parameters may need
  28179.    adjustment.
  28180.  
  28181.  ────────────────────────────────────────────────────────────────────────────
  28182.  NOTE
  28183.  
  28184.  A value of STATS_NO_VALUE for any element means that information is not
  28185.  available. A value of STATS_OVERFLOW means that the element has overflowed.
  28186.  The NETSTATS.H header file defines these constants.
  28187.  ────────────────────────────────────────────────────────────────────────────
  28188.  
  28189.  
  28190.  NetStatisticsGet2
  28191.  ────────────────────────────────────────────────────────────────────────────
  28192.  
  28193.  NetStatisticsGet2 retrieves, and optionally clears, operating statistics for
  28194.  a service. Currently, only the Workstation and Server services are
  28195.  supported.
  28196.  
  28197.  
  28198.  Operating Systems Supported
  28199.  
  28200.  
  28201.    ■   MS OS/2 version 1.2, local and remote
  28202.  
  28203.    ■   MS OS/2 version 1.1, local and remote
  28204.  
  28205.    ■   MS-DOS, remote only
  28206.  
  28207.  
  28208.  
  28209.  Privilege Level
  28210.  
  28211.  Admin privilege or server operator privilege is required to successfully
  28212.  execute NetStatisticsGet2 on a remote server. A non-admin class user cannot
  28213.  use this function to clear statistics on a computer that has local security
  28214.  enabled.
  28215.  
  28216.  
  28217.  Syntax
  28218.  
  28219.    #define INCL_NETSTATS
  28220.    #define INCL_NETERRORS
  28221.    #include <lan.h>
  28222.  
  28223.    API_FUNCTION
  28224.    NetStatisticsGet2 (const char far *      pszServer,
  28225.                       const char far *      pszService,
  28226.                       unsigned long         ulReserved,
  28227.                       short                 sLevel,
  28228.                       unsigned long         flOptions,
  28229.                       char far *            pbBuffer,
  28230.                       unsigned short        cbBuffer,
  28231.                       unsigned short far *  pcbTotalAvail
  28232.                      );
  28233.  
  28234.  where
  28235.  
  28236.  pszServer
  28237.    Points to an ASCIIZ string that contains the name of the server on which
  28238.    to execute NetStatisticsGet2. A null pointer or null string specifies the
  28239.    local computer.
  28240.  
  28241.  pszService
  28242.    Points to an ASCIIZ string that contains the name of the service about
  28243.    which to get the statistics. Only the values SERVER and WORKSTATION are
  28244.    currently allowed. If another name is used, NetStatisticsGet2 returns
  28245.    ERROR_NOT_SUPPORTED.
  28246.  
  28247.  ulReserved
  28248.    Reserved; must be 0.
  28249.  
  28250.  sLevel
  28251.    Specifies the level of detail requested; must be 0.
  28252.  
  28253.  flOptions
  28254.    Specifies the options flags. The NETSTATS.H header file defines these
  28255.    possible values:
  28256.  
  28257.  Bit(s)  Bit Mask  Code          Meaning
  28258.  ────────────────────────────────────────────────────────────────────────────
  28259.  0       0x1       STATSOPT_CLR  Clear statistics.
  28260.  1-31                            Reserved; must be 0.
  28261.  ────────────────────────────────────────────────────────────────────────────
  28262.  
  28263.    The option to clear the