devxlogo

Buffer Return Problems

Buffer Return Problems

Question:
I am feeling very sick and was wondering if you could help me. I am trying to access the Lan Manager 2.1 API and am having difficulty get return data in my VB Structures (Types). I have never had to send a then retrieve data through dll with Types before an I am very confused and frustrated…As an example, Lanman has an api which returns information about the current workstation:

Declare Function NetWkstaGetInfo% Lib “NetAPI.dll” (ByVal Domain$, ByVal Level%, Buffer As Any, ByVal Bufsize%, Total%).
The VB code I am trying to use is as follows:
If NetWkstaGetInfo(“”, 1, “”, 0, cbBuffer) = NERR_BufTooSmall Then	retval = NetWkstaGetInfo(“”, 1, Buffer, cbBuffer, pcbTotalAvail)Else	MessageBox “Unable to retrieve User Network Information”, 0	Exit SubEnd If
The first line, NetWkstaGetInfo returns a buffer size (cbBuffer) of 214 bytes. But the data I get back appears to be garbage.

Answer:
Try calling the API with the following call:

retval = NetWkstaGetInfo(ByVal “”, ByVal 1, ByVal Buffer, ByVal cbBuffer, ByVal pcbTotalAvail)

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist