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

Вниз

связать тип данных и указатель возвращаемый функцией   Найти похожие ветки 

 
gibz ©   (2007-01-14 23:41) [0]

код такой
type
MPR_SERVER_HANDLE=THandle;
type
MPR_SERVER_0 = record
fLanOnlyMode: BOOL;
dwUpTime: DWORD;
dwTotalPorts: DWORD;
dwPortsInUse: DWORD;
end;
function MprAdminServerConnect(lpwsServerName: PWideChar; var phMprServer: MPR_SERVER_HANDLE): DWord; stdcall; external "mprapi.dll";
function MprAdminServerGetInfo(phMprServer: MPR_SERVER_HANDLE; dwLevel: DWord; var lplpBuffer: Pointer): DWord; stdcall; external "mprapi.dll";
procedure MprAdminServerDisconnect(var phMprServer: THandle); stdcall; external "mprapi.dll";

var
MprServer: MPR_SERVER_HANDLE;
MprErrors: DWord;
lpBuffer: Pointer;
ServInfo: MPR_SERVER_0;
begin
MprErrors:=MprAdminServerConnect("hanymej",MprServer);
writeln(MprErrors);
MprErrors:=MprAdminServerGetInfo(MprServer,0,lpBuffer);
writeln(MprErrors);
// как вывести данные полученные от MprAdminServerGetInfo
MprAdminServerDisconnect(MprServer);
end.


 
tesseract ©   (2007-01-15 00:01) [1]


> MprErrors:=MprAdminServerGetInfo(MprServer,0,lpBuffer);


А память под lpBuffer кто выделять будет? Да и тип данных у тебя в коде определишь. Если это PCHAR, то и передавай PCHAR.


 
gibz ©   (2007-01-15 00:12) [2]

выделяю память new(lpBuffer);
а дальше как ?
просто не могу понять как связать lpBuffer и MPR_SERVER_0


 
Eraser ©   (2007-01-15 01:01) [3]

> [2] gibz ©   (15.01.07 00:12)

на какую структуру или блок данных указывает lplpBuffer? без знания этого, что-то посоветовать сложно.


 
gibz ©   (2007-01-15 01:07) [4]

The MprAdminServerGetInfo function retrieves information about the specified RRAS server.

DWORD MprAdminServerGetInfo(
 MPR_SERVER_HANDLE hMprServer,
 DWORD dwLevel,
 LPBYTE* lplpBuffer
);

Parameters

hMprServer
   [in] Handle to the router to query. Obtain this handle by calling MprAdminServerConnect.
dwLevel
   [in] Specifies the level of the information requested. This parameter may be zero or one.

       Windows Server 2003 and Windows 2000 Server:  This parameter must be zero.

lplpBuffer
   [out] Pointer to a pointer variable. On successful return, this pointer variable points to a MPR_SERVER_0 or MPR_SERVER_1 structure depending on the value of dwLevel.

       Windows Server 2003 and Windows 2000 Server:  This variable points to a buffer that receives the retrieved information.

   Free the memory for this buffer using MprConfigBufferFree

Return Value

If the function succeeds, the return value is NO_ERROR.

If the function fails, the return value is one of the following error codes.


 
ors_archangel ©   (2007-01-15 01:14) [5]

Может, может, быть так:
type
MPR_SERVER_HANDLE=THandle;
type
MPR_SERVER_0 = record
fLanOnlyMode: BOOL;
dwUpTime: DWORD;
dwTotalPorts: DWORD;
dwPortsInUse: DWORD;
end;
function MprAdminServerConnect(lpwsServerName: PWideChar; var phMprServer: MPR_SERVER_HANDLE): DWord; stdcall; external "mprapi.dll";
function MprAdminServerGetInfo(phMprServer: MPR_SERVER_HANDLE; dwLevel: DWord; var lplpBuffer: MPR_SERVER_0): DWord; stdcall; external "mprapi.dll";
procedure MprAdminServerDisconnect(var phMprServer: THandle); stdcall; external "mprapi.dll";

var
MprServer: MPR_SERVER_HANDLE;
MprErrors: DWord;
ServInfo: MPR_SERVER_0;
begin
MprErrors:=MprAdminServerConnect("hanymej",MprServer);
writeln(MprErrors);
MprErrors:=MprAdminServerGetInfo(MprServer,0,ServInfo);
writeln(MprErrors);
with ServInfo do begin
 writeln("ServInfo:");
 writeln(" LanOnlyMode: ",fLanOnlyMode);
 writeln(" UpTime: ",dwUpTime);
 writeln(" TotalPorts: ",dwTotalPorts);
 writeln(" PortsInUse: ",dwPortsInUse);
end;

MprAdminServerDisconnect(MprServer);
end.


 
ors_archangel ©   (2007-01-15 01:16) [6]

А! "this pointer variable points to a MPR_SERVER_0 or MPR_SERVER_1 structure depending on the value of dwLevel", тогда в описание такое:
function MprAdminServerGetInfo(phMprServer: MPR_SERVER_HANDLE; dwLevel: DWord; var lplpBuffer): DWord; stdcall; external "mprapi.dll";
New(lpBuffer) не надо, передавай прямо ServInfo!


 
gibz ©   (2007-01-15 01:48) [7]

вообщем делаю так
type
 MPR_SERVER_HANDLE=THandle;
type
   MPR_SERVER_0 = record
   fLanOnlyMode:  BOOL;
   dwUpTime:  DWORD;
   dwTotalPorts:  DWORD;
   dwPortsInUse:  DWORD;
 end;
type
   MPR_SERVER_1 = record
   dwNumPptpPorts: DWORD;
   dwPptpPortFlags: DWORD;
   dwNumL2tpPorts: DWORD;
   dwL2tpPortFlags: DWORD;
 end;
function MprAdminServerConnect(lpwsServerName: PWideChar; var phMprServer: MPR_SERVER_HANDLE): LongInt; stdcall; external "mprapi.dll";
function MprAdminServerGetInfo(phMprServer: MPR_SERVER_HANDLE; dwLevel: DWord; var lplpBuffer): DWord; stdcall; external "mprapi.dll";
procedure MprAdminServerDisconnect(var phMprServer: THandle); stdcall; external "mprapi.dll";

var
 MprServer: MPR_SERVER_HANDLE;
 MprErrors: LongInt;
 ServInfo: MPR_SERVER_0;
 ServInfo1: MPR_SERVER_1;
begin
 MprErrors:=MprAdminServerConnect("hanymej",MprServer);
 writeln(MprErrors);
 MprErrors:=MprAdminServerGetInfo(MprServer,0,ServInfo);
 writeln(MprErrors);
 MprErrors:=MprAdminServerGetInfo(MprServer,1,ServInfo1);
 writeln(MprErrors);
 with ServInfo do begin
 writeln("ServInfo:");
 writeln(" LanOnlyMode: ",fLanOnlyMode);
 writeln(" UpTime: ",dwUpTime);
 writeln(" TotalPorts: ",dwTotalPorts);
 writeln(" PortsInUse: ",dwPortsInUse);
 end;
 with ServInfo1 do begin
 writeln("ServInfo:");
 writeln(" dwNumPptpPorts: ",dwNumPptpPorts);
 writeln(" dwPptpPortFlags: ",dwPptpPortFlags);
 writeln(" dwNumL2tpPorts: ",dwNumL2tpPorts);
 writeln(" dwL2tpPortFlags: ",dwL2tpPortFlags);
 end;
 MprAdminServerDisconnect(MprServer);
 { TODO -oUser -cConsole Main : Insert code here }
end.


выводит не верную инфу
 ServInfo:
 dwNumPptpPorts: TRUE
 UpTime: 0
 TotalPorts: 0
 PortsInUse: 0

 ServInfo:
 dwNumPptpPorts: 13631144
 dwPptpPortFlags: 0
 dwNumL2tpPorts: 0
 dwL2tpPortFlags: 0


хотя rras запущен корректно, есть подключения а dwNumPptpPorts: по идее должно возвращать 128


 
ors_archangel ©   (2007-01-15 02:51) [8]

Out!!! Тьфу ты, извини, я невнимательно посмотрел:
Добавь указательные типы:
type
 PMPR_SERVER_0 = ^MPR_SERVER_0;
 PMPR_SERVER_1 = ^MPR_SERVER_1;

Переменные - будут указатели:
var
 ServInfo0: PMPR_SERVER_0;
 ServInfo1: PMPR_SERVER_1;

Код модифицируешь для работы с указателями:

with ServInfo^ do begin
writeln("ServInfo:");
writeln(" LanOnlyMode: ",fLanOnlyMode);
writeln(" UpTime: ",dwUpTime);
writeln(" TotalPorts: ",dwTotalPorts);
writeln(" PortsInUse: ",dwPortsInUse);
end;
with ServInfo1^ do begin
writeln("ServInfo:");
writeln(" dwNumPptpPorts: ",dwNumPptpPorts);
writeln(" dwPptpPortFlags: ",dwPptpPortFlags);
writeln(" dwNumL2tpPorts: ",dwNumL2tpPorts);
writeln(" dwL2tpPortFlags: ",dwL2tpPortFlags);
end;

- вызовы MprAdminServerGetInfo не меняются


 
gibz ©   (2007-01-15 02:55) [9]

спасибо за помощь !



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

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

Наверх




Память: 0.49 MB
Время: 0.014 c
15-1180377430
No_Dead
2007-05-28 22:37
2007.06.24
Если у вас есть время - взгляните..


1-1177569767
StriderMan
2007-04-26 10:42
2007.06.24
List из TNotifyEvent ов


3-1175016877
Цукор5
2007-03-27 21:34
2007.06.24
DBase ( Win or DOS ???)


15-1180347760
micke_2007
2007-05-28 14:22
2007.06.24
Вопрос о Shop-Script-Primium


4-1168940795
Невский
2007-01-16 12:46
2007.06.24
Весы Bizerba