在线等待,Win98下如何编程实现将某个硬盘分区设置为共享?急!(100分)

  • 主题发起人 主题发起人 bcfans
  • 开始时间 开始时间
B

bcfans

Unregistered / Unconfirmed
GUEST, unregistred user!
请给我delphi的使用NetShareAdd函数方法设置共享的完整的源代码。(Win98下)((不要修改注册表的那种方法)
我用NetShareAdd函数,不知道差哪,运行后就是没效果。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Registry;

type
TForm1 = class(TForm)
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
NETNAME_LEN = 13;
PASSWORD_LEN = 9;
SHI50F_RDONLY = $0001;
var
Form1: TForm1;
function NetShareAdd(servername: PChar; level: smallint;
buf: Pointer; buf_len: smallint): smallint; far; stdcall;
external 'svrapi.dll';

implementation

{$R *.dfm}
type
SHARE_INFO_50 = record
netname: array[0..NETNAME_LEN - 1] of char;
sharetype: shortint;
flags: smallint;
remark: PChar;
path: PChar;
rw_password: array[0..PASSWORD_LEN - 1] of char;
ro_password: array[0..PASSWORD_LEN - 1] of char;
end;

procedure TForm1.Button2Click(Sender: TObject); //运行后就是没效果,差哪呢?
var
buf: pointer;
k: ^SHARE_INFO_50;
s: string;
i: integer;
begin
s := 'C:';
new(k);
k^.netname := 'C:';
k^.path := PChar(s);
k^.flags := 258;
k^.remark := PChar('');
buf := k;
NetShareAdd(PChar(''), 50, buf, 0);
Dispose(k);
end;

end.
 
后退
顶部