Solved

Using NetShareDel. I can't make it work!

Posted on 2008-06-09
3
715 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

25 Experts available now in Live!

Get 1:1 Help Now