Link to home
Start Free TrialLog in
Avatar of CodedK
CodedKFlag for Greece

asked on

Create a folder and make it 'shared'.

Hi.

I'd like some code to create a folder ... if it doesnt exist allready...
and then make it shared to everybody.

Thanks in advance.
Avatar of BlackTigerX
BlackTigerX

to create it:
ForceDirectories('YourDirectoryHere')

if will create it if it doesn't exist
>>if will create it if it doesn't exist
IT will create it if it doesn't exist
for sharing use NetShareAdd, see here:
https://www.experts-exchange.com/questions/10167039/Desharing-Sharing-Folders.html

quote:
You need to use the NetShareAdd( ) and the NestShareSetInfo API calls...

The win32.hlp says NetShareAdd( ) does not work in win 9.* but it actully does...

example
var
 Buff: array [0..MAX_PATH] of char;
begin
 NetShareAdd('YourMachineName', 502, Buff, 0 or nil);  NetShareSetInfo('YourMachineName', 'SharedAsName', 1501, Buff, 0 or nil);
end;
Avatar of CodedK

ASKER

Thank u BlackTigerX, I'll check it and i ll post. :)
Avatar of CodedK

ASKER

Undeclared udentifier...

Should i add something in uses ?
Avatar of CodedK

ASKER

BlackTigerX :/
I just took a look at the paq questions of other experts... Most of them had the same problem with this code...

Can u test it to see if it works or what is missing ?
is probably not in any of the units that comes with Delphi, but it is on the JEDIs API translation, in the JwaLmShare.pas unit

function NetShareAdd(servername: LMSTR; level: DWORD; buf: LPBYTE; parm_err: LPDWORD): NET_API_STATUS; stdcall;
ASKER CERTIFIED SOLUTION
Avatar of BlackTigerX
BlackTigerX

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 CodedK

ASKER

Thank u blackTiger :)