// ¾Æ·¡ ¿¹Á¦´Â Windows NT/Windows 2000 ´Â Áö¿øÇÏÁö ¾Ê½À´Ï´Ù
// ´Ù¸¥ Ç÷§ÆûÀº MSDN »çÀÌÆ®¸¦ Âü°íÇϼ¼¿ä
// http://msdn.microsoft.com/library/sdkdoc/network/ntlmapi_18bz.htm
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
// Win95/98 ¿¡¼ share info´Â 0,1,2,50 structure ¸¸ »ç¿ë°¡´É
// Windows NT¿¡¼ share info´Â 0,1,2,501,502,1005 structure ¸¸ »ç¿ë°¡´É
Share_Info50 = packed record
shi50_netname : array[0..12] of Char; {13}
shi50_type : Byte;
shi50_flags : Word;
shi50_remark : PChar;
shi50_path : PChar;
shi50_rw_password : array[0..8] of Char; {9}
shi50_ro_password : array[0..8] of Char;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function NetShareGetInfo(ServerName: PChar;
NetName: PChar;
ShareLevel: SmallInt;
Buffer: Pointer;
Size: Word;
var Used: Word): Integer; stdcall external 'SVRAPI.DLL';
function GetShareInfo(ServerName: PChar;
NetName: PChar;
var ShareStruct: Share_Info50): Integer;
var
PMyShare: ^Share_Info50;
AmountUsed: Word;
Error: Integer;
begin
PMyShare := AllocMem(255);
// 50 -> for Win95/98 peer servers
Error := NetShareGetInfo(ServerName, NetName, 50, PMyShare, 255, AmountUsed);
if Error = 0 then // ¿¡·¯¾øÀ½
begin
ShareStruct.shi50_netname := PMyShare.shi50_netname;
ShareStruct.shi50_type := PMyShare.shi50_type;
ShareStruct.shi50_flags := PMyShare.shi50_flags;
ShareStruct.shi50_remark := PMyShare.shi50_remark;
ShareStruct.shi50_path := PMyShare.shi50_path;
ShareStruct.shi50_rw_password := PMyShare.shi50_rw_password;
ShareStruct.shi50_ro_password := PMyShare.shi50_ro_password;
end;
FreeMem(PMyShare);
Result := Error;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Share_Info: Share_Info50;
rt: Integer;
begin
Memo1.Lines.Clear;
FillChar(Share_Info, SizeOf(Share_Info50), 0);
// * Local Machine ÀÌ ¾Æ´Ñ ¿ø°ÝÁö ÄÄÇ»ÅÍÀÇ °æ¿ì´Â Á¤È®È÷ µ¿ÀÛÇÏÁö ¾Ê½À´Ï´Ù
// '\±è¿µ´ë' -> ÄÄÇ»ÅÍ À̸§ (nil Àº Local MachineÀ» ÀǹÌÇÕ´Ï´Ù)
// 'ZZZ' -> °øÀ¯À̸§
rt := GetShareInfo('\±è¿µ´ë', 'ZZZ', Share_Info);
if rt = 0 then
begin
Memo1.Lines.Add('°øÀ¯À̸§: '+Share_Info.shi50_netname);
if Share_Info.shi50_type = 0 then
Memo1.Lines.Add('°øÀ¯ Á¾·ù: µð·ºÅ丮 °øÀ¯')
else if Share_Info.shi50_type = 1 then
Memo1.Lines.Add('°øÀ¯ Á¾·ù: ÇÁ¸°ÅÍ °øÀ¯');
Memo1.Lines.Add('Àüü °æ·Î: '+Share_Info.shi50_path);
Memo1.Lines.Add('¼³¸í: '+StrPas(Share_Info.shi50_remark));
if Share_Info.shi50_flags = (256 or 1) then
Memo1.Lines.Add('»ç¿ë ±ÇÇÑ: Àбâ Àü¿ë')
else if Share_Info.shi50_flags = (256 or 2) then
Memo1.Lines.Add('»ç¿ë ±ÇÇÑ: Àбâ/¾²±â')
else if Share_Info.shi50_flags = (256 or 1 or 2) then
Memo1.Lines.Add('»ç¿ë ±ÇÇÑ: ¾ÏÈ£¿¡ µû¶ó ´Ù¸§');
Memo1.Lines.Add('Àбâ/¾²±â ¾ÏÈ£: '+Share_Info.shi50_rw_password);
Memo1.Lines.Add('Àбâ Àü¿ë ¾ÏÈ£: '+Share_Info.shi50_ro_password);
end
else
begin
Memo1.Lines.Add('Á¤º¸¸¦ Àоî¿Ã ¼ö ¾ø½À´Ï´Ù. ¿¡·¯¹øÈ£('+IntToStr(rt)+')');
end;
end;
end. |
|