①.RasEnumEntries

来源:互联网 发布:淘宝详情页抄袭 编辑:程序博客网 时间:2024/06/10 02:55

函数原型:

 

DWORD RasEnumEntries(
  __in          LPCTSTR reserved,
  __in          LPCTSTR lpszPhonebook,
  __in_out      LPRASENTRYNAME lprasentryname,
  __in_out      LPDWORD lpcb,
  __out         LPDWORD lpcEntries
);

 

先说下函数的功能:枚举指定Phone book的连接。

 

参数:

 

①。第一个MSDN的说明:

Reserved; must be NULL.

 

②。第二个指定Phone book,以后再追究。

(所以前2个都为NULL~)

 

③。指定一个缓冲。__in_out 

   in 方面:先看下RASENTRYNAME 的定义

 

typedef struct _RASENTRYNAME {
  DWORD  dwSize;
  TCHAR  szEntryName[RAS_MaxEntryName + 1];
#if (WINVER >= 0x500)
  DWORD dwFlags;
  TCHAR  szPhonebookPath[MAX_PATH + 1];
#endif
} RASENTRYNAME;

再看MSDN解释:

an application must set the dwSize member of the first RASENTRYNAME structure in the buffer to sizeof(RASENTRYNAME) in order to identify the version of the structure being passed.

 

   out 方面:

MSDN:

receives an array of RASENTRYNAME structures, one for each phone-book entry.

 

④。同样是  __in_out   

  in方面: contains the size, in bytes, of the buffer specified by lprasentryname.

 

(不会英语都看的懂了~)

out方面:不常用。

 

直接上解释:the function sets this variable to the number of bytes required to successfully complete the call.

 

⑤。

这个会用到。

结合返回值作用~后面说

Pointer to a variable that receives to the number of phone-book entries written to the buffer specified by lprasentryname.

 

返回值:

 

成功返回0

 

不成功只用管

ERROR_BUFFER_TOO_SMALL

意思是缓冲太小了

 

上面说到第五个参数结合返回值作用:

 

可以用来判断0个项的情况。

 

例子:

r代表返回值 第五个参数entries

 

if(r == 0)

{

       if(entries > 0)

       {

             //有连接 拿去用

       }

       else

       {

             //无连接

       }

}