全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1314
推到 Plurk!
推到 Facebook!

請問 windows2000/XP 的工作群組名稱(非網域名稱)如何得到?

答題得分者是:qoo1234
laser199
一般會員


發表:7
回覆:6
積分:2
註冊:2002-04-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-14 10:54:45 IP:61.221.xxx.xxx 未訂閱
1.我有搜尋過Registry 都沒有發現?存的路徑也和98不一樣 (非\System\CurrentControlSet\Services\VxD\VNETSUP\Workgroup) 2.有試過各種元件好像都抓到空白字串,但在我的電腦按右鍵內容明明就有... 請各位先進指教......謝謝
laser199
一般會員


發表:7
回覆:6
積分:2
註冊:2002-04-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-10-14 11:24:37 IP:61.221.xxx.xxx 未訂閱
聽說使用 NetWkstaGetInfo 函數可以但Delphi好像不能用???
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-10-14 11:47:30 IP:218.163.xxx.xxx 未訂閱
http://users.chello.be/ws36637/userlist.html http://www-level3.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20676575.html     
 
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;    type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
type
  WKSTA_INFO_100 = record
     wki100_platform_id  : DWORD;
     wki100_computername : LPWSTR;
     wki100_langroup     : LPWSTR;
     wki100_ver_major    : DWORD;
     wki100_ver_minor    : DWORD;
  end;    type WKSTA_USER_INFO_1 = record
     wkui1_username: LPWSTR;
     wkui1_logon_domain: LPWSTR;
     wkui1_oth_domains: LPWSTR;
     wkui1_logon_server:LPWSTR;
  end;    type LPWKSTA_INFO_100 = ^WKSTA_INFO_100;
type LPWKSTA_USER_INFO_1 = ^WKSTA_USER_INFO_1;    function NetWkstaGetInfo(servername:LPTSTR;level:DWORD;bufptr:LPWKSTA_INFO_100):Longint;stdcall;external 'netapi32.dll';
function NetWkstaUserGetInfo(reserved:LPWSTR;level:DWORD;bufptr:Pointer):Longint;stdcall;external 'netapi32.dll';    var
  Form1: TForm1;    implementation    {$R *.dfm}    procedure TForm1.Button1Click(Sender: TObject);
var pbufptr: LPWKSTA_INFO_100;
  buf: WKSTA_USER_INFO_1;
  Res: Longint;
begin
  Memo1.Lines.Clear;
  Res:=NetWkstaGetInfo(nil,100,@pbufptr);
  Memo1.Lines.Add('compname: ' pbufptr^.wki100_computername);
  Memo1.Lines.Add('group: ' pbufptr^.wki100_langroup);
  //Memo1.Lines.Add('res: ' inttostr(res));
  //Res:=NetWkstaUserGetInfo(nil,1,@buf);
  //ShowMessage(buf.wkui1_logon_domain);
end;    end.    
網海無涯,學無止境!
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-10-14 12:07:10 IP:218.163.xxx.xxx 未訂閱
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20405375.html    取得群組名稱 For Windows 98/NT/2000/XP  
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;    type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;    var
  Form1: TForm1;    implementation    {$R *.dfm}
function GetDomainName: AnsiString; 
type
WKSTA_INFO_100 = record 
  wki100_platform_id: Integer; 
  wki100_computername: PWideChar; 
  wki100_langroup: PWideChar;
  wki100_ver_major: Integer; 
  wki100_ver_minor: Integer;
end;     WKSTA_USER_INFO_1 = record 
  wkui1_username: PChar; 
  wkui1_logon_domain: PChar; 
  wkui1_logon_server: PChar; 
  wkui1_oth_domains: PChar; 
end;
type 
//Win9X ANSI prototypes from RADMIN32.DLL and RLOCAL32.DLL     TWin95_NetUserGetInfo = function(ServerName, UserName: PChar; Level: DWORD; var 
  BfrPtr: Pointer): Integer; 
stdcall;
TWin95_NetApiBufferFree = function(BufPtr: Pointer): Integer; 
stdcall; 
TWin95_NetWkstaUserGetInfo = function(Reserved: PChar; Level: Integer; var 
  BufPtr: Pointer): Integer; 
stdcall;     //WinNT UNICODE equivalents from NETAPI32.DLL     TWinNT_NetWkstaGetInfo = function(ServerName: PWideChar; level: Integer; var 
  BufPtr: Pointer): Integer; 
stdcall; 
TWinNT_NetApiBufferFree = function(BufPtr: Pointer): Integer;
stdcall;     function IsWinNT: Boolean; 
var 
  VersionInfo: TOSVersionInfo; 
begin
  VersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); 
  Result := GetVersionEx(VersionInfo); 
  if Result then 
    Result := VersionInfo.dwPlatformID = VER_PLATFORM_WIN32_NT; 
end; 
var    Win95_NetUserGetInfo: TWin95_NetUserGetInfo; 
Win95_NetWkstaUserGetInfo: TWin95_NetWkstaUserGetInfo; 
Win95_NetApiBufferFree: TWin95_NetApiBufferFree;     WinNT_NetWkstaGetInfo: TWinNT_NetWkstaGetInfo;
WinNT_NetApiBufferFree: TWinNT_NetApiBufferFree;     WSNT: ^WKSTA_INFO_100; 
WS95: ^WKSTA_USER_INFO_1;     EC: DWORD;
hNETAPI: THandle; 
begin 
try       Result := '';       if IsWinNT then 
  begin 
    hNETAPI := LoadLibrary('NETAPI32.DLL'); 
    if hNETAPI <> 0 then 
    begin @WinNT_NetWkstaGetInfo := GetProcAddress(hNETAPI, 'NetWkstaGetInfo'); 
        @WinNT_NetApiBufferFree  := GetProcAddress(hNETAPI, 'NetApiBufferFree');          EC := WinNT_NetWkstaGetInfo(nil, 100, Pointer(WSNT)); 
      if EC = 0 then 
      begin 
        Result := WideCharToString(WSNT^.wki100_langroup); 
        WinNT_NetApiBufferFree(Pointer(WSNT));
      end; 
    end; 
  end 
  else 
  begin 
    hNETAPI := LoadLibrary('RADMIN32.DLL');
    if hNETAPI <> 0 then 
    begin @Win95_NetApiBufferFree := GetProcAddress(hNETAPI, 'NetApiBufferFree'); 
        @Win95_NetUserGetInfo := GetProcAddress(hNETAPI, 'NetUserGetInfoA');           EC := Win95_NetWkstaUserGetInfo(nil, 1, Pointer(WS95)); 
      if EC = 0 then
      begin 
        Result := WS95^.wkui1_logon_domain; 
        Win95_NetApiBufferFree(Pointer(WS95)); 
      end; 
    end; 
  end;    finally 
  if hNETAPI <> 0 then 
    FreeLibrary(hNETAPI); 
end; 
end;    procedure TForm1.Button1Click(Sender: TObject);
begin
 ShowMessage('群組名稱:' GetDomainName);
end;    end.     
網海無涯,學無止境!
系統時間:2024-05-09 18:50:56
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!