急救!!!!怎么列出当前机器内安装的所有MODEM ??

newfang 2005-09-09 04:05:20
如题!!
...全文
148 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
newfang 2005-09-12
  • 打赏
  • 举报
回复
谢谢sdzeng(大头鸟)
sdzeng 2005-09-11
  • 打赏
  • 举报
回复
猛料里有一个例子,不过有点问题,我改了一下:

unit Unit1;

interface

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

const
RAS_MaxDeviceType = 16;
RAS_MaxDeviceName = 128;

RASBASE = 600;
ERROR_BUFFER_TOO_SMALL = (RASBASE+3);

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

LpRasDevInfo = ^TRasDevInfo;
TRasDevInfo = record
dwSize : Longint;
szDeviceType : Array[0..RAS_MaxDeviceType] of AnsiChar;
szDeviceName : Array[0..RAS_MaxDeviceName] of AnsiChar;
end;

function RasEnumDevices(lpRasDevInfo :LpRasDevInfo;
lpcb: LPDWORD;lpcdevices: LPDWORD): DWORD;
stdcall; external 'RASAPI32.dll' name 'RasEnumDevicesA';


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
buffer: Pointer;
devices: LPRasDevInfo;
devSize, ndevs: Integer;
begin
devSize := 0;
ndevs := 0;
if RasEnumDevices(nil, @devSize, @ndevs) <> ERROR_BUFFER_TOO_SMALL then
ShowMessage('RasEnumDevices failed.');

buffer := AllocMem(devSize);
try
devices := buffer;
devices^.dwSize := SizeOf(TRasDevInfo);
if RasEnumDevices(buffer, @devSize, @ndevs) = 0 then
begin
while ndevs > 0 do
begin

if string(devices^.szDeviceType)='modem' then
Memo1.Lines.Add(Format('%s=%s', [devices^.szDeviceName, devices^.szDeviceType]));

Inc(devices);
Dec(ndevs);
end;
end
else
ShowMessage('RasEnumDevices failed.');
finally
FreeMem(buffer);
end;
end;
end.
newfang 2005-09-10
  • 打赏
  • 举报
回复
老大,有没有其它方法,我觉得查注册表不通用!!
在2K下和在XP或其它系统下可能都不一样的!
duanhai 2005-09-10
  • 打赏
  • 举报
回复
查注冊表

首先看看你的MODEM在注冊表的什麼位置,找出其規律即可知
newfang 2005-09-10
  • 打赏
  • 举报
回复
自己顶!!

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧