[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

Unsharing a drive or path

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
mabell
Asked:
mabell
1 Solution
 
b26Commented:
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
 
jeurkCommented:
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
 
jeurkCommented:
it's free and with sources...
0
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!

 
b26Commented:
netshareDel it's not a 16 bit function

take care,
B
0
 
MadshiCommented:
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
 
RusfistCommented:
Listening...
0
 
mabellAuthor Commented:
Thanks all for your help :-))
but Madshi will have the points. So Madshi post your comment as an answer :-)
Thx!!!
0
 
yk030299Commented:
listen
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now