Solved

Using NetShareDel. I can't make it work!

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

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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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