Solved

Unsharing a drive or path

Posted on 2000-03-15
8
255 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
8 Comments
 

Expert Comment

by:b26
Comment Utility
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
Comment Utility
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
Comment Utility
it's free and with sources...
0
 

Expert Comment

by:b26
Comment Utility
netshareDel it's not a 16 bit function

take care,
B
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
Comment Utility
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
Comment Utility
Listening...
0
 

Author Comment

by:mabell
Comment Utility
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
Comment Utility
listen
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Create a Restore Point In Windows 10 3 102
IExtractImage Delphi 14 162
How to use Hashing sha1 in Delphi 2010 4 160
code issue 8 84
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now