如何得到局域网中其它计算机的当前登录用户名(winnt4,win2000,win98)?

cynwhm 2003-05-20 06:25:07
my e-mail:cyn@www.jtp.com.cn
...全文
134 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
shark_dim 2003-09-02
  • 打赏
  • 举报
回复
再次up
NowCan 2003-09-02
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <assert.h>
#include <windows.h>
#include <lm.h>

int wmain(int argc, wchar_t *argv[])
{
LPWKSTA_USER_INFO_0 pBuf = NULL;
LPWKSTA_USER_INFO_0 pTmpBuf;
DWORD dwLevel = 0;
DWORD dwPrefMaxLen = -1;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
DWORD dwResumeHandle = 0;
DWORD i;
DWORD dwTotalCount = 0;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;

if (argc > 2)
{
fwprintf(stderr, L"Usage: %s [\\\\ServerName]\n", argv[0]);
exit(1);
}
// The server is not the default local computer.
//
if (argc == 2)
pszServerName = argv[1];
fwprintf(stderr, L"\nUsers currently logged on %s:\n", pszServerName);
//
// Call the NetWkstaUserEnum function, specifying level 0.
//
do // begin do
{
nStatus = NetWkstaUserEnum(pszServerName,
dwLevel,
(LPBYTE*)&pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
&dwResumeHandle);
//
// If the call succeeds,
//
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
//
// Loop through the entries.
//
for (i = 0; (i < dwEntriesRead); i++)
{
assert(pTmpBuf != NULL);

if (pTmpBuf == NULL)
{
//
// Only members of the Administrators local group
// can successfully execute NetWkstaUserEnum
// locally and on a remote server.
//
fprintf(stderr, "An access violation has occurred\n");
break;
}
//
// Print the user logged on to the workstation.
//
wprintf(L"\t-- %s\n", pTmpBuf->wkui0_username);

pTmpBuf++;
dwTotalCount++;
}
}
}
//
// Otherwise, indicate a system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
{
NetApiBufferFree(pBuf);
pBuf = NULL;
}
}
//
// Continue to call NetWkstaUserEnum while
// there are more entries.
//
while (nStatus == ERROR_MORE_DATA); // end do
//
// Check again for allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
//
// Print the final count of workstation users.
//
fprintf(stderr, "\nTotal of %d entries enumerated\n", dwTotalCount);

return 0;
}

看看这个行不行?事先建一个空连接。
shark_dim 2003-08-30
  • 打赏
  • 举报
回复
有人知道吗?知道了,就说!我也给分!给好多份!!!!
200够不够?

顺便up!!
shark_dim 2003-08-28
  • 打赏
  • 举报
回复
我也想知道,帮你up
pepsi1980 2003-08-26
  • 打赏
  • 举报
回复
netbios
影子传说 2003-08-25
  • 打赏
  • 举报
回复
如何获得?
NowCan 2003-05-21
  • 打赏
  • 举报
回复
什么?!
别人机器上的登陆用户?
路人丁 2003-05-21
  • 打赏
  • 举报
回复
//根据ip获取主机名
struct hostent *hostname;
unsigned int addr;
addr=inet_addr((char FAR*)(Edit1->Text.c_str()));
hostname=gethostbyaddr((char *)&addr,4,AF_INET);
Edit2->Text=AnsiString(hostname->h_name);

//根据主机名获取ip地址
struct hostent *hostname;
struct in_addr in;
char *IP,*ptr;
if(!(hostname=gethostbyname((char FAR*)(Edit3->Text.c_str()))))
{
Application->MessageBox("错误","出错信息",MB_OKCANCEL);
return;
}
memset((void *)&in,sizeof(in),0);
in.s_addr=*((unsigned long *)hostname->h_addr_list[0]);
if(!(ptr=inet_ntoa(in)))
return;
IP=new char[strlen(ptr)+1];
strcpy(IP,ptr);
Edit4->Text=AnsiString(IP);
cynwhm 2003-05-21
  • 打赏
  • 举报
回复
我想自己编程实现
cynwhm 2003-05-21
  • 打赏
  • 举报
回复
我根据访问别人机器上的注册表可获得,但太慢。
rookieme 2003-05-20
  • 打赏
  • 举报
回复
用黑客扫描工具

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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