[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Using NetShareDel. I can't make it work!

Posted on 2008-06-09
3
Medium Priority
?
757 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
[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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
wd123 earned 2000 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

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!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 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