这是基础问题,楼主仍需继续努力..........
要灵活,写成函数吧
// AFolder:要设置共享的目录
// AName:共享名
procedure TForm1.SetFolderShare(const AFolder, AName: String);
var
sDir: String;
iLen: Integer;
begin
sDir := Trim(AFolder);
iLen := Length(sDir);
if Copy(sDir,iLen,1) = '/' then sDir := Copy(sDir,1,iLen - 1);
//双引号用于处理字符串中存在空格的情况
WinExec(PChar('net.exe share "' + Trim(AName) + '"="' + sDir + '"'),SW_HIDE);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetFolderShare(ExtractFilePath(ParamStr(0)),'456');
end;