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 IfThe 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)