论坛: 编程破解 标题: NetBios编程的问题 复制本贴地址    
作者: ejdm [ejdm]    论坛用户   登录
NetBios编程遇到的问题。由于太晚了,实在琢磨不动了,只好贴出来麻烦各位高手帮忙了。

1)想重设LANA,NetBios参数设置如下:
        NCB ncb;
        int i;
        ZeroMemory(&ncb,sizeof(NCB));
        ncb.ncb_command=NCBRESET;
ncb.ncb_callname[0]=ucMaxSession;
ncb.ncb_callname[2]=ucMaxName;
ncb.ncb_callname[3]=(UCHAR)bFirstName;
        for(i=0;i<lenum->length;i++)        //lenum我已经用NCBENUM赋予正确LANA编号的值
{
   ncb.ncb_lana_num=lenum->lana[i];
   if(Netbios(&ncb)!=NRC_GOODRET)
   {
     printf("ERROR:Netbios:NCBRESET FOR LANA[%d]:%d\n",ncb.ncb_lana_num,ncb.ncb_retcode);
   }
}
以上程序运行,显示LANA[8]:35
                  LANA[9]:35
ncb.ncb_retcode返回35是指什么错误啊,只有LANA[0]能够调用正确,这是为什么呢?


2)为指定LANA添加指定进程名的函数,一个普通的stryncpy()函数老是编译出错,具体情况如下:
int AddName(int lana,char *name)
{
NCB ncb;
ZeroMemory(&ncb,sizeof(NCB));
ncb.ncb_command=NCBADDNAME;
ncb.ncb_lana_num=lana;
memset(&ncb.ncb_name,' ',NCBNAMSZ);
strncpy(&ncb.ncb_name, name, strlen(name));

if (Netbios(&ncb)!=NRC_GOODRET)
{
     printf("ERROR:Netbios:NCBADDNAME[LANA=%d,NAME=%s]:%d\n",lana,*name,ncb.ncb_retcode);
     return ncb.ncb_retcode;
}
return NRC_GOODRET;
}
编译的时候提示如下:
D:\linshi\common.cpp(61) : error C2664: 'strncpy' : annot convert parameter 1 from 'unsigned char (*)[16]' to 'char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
这是指strncpy的第一个参数类型不对?我用(char *)将ncb.ncb_name的类型转掉就可以编译通过了,可我想netbios调用时应该不允许改NCB参数里的成员类型的吧。还有什么办法可以解决这个问题呢?




地主 发表时间: 07/04 00:57

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号