473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

NetShareEnum Error 87 in Win98

I need to access Windows API NetShareEnum. It is working fine in the post
Win98 version but the Win98 function is returning me error number 87
(Invalid parameters)

Whats I am doing wrong ?

Following is my code

Thanks

Jean-Marc St-Hilaire
-----------------------------------

<StructLayout(LayoutKind.Sequential)> _
Private Structure SHARE_INFO_50
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim netname As String
Dim type As Integer
Dim flags As Int32
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim remark As String
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim path As String
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim rw_password As String
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim ro_password As String
End Structure

Private Declare Ansi Function NetShareEnum98 Lib "svrapi.dll" Alias
"NetShareEnum" ( _
ByRef ServerName As String, _
ByVal level As Integer, _
ByRef BufPtr As IntPtr, _
ByRef cBuffer As Integer, _
ByRef entriesread As Integer, _
ByRef totalentries As Integer _
) As Integer

Dim bServer As String
Dim level As Integer
Dim bufptr As IntPtr
Dim buffer As Integer
Dim dwEntriesRead As Integer = 0
Dim dwTotalEntries As Integer = 0
bufptr = Marshal.AllocHGlobal(buffer)
level = 50
structSize = Marshal.SizeOf(GetType(SHARE_INFO_50))
buffer = structSize * 20
bServer = ""

erreurLvl = NetShareEnum98( _
bServer, _
level, _
bufptr, _
buffer, _
dwEntriesRead, _
dwTotalEntries)
Nov 21 '05 #1
1 1785
Jean-Marc,
<StructLayout(LayoutKind.Sequential)> _
Private Structure SHARE_INFO_50
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim netname As String
Dim type As Integer
Dim flags As Int32
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim remark As String
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim path As String
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim rw_password As String
<MarshalAs(System.Runtime.InteropServices.Unmanage dType.LPWStr)> _
Dim ro_password As String
End Structure
netname, rw_password and ro_password are fixed length strings with
sizes 13, 9 and 9 respectively, so you should use
UnmangedType.ByValTStr for them.

For the other string members, you can delete the MarshalAs attribute
(or change it to use UnmanagedType.LPStr).

type should be a Byte and flags a Short.

Private Declare Ansi Function NetShareEnum98 Lib "svrapi.dll" Alias
"NetShareEnum" ( _
ByRef ServerName As String, _
ByVal level As Integer, _
ByRef BufPtr As IntPtr, _
ByRef cBuffer As Integer, _
ByRef entriesread As Integer, _
ByRef totalentries As Integer _
) As Integer
ServerName, cBuffer and BufPtr should be passed ByVal.

All Integers except the return type should be Short.

Dim bServer As String
Dim level As Integer
Dim bufptr As IntPtr
Dim buffer As Integer
Dim dwEntriesRead As Integer = 0
Dim dwTotalEntries As Integer = 0
bufptr = Marshal.AllocHGlobal(buffer)


Since buffer is uninitialized at this point and has the default value
of 0, you're allocating a zero length buffer.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bruce W...1 | last post by:
I've got MySQL running as a service on my Windows 2000 box. And I can work with it using a command window (DOS box). I used the default install of MySQL and here's what status says: mysql>...
14
by: David W. Fenton | last post by:
I'm no stranger to this error message, but I have a client who is experiencing it, but, fortunately, without any actual data corruption, and it's driving them made. Their inability to grasp that...
2
by: David Sabo | last post by:
Hi all... I having trouble printing on Win98. I cannot print more than once if I'm lucky in win98, when the printdocument.print() is executed the following Exception is raised. It doesn't start...
0
by: siddharth_jain_1 | last post by:
Hello I am using NetShareEnum to enumerate all the shared folders of a server. If there is password set on the server, I get system error code 5 (access denied) as the return value of...
1
by: Siddharth Jain | last post by:
hello I am trying to enumerate the shared folders on a server using the NetShareEnum function. Now, when the server has a password set to access the shared folders, the function returns system...
0
by: Siddharth Jain | last post by:
hello I am trying to enumerate the shared folders on a server using the NetShareEnum function. Now, when the server has a password set to access the shared folders, the function returns system...
1
by: Siddharth Jain | last post by:
hello I am trying to enumerate the shared folders on a server using the NetShareEnum function. Now, when the server has a password set to access the shared folders, the function returns system...
4
by: Wasi Rehman | last post by:
hi friends, I have one webservice which i want to run on win98 system because some reference in that webservice only run in win98, and my ASP.net application is on win2000 pro. I want to call that...
4
by: taghi | last post by:
I want to call NetShareEnum, a function from netapi32.dll NetShareEnum has this definition: NET_API_STATUS NetShareEnum( __in LPWSTR servername, __in DWORD level, __out LPBYTE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.