Solved

Unsharing a drive or path

Posted on 2000-03-15
8
263 Views
Last Modified: 2010-05-18
Hi all :-)

I want to know how to unshare a drive or a path on a win9x box with no username or password set.

Thanks
0
Comment
Question by:mabell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Expert Comment

by:b26
ID: 2619097
Hi,

Use the function: (extras from MSDN)

NET_API_STATUS NetShareDel(
  LPWSTR servername,  
  LPWSTR netname,    
  DWORD reserved      
);
 
(could be found in in netapi32.dll NT, or svrapi.dll WIN95/98)

Parameters
servername
[in] Pointer to a Unicode string specifying the name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.
netname
[in] Pointer to a Unicode string specifying the network name of the share to delete.
reserved
Reserved, must be zero.
Return Values
If the function returns account information, the return value is NERR_Success.

If the function fails, the return value can be one of the following error codes:

ERROR_ACCESS_DENIED The user does not have access to the requested information.
ERROR_INVALID_PARAMETER The specified parameter is invalid.
ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available.
NERR_NetNameNotFound The share name does not exist.
0
 
LVL 4

Expert Comment

by:jeurk
ID: 2619159
hello,

Here http://www.jgsoftware.com/files/netconn.zip
you have a component that does all for you.
This component manages connections to network resources in Windows 95
      and NT.  You may establish connections, map local resources (drives and
      ports) to network resources, and you may break connections with this
      component.
It's using the Win32 API functions
      WNetAddConnection2 and WNetCancelConnection2 that you should use instead of netshareDel that is a 16 bit function (I think).

the site is here : http://www.jgsoftware.com/nt.htm

CU

0
 
LVL 4

Expert Comment

by:jeurk
ID: 2619161
it's free and with sources...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:b26
ID: 2619390
netshareDel it's not a 16 bit function

take care,
B
0
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
ID: 2619437
Hi guys,

with WNetAddConnection&Co you can map drives to an existing share respectively delete such a drive map. But you can't delete the share itself with this function. For this purpose you must use (as b26 suggested) NetShareDel, which is a 32bit function. But the function definition is different under win9x than it is under winNT!!! Here comes the win9x function definition:

extern API_FUNCTION
  NetShareDel ( const char FAR * pszServer,
                const char FAR * pszNetName,
                unsigned short   usReserved );

Which is this in Delphi:

procedure DelShare9x(shareName: string);
var svrDll : dword;
    NetShareDel9x : function (server, netName: pchar; reserved: word) : cardinal; stdcall;
begin
  svrDll := LoadLibrary('svrapi.dll');
  NetShareDel9x := GetProcAddress(svrDll, 'NetShareDel');
  NetShareDel9x(nil, pchar(shareName), 0);
  FreeLibrary(svrDll);
end;

Regards, Madshi.
0
 

Expert Comment

by:Rusfist
ID: 2619513
Listening...
0
 

Author Comment

by:mabell
ID: 2621021
Thanks all for your help :-))
but Madshi will have the points. So Madshi post your comment as an answer :-)
Thx!!!
0
 
LVL 1

Expert Comment

by:yk030299
ID: 2622071
listen
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question