那要指定本机该用什么参数,我上面用inu就是我自己的计算机名啊还有为什么你知道2351就是那个意思,msdn都没说的

解决方案 »

  1.   

    1、根据MSDN的说明,共享自己的机器时,第一个参数为NULL或"";2、使用FormatMessage函数格式化那个错误值(nStatus),就得到“此计算机名无效”.
      

  2.   

    举个FormatMessage()的例子,太复杂了
      

  3.   

    计算机名需要用unicode字符串。改成:
    nStatus = NetShareAdd(L"inu",         // 用L转换一下
      50,
                      (char *)pBuf,
                          cbBuffer);就可以了。
      

  4.   

    抱歉,上面说得可能不对。可以不用unicode的,但计算机名必须以\\开头,或者是NULL。servername 
    [in] Pointer to a Unicode (Windows NT/2000) or ANSI (Windows 95/98) string specifying the name of the remote server on which the function is to execute. The string must begin with \\. If this parameter is NULL, the local computer is used. 
      

  5.   

    FormatMessage()不是用来把string转换成int型的错误号的吗?
    怎么能反过来用的?