Solved

Using NetShareDel. I can't make it work!

Posted on 2008-06-09
3
709 Views
Last Modified: 2010-04-21
I am using NetShareDel and declaring it as:

 function NetShareDel(ServerName, ShareName : PChar; level:DWord) : DWord; stdcall; external 'NETAPI32.DLL';

I create a share and call it "Test" and then do a simple button click...

procedure TForm1.Button4Click(Sender: TObject);
begin
 NetShareDel(nil, pChar('GuestGate'), 0);
end;

... to unshare the "Test" shared folder.

It does not unshare the folder.

What have I done/am doing wrong! I can use NetShareAdd just fine, but something's amiss here and I am brain dead!

Thanks!

John
0
Comment
Question by:Johnjces
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
wd123 earned 500 total points
ID: 21747409
In WinNT (or high) you must use ShareName in WideChar.
NameNT:PWChar;

...

Size:=SizeOf(WideChar)*256;

GetMem(NameNT,Size);

StringToWideChar(ShareName,NameNT,Size);

NetShareDelNT(nil,NameNT,0);

Open in new window

0
 
LVL 18

Author Comment

by:Johnjces
ID: 21747745
That did it!

THANKS!

Summation for others:

function NetShareDel(ServerName, ShareName : pwChar; level:DWord) : DWord; stdcall; external 'NETAPI32.DLL';

procedure TForm1.Button1Click(Sender: TObject);
var
 NameNT : PWChar;
 Size : Integer;
begin
 Size := SizeOf(WideChar)*256;
 GetMem(NameNT,Size);
 StringToWideChar('Test',NameNT,Size);
 NetShareDel(nil,NameNT,0);
end;

John
0
 
LVL 18

Author Closing Comment

by:Johnjces
ID: 31465545
Got me to the right place. Thanks!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

13 Experts available now in Live!

Get 1:1 Help Now