Netware Programming in Visual Basic A Brief Overview |
![]() |
|||||||
|
|
||||||||
Introduction
After watching the Comp.Lang.Basic.Visual news group for a while, I started to notice a lot of questions about making Netware API
calls from Visual Basic. Most of the questions originated as specific API how-to's, but then soon became general "How do I any Netware
API programming?". This paper is in response to these general question. All Calls Start HereMost Netware API functions reside in NWCALLS.DLL. But before you can make calls to map drives, query connections, or get the server date and time, some housekeeping must be performed. This housekeeping is the primary item that novice Netware programmers do not do. They tend to just make the Netware API call they want and then wonder why id did not work.The first Netware API call all applications must make is NWCallsInit. Without it, none of the other calls will work. The Visual Basic declare is: Declare Function NWCallsInit Lib "NWCALLS.DLL" (inp As Any, oup As Any) As IntegerYou should note that all Netware API calls return an integer return code. If the value is zero the call was successful, if non-zero the call failed. Making this call is quite simple and should be placed in the application startup code, such as the Load event for the main form. Make the NwCallsInit call as follows: Dim nwrc As IntegerOnce you have initialized the Netware calls interface, you can make all of the other Netware API calls. However, most of the Netware API calls require a connection handle as their first argument. I usually make the API call to obtain this handle right after calling NWCallsInit. I place the handle in a global variable so that I can use it whenever I need it for other API calls. To get a connection handle for the station your application is running on, call NWGetDefaultConnectionID. Its Visual Basic declare is: Declare Function NWGetDefaultConnectionID Lib "NWCALLS.DLL" (connhdl As Integer) As IntegerThis API function will place a connection handle in the passed integer variable. Get the connection handle like this: Global gConnHandle As IntegerOnce you have initialized NWCalls and obtained a connection a handle the world of Netware API is open. Obtaining Server InformationAt this point I will show a simple Netware API call that gets information about the server that the workstation is attached to. The Netware API function NWGetFileServerInformation will return the server name, the server Netware version information, connection information as well as few other pieces of information about the server. The Visual Basic declare is:Declare Function NWGetFileServerInformation Lib "NWCALLS.DLL" (ByVal connhdl As Integer, ByVal serverName as String,You can make this call as follows: Dim ret As IntegerNotice that the serverName variable is a fixed length string. This is required by the Netware API call because does not know how work with Visual Basic variable length strings. Any time a string is required for a Netware API call, make certain you define it as fixed length. If you wanted to get the date and time from the File Server you would use NWGetFileServerDateAndTime. The Visual Basic declare is: Declare Function NWGetFileServerDateAndTime Lib "NWCALLS.DLL" (ByVal connhdl As Integer, ByVal dtetme As String) As IntegerThis functions returns the date and time in a special byte layout that needs to be parsed. This code sample shows how this done. Dim ret As Integer ConclusionNetware programming is not difficult one you know how to start. Trying to get your Netware API call to work without the proper initialization can be quite trying. One further recommendation if you plan to do a lot of Netware programming, Novell has produced a CD-ROM that contains all of the API documentation, it sells for approximately $40.00 US. You should try to get a copy of this. It will make life as a Novell Netware programming much easier.Back |
||||||||