473,804 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(L ayoutKind.Seque ntial)> _
Private Structure SHARE_INFO_50
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim netname As String
Dim type As Integer
Dim flags As Int32
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim remark As String
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim path As String
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim rw_password As String
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim ro_password As String
End Structure

Private Declare Ansi Function NetShareEnum98 Lib "svrapi.dll " Alias
"NetShareEn um" ( _
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.AllocHG lobal(buffer)
level = 50
structSize = Marshal.SizeOf( GetType(SHARE_I NFO_50))
buffer = structSize * 20
bServer = ""

erreurLvl = NetShareEnum98( _
bServer, _
level, _
bufptr, _
buffer, _
dwEntriesRead, _
dwTotalEntries)
Nov 21 '05 #1
1 1808
Jean-Marc,
<StructLayout( LayoutKind.Sequ ential)> _
Private Structure SHARE_INFO_50
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim netname As String
Dim type As Integer
Dim flags As Int32
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim remark As String
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim path As String
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
Dim rw_password As String
<MarshalAs(Syst em.Runtime.Inte ropServices.Unm anagedType.LPWS tr)> _
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.By ValTStr for them.

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

type should be a Byte and flags a Short.

Private Declare Ansi Function NetShareEnum98 Lib "svrapi.dll " Alias
"NetShareEnu m" ( _
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.AllocHG lobal(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
4904
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> status -------------- mysql Ver 12.21 Distrib 4.0.15, for Win95/Win98 Connection id: 5 Current database:
14
9753
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 the cause is fundamentally a networking problem is also making me pull my hair out. Some history: The network is composed of five computers dating back to 1995, each purchased one at a time, and each having a different OS, etc. Until
2
1752
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 to execute the method raised by the event PrintPage. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object.
0
1509
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 NetShareEnum, as expected. However, if I know the password required to access the shares on the server, how do I specify that in my code?
1
7269
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 error code 5 (access denied). However, if I know the password to access the shares, how can I specify that in my program?
0
1100
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 error code 5 (access denied). However, if I know the password to access the shares, how can I specify that in my program?
1
2577
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 error code 5 (access denied). However, if I know the password to access the shares, how can I specify that in my program?
4
1746
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 webservice from my ASP.net application how could i do that........ how can i publish my webservice on win98 , is it possible or not if not then what should i do ........ remember the DLL which is called by my webservice only run on Win98.
4
3167
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 *bufptr, __in DWORD prefmaxlen, __out LPDWORD entriesread, __out LPDWORD totalentries,
0
9575
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10564
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.