Retrieving Information About a Network Resource的例子编译不过
如下:
#include "wtypes.h"
#include "winnt.h"
#include "windef.h"
#include "Winnetwk.h"
//
// Verify a server on the network.
//
DWORD
CheckServer(
LPTSTR pszServer
)
{
DWORD dwError;
NETRESOURCE nr;
NETRESOURCE nrOut;
LPTSTR pszSystem = NULL; // pointer to variable-length strings
LPVOID lpBuffer = &nrOut; // buffer
DWORD cbResult = sizeof(nrOut); // buffer size //
// Fill a block of memory with zeroes; then
// initialize the NETRESOURCE structure.
//
ZeroMemory(&nr, sizeof(nr)); nr.dwScope = RESOURCE_GLOBALNET;
nr.dwType = RESOURCETYPE_ANY;
nr.lpRemoteName = pszServer; //
// First call the WNetGetResourceInformation function with
// memory allocated to hold only a NETRESOURCE structure. This
// method can succeed if all the NETRESOURCE pointers are NULL.
//
dwError = WNetGetResourceInformation(&nr, lpBuffer, &cbResult, &pszSystem); //
// If the call fails because the buffer is too small,
// call the LocalAlloc function to allocate a larger buffer.
//
if (dwError == ERROR_MORE_DATA)
{
lpBuffer = LocalAlloc(LMEM_FIXED, cbResult); if (lpBuffer == NULL)
{
dwError = ERROR_NOT_ENOUGH_MEMORY;
}
//
// Call WNetGetResourceInformation again
// with the larger buffer.
//
else
{
dwError = WNetGetResourceInformation(&nr, lpBuffer, &cbResult, &pszSystem);
}
}
if (dwError == NO_ERROR)
{
// If the call succeeds, process the contents of the
// returned NETRESOURCE structure and the variable-length
// strings in lpBuffer. Then free the memory.
//
if (lpBuffer != &nrOut)
{
LocalFree(lpBuffer);
}
} return dwError;
}
int main()
{
char str[]="\\\\172.16.80.212";
CheckServer(str)
return 0;
}错误是:
G:\netcon1\main.cpp(35) : error C2065: 'WNetGetResourceInformation' : undeclared identifier另外谁知道,怎么通过程序确定网络路径已经登陆过,一般以”\\192.168.0.10\d\x.bmp“访问文件 如果以前没有输入 用户名 密码 的话,将访问不到文件,如果从网上邻居登陆过一次就可以了,如果没登陆我也可以用WNetAddConnection2登陆,但是我不知道怎样确定是否登陆过????
解决方案 »
- 如何把DLL提供的回调函数封装在类中?
- 怎么用vc++做类似qq按钮的button
- 请教高手们一个关于图象处理的问题,小女子先谢了!
- 在编写一个控制台 例子程序时,主程序要调用一些用户字定义函数。我把这些函数的声明部分写到 myFuction.h 文件中共享调用,那么实现部分
- 请教 完成端口写服务程序
- 一颗红星,两手散分
- 窗口DoModal会执行什么?
- 一个鼠标钩子的问题(不知道是太简单,还是太难,在vchelp上没人回答我)
- P2P必须解决的问题:分布在两个局域网的两台子机可以透过代理做TCP逻辑连接吗?
- 这个用法CEdit *edit1=(CEdit*)GetDlgItem(IDC_EDIT1)请教一下
- 求救:关于数字签名中的API CryptSignHash的使用方法
- 哪个打包软件比较好?我想把程序打包
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winnetwk.h.
Library: Use Mpr.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
这些都加了吗?
和lib 都加了
编译都通不过