Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.02.17;
Скачать: CL | DM;

Вниз

Группа в XP   Найти похожие ветки 

 
akim2   (2003-12-15 17:32) [0]

Добрый всем!

Подскажите пож, как можно прочитать Workgroup в кот я сейчас работаю? В 2000 нашел а в XP не могу. Может кто знает?


 
Игорь Шевченко ©   (2003-12-15 22:08) [1]

unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TfMain = class(TForm)
Label1: TLabel;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
end;

var
fMain: TfMain;

implementation
uses
HSNetApi;

{$R *.dfm}

procedure TfMain.FormCreate(Sender: TObject);
var
S : PWideChar;
rc : DWORD;
begin
rc := NetpGetDomainName(@S);
if rc = NOERROR then begin
Edit1.Text := WideCharToString(S);
NetApiBufferFree(S);
end else
Edit1.Text := Format("Error %d", [rc]);
end;

end.


unit HSNetApi;

interface
uses
Windows;

function NetApiBufferFree (lpBuffer : Pointer) : Integer; stdcall;
function NetpGetDomainName (lpBuffer : Pointer) : Integer; stdcall;
function NetpGetComputerName (lpBuffer : Pointer) : Integer; stdcall;

implementation
uses
SysUtils;

{ NETAPI32.DLL functions }
type
TNetApiBufferFree =
function (lpBuffer : Pointer) : Integer; stdcall;
TNetpGetDomainName =
function (lpBuffer : Pointer) : Integer; stdcall;
TNetpGetComputerName =
function (lpBuffer : Pointer) : Integer; stdcall;

const
netapidllname = "netapi32.dll";

var
NetApiDllHandle: THandle;
_NetApiBufferFree : TNetApiBufferFree;
_NetpGetDomainName : TNetpGetDomainName;
_NetpGetComputerName : TNetpGetComputerName;

function InitNetApi : Boolean;
begin
if NetApiDllHandle = 0 then
if Win32Platform = VER_PLATFORM_WIN32_NT then begin
NetApiDllHandle := LoadLibrary(NetApidllname);
if NetApiDllHandle <> 0 then begin
@_NetApiBufferFree := GetProcAddress(NetApiDllHandle,
"NetApiBufferFree");
@_NetpGetDomainName := GetProcAddress(NetApiDllHandle,
"NetpGetDomainName");
@_NetpGetComputerName := GetProcAddress(NetApiDllHandle,
"NetpGetComputerName");
end;
end;
Result := (NetApiDllHandle <> 0);
end;

function NetApiNotImplemented : Integer;
begin
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
Result := ERROR_PROC_NOT_FOUND;
end;

function NetApiBufferFree (lpBuffer : Pointer) : Integer; stdcall;
begin
if InitNetApi and Assigned(_NetApiBufferFree) then
Result := _NetApiBufferFree(lpBuffer)
else
Result := NetApiNotImplemented;
end;

function NetpGetDomainName (lpBuffer : Pointer) : Integer; stdcall;
begin
if InitNetApi and Assigned(_NetpGetDomainName) then
Result := _NetpGetDomainName(lpBuffer)
else
Result := NetApiNotImplemented;
end;

function NetpGetComputerName (lpBuffer : Pointer) : Integer; stdcall;
begin
if InitNetApi and Assigned(_NetpGetComputerName) then
Result := _NetpGetComputerName(lpBuffer)
else
Result := NetApiNotImplemented;
end;

initialization
finalization
if NetApiDllHandle <> 0 then
FreeLibrary(NetApiDllHandle);
end.



Страницы: 1 вся ветка

Текущий архив: 2004.02.17;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.017 c
1-53594
leonidus
2004-02-01 11:58
2004.02.17
Не отрабатываются исключительные ситуации


6-53678
Werewolfru
2003-12-13 18:43
2004.02.17
Как программно получить статус пользователя по его UIN`у


3-53359
Fom
2004-01-28 12:29
2004.02.17
Как в FB переименовать таблицу с данными?


1-53590
hexone
2004-02-09 14:55
2004.02.17
Undo


4-53825
deema
2003-12-14 18:59
2004.02.17
Clipboard format