Link to home
Start Free TrialLog in
Avatar of Johnjces
JohnjcesFlag for United States of America

asked on

Using NetShareDel. I can't make it work!

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
ASKER CERTIFIED SOLUTION
Avatar of wd123
wd123
Flag of Belarus image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Johnjces

ASKER

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
Got me to the right place. Thanks!