title image


Smiley Hab nochwas gefunden...
Mit folgendem Code gehts bei mir, sollte auch eine saubere Lösung sein:





type

TShareInfo2 = packed record

shi2_netname : PWChar;

shi2_type : Dword;

shi2_remark : PWChar;

shi2_permissions : DWord;

shi2_max_uses : DWord;

shi2_current_uses : DWord;

shi2_path : PWChar;

shi2_passwd : PWChar;

end;



type

LMSTR = Windows.LPWSTR;

LPBYTE = Windows.PBYTE;

NET_API_STATUS = DWORD;



const



// share_info_2.permissions

ACCESS_READ = $01;

ACCESS_WRITE = $02;

ACCESS_CREATE = $04;

ACCESS_EXEC = $08;

ACCESS_DELETE = $10;

ACCESS_ATRIB = $20;

ACCESS_PERM = $40;



ACCESS_GROUP = $8000;



ACCESS_NONE = 0;

ACCESS_ALL = (ACCESS_READ or ACCESS_WRITE or ACCESS_CREATE or ACCESS_EXEC or ACCESS_DELETE or ACCESS_ATRIB or ACCESS_PERM);



// parm_err

SHARE_NETNAME_PARMNUM = 1;

SHARE_TYPE_PARMNUM = 3;

SHARE_REMARK_PARMNUM = 4;

SHARE_PERMISSIONS_PARMNUM = 5;

SHARE_MAX_USES_PARMNUM = 6;

SHARE_CURRENT_USES_PARMNUM = 7;

SHARE_PATH_PARMNUM = 8;

SHARE_PASSWD_PARMNUM = 9;

SHARE_FILE_SD_PARMNUM = 501;



// type

STYPE_DISKTREE = 0;

STYPE_PRINTQ = 1;

STYPE_DEVICE = 2;

STYPE_IPC = 3;



STYPE_TEMPORARY = $40000000;

STYPE_SPECIAL = DWORD($80000000);



function NetShareAdd(servername: LMSTR; level: DWORD; buf: LPBYTE; parm_err: LPDWORD): NET_API_STATUS; stdcall; external 'netapi32.dll';

...



procedure TForm1.Button1Click(Sender: TObject);

var

share: TShareInfo2;

err: DWord;

begin

Share.shi2_netname:='Freigabename';

share.shi2_type:=STYPE_DISKTREE;

share.shi2_permissions:=ACCESS_ALL;

Share.shi2_remark:='Testfreigabe';

share.shi2_max_uses:=DWORD(-1);

share.shi2_current_uses:=0;

share.shi2_passwd:=nil;

share.shi2_path:='d:\TEMP';

NetShareAdd('',2,@Share,@err);

end;






Gruß Thomas


Was ist der Unterschied zwischen Bill Gates und Gott?

  -->Gott hält sich nicht für Bill Gates!




geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: