没有API,要修改注册表,具体是什么我也不大清楚,要找一个。

解决方案 »

  1.   

    Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long 
    说明 
    创建同一个网络资源的永久性连接 
    返回值 
    Long,零表示成功。会设置GetLastError。如GetLastError是ERROR_EXTENDED_ERROR,则可用WNetGetLastError取得额外的错误信息 
    参数表 
    参数 类型及说明 
    lpszNetPath String,要连接的网络名 
    lpszPassword String,可选的一个密码。如为vbNullString,表示采用当前用户的默认密码。如为一个空字串,则不用任何密码 
    lpszLocalName String,资源的本地名称。(例如,F: 和 LPT1:) 
      

  2.   

    摘自MSDN
    NetShareAdd     Shares a resource on a server. 
    NetShareCheck   Queries whether a server is sharing a device. 
    NetShareDel     Deletes a share name from a server's list of       shared resources. 
    NetShareEnum   Retrieves share information about each shared resource on a server. 
    NetShareGetInfo    Retrieves information about a specified shared resource on a server. 
    NetShareSetInfo   Sets a shared resource's parameters. 
      

  3.   

    各位高手,NetShareAdd 在Win98能成功吗 ,
      

  4.   

    我的程序编译后总报
    LNK2001: unresolved external symbol _NetShareAdd@16,不知何错代码:
    SHARE_INFO_2 si2;
    DWORD parm= 0; si2.shi2_current_uses=10;
    si2.shi2_max_uses=7;
    si2.shi2_netname="rod";
    si2.shi2_passwd="";
    si2.shi2_path="e:\\guer\\1";
    si2.shi2_permissions=ACCESS_ALL;
    si2.shi2_re="";
    si2.shi2_type=STYPE_DISKTREE; NetShareAdd(NULL,2,(LPBYTE)&si2,&parm);
      

  5.   

    Header: Declared in Lmshare.h (Windows NT/2000) or Svrapi.h (Windows 95/98); include Lm.h (Windows NT/2000).
    Library: Use Netapi32.lib (Windows NT/2000) or Svrapi.lib (Windows 95/98).Windows 95/98: You must specify the size of the information buffer, in bytes, using the cbBuffer parameter. The Windows NT/Windows 2000 parm_err parameter is not available on this platform. Therefore, the parameter list is as follows. extern API_FUNCTION
     NetShareAdd(
      const char FAR * pszServer,       
      short sLevel,                     
      const char FAR * pbBuffer,        
      unsigned short  cbBuffer          
    );NetShareAdd Sample (Windows 95/98)
    Windows 95/98: The following code sample demonstrates how to share a resource on the local computer with a call to the NetShareAdd function.The code sample specifies the share_info_50 structure and no password on the share. The sample also allocates and frees the memory required for the information buffer.#include <stdio.h>
    #include <windows.h> 
    #include <svrapi.h>int main(int argc, char FAR * argv[])
    {
       char FAR * pszServerName = NULL;
       short nLevel = 50;
       struct share_info_50* pBuf = NULL;
       unsigned short cbBuffer;
       NET_API_STATUS nStatus;
       //
       // ServerName can be NULL to indicate the local computer.
       //
       if ((argc < 3) || (argc > 4))
       {
          printf("Usage: %s [\\\\ServerName] ShareName SharePath\n", argv[0]);
          exit(1);
       }   if (argc == 4)
          pszServerName = argv[1];
       //
       // Allocate the memory required to specify a 
       //   share_info_50 structure.
       //
       cbBuffer = sizeof(struct share_info_50);
       pBuf = malloc(cbBuffer);   if (pBuf == NULL)
          printf("No memory\n");
       //
       // Assign values to the share_info_50 structure.
       //
       strcpy(pBuf->shi50_netname, argv[argc-2]);
       pBuf->shi50_type = STYPE_DISKTREE;
       pBuf->shi50_flags = SHI50F_FULL;
       pBuf->shi50_re = NULL;
       pBuf->shi50_path = argv[argc-1];
       pBuf->shi50_rw_password[0] = '\0'; // No password
       pBuf->shi50_ro_password[0] = '\0'; // No password
       //
       // Call the NetShareAdd function
       //  specifying information level 50.
       //
       nStatus = NetShareAdd(pszServerName,
                             nLevel,
                             (char FAR *)pBuf,
                             cbBuffer);
       //
       // Display the result of the function call.
       //
       if (nStatus == NERR_Success)
          printf("Share added successfully\n");
       else
          fprintf(stderr, "A system error has occurred: %d\n", nStatus);
       //
       // Free the allocated memory.
       //
       if (pBuf != NULL)
          free(pBuf);   return 0;
    }