Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unsharing a drive or path

Posted on 2000-03-15
8
Medium Priority
?
265 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
Technology Partners: 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 400 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

610 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