--- mstools/samples/sdktools/netwatch/net.c 2018/08/09 18:24:28 1.1 +++ mstools/samples/sdktools/netwatch/net.c 2018/08/09 18:27:28 1.1.1.2 @@ -58,6 +58,37 @@ InitNetWatch(BOOL fInit) if(szCommandLine = GetCommandLine()) { + if(*szCommandLine == '\"') + { + /* + * Scan, and skip over, subsequent characters until + * another double-quote or a null is encountered. + */ + while(*++szCommandLine && (*szCommandLine != '\"')) + ; + + /* + * If we stopped on a double-quote (usual case), skip + * over it. + */ + if(*szCommandLine == '\"') + szCommandLine++; + } + else + { + while(*szCommandLine > ' ') + szCommandLine++; + } + + /* + * Skip past any white space preceeding the second token. + */ + while (*szCommandLine && (*szCommandLine <= ' ')) + { + szCommandLine++; + } + +#ifdef NEVER // skip first arg (our exe name) while(*szCommandLine && (*szCommandLine != ' ')) szCommandLine++; @@ -65,6 +96,7 @@ InitNetWatch(BOOL fInit) // skip spaces while(*szCommandLine && (*szCommandLine == ' ')) szCommandLine++; +#endif if(*szCommandLine) { @@ -213,6 +245,17 @@ FilesEnum(HWND hwndLB, DWORD *pdwIndex, NET_API_STATUS nas; DWORD dwentriesread; DWORD dwtotalentries; + TCHAR *psharepathend; + + // Reasoning: if you are passed c:\ as a sharepath, sometimes c: is opened + // as execute. But since we would be qualifying paths on c:\, it won't show + // c: as being open. So - remove the last \ if it's there. + if(sharepath && sharepath[0]) + { + psharepathend = sharepath + lstrlen(sharepath) - 1; + if(*psharepathend == TEXT('\\')) + *psharepathend = '\0'; + } nas = NetFileEnum(szServerName, sharepath, username, 3, (LPBYTE *)&fi3, MAX_PREFERRED_LENGTH, @@ -542,13 +585,22 @@ DisplayUserDetails(HWND hwnd, LBDATA *pl if(wAction == VK_DELETE) { - wsprintf(szBuffer, szFromIDS1(IDS_AREYOUSURE + LBITEM_USER), - szUserName); + // if user has open files, tell the del happy person this + // otherwise just reaffirm that they wanna hack em. + if(sesi2->sesi2_num_opens) + { + wsprintf(szBuffer, szFromIDS1(IDS_AREYOUSURE + LBITEM_USER), + szUserName); + } + else + { + wsprintf(szBuffer, szFromIDS1(IDS_DISUSER), szUserName); + } + if(MessageBox(hwnd, szBuffer, szAppName, MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2) == IDYES) { - nas = NetSessionDel(szServerName, plbdata->rgsz, - plbdata->rgsz + lstrlen(plbdata->rgsz) + 1); + nas = NetSessionDel(szServerName, szNetName, szUserName); } } else