[개발/delphi] 인터넷 연결 목록을 추적하기
// d2007, JVCL 사용, TJvRas32 (PhoneBook VCL)
const
RAS_MaxEntryName = 256;
RASBASE = 600;
ERROR_BUFFER_TOO_SMALL = RASBASE + 3;
ERROR_INVALID_SIZE = RASBASE + 32;
type
PRasEntryName = ^TRasEntryName;
TRasEntryName = record
dwSize: Longint;
szEntryName: array [0..RAS_MaxEntryName] of Char;
end;
function RasEnumEntriesA(reserved: PChar; lpszPhonebook: PChar;
lpRasEntryName: PRasEntryName; var lpcb: DWORD;
var lpcEntries: DWORD): DWORD; stdcall; external 'RASAPI32.DLL';
procedure GetRasEntries(List: TStrings);
var
RasEntryNames: array of TRasEntryName;
Err, Size, Entries: DWORD;
i: Integer;
begin
List.Clear;
SetLength(RasEntryNames, 1);
Size := SizeOf(TRasEntryName);
RasEntryNames[0].dwSize := Size;
Err := RasEnumEntriesA(nil, nil, @RasEntryNames[0], Size, Entries);
if (Err = ERROR_BUFFER_TOO_SMALL) and (Entries > 0) then begin
Assert(Size = SizeOf(TRasEntryName) * Entries);
SetLength(RasEntryNames, Entries);
Err := RasEnumEntriesA(nil, nil, @RasEntryNames[0], Size, Entries);
if Err = 0 then
for i := 0 to Length(RasEntryNames) do
List.Add(RasEntryNames[i].szEntryName);
end else
List.Add(RasEntryNames[0].szEntryName);
end;
반응형
'Delphi, RadStudio' 카테고리의 다른 글
[개발/delphi] How can I pass PostData when I Navigate to a URL (0) | 2012.01.25 |
---|---|
[개발/delphi] 델파이 - Object Pascal 강좌 (0) | 2012.01.18 |
[개발/delphi] 델파이 zlib 를 이용한 파일압축 (0) | 2012.01.17 |
[개발/delphi] 64bit OS 판별 (1) | 2012.01.13 |
[개발/delphi] 64bit 시스템 디렉토리 가져오기 (0) | 2012.01.13 |
댓글