int main(int argc, char *argv[]) { std::vector<std::vector<std::string>> pPaths; char *pPath = NULL; bool pathFile = false; WSADATA wsaData; printAbout(); if (argc < 2) { pPath = strrchr(argv[0], '\\'); pPath = pPath == NULL ? argv[0] : pPath + 1; printUsage(pPath); return 1; } g_nUID = g_nGID = 0; g_bLogOn = true; g_sFileName = NULL; for (int i = 1; i < argc; i++) {//parse parameters if (_stricmp(argv[i], "-id") == 0) { g_nUID = atoi(argv[++i]); g_nGID = atoi(argv[++i]); } else if (_stricmp(argv[i], "-log") == 0) { g_bLogOn = _stricmp(argv[++i], "off") != 0; } else if (_stricmp(argv[i], "-pathFile") == 0) { g_sFileName = argv[++i]; if (g_MountProg.SetPathFile(g_sFileName) == false) { printf("Can't open file %s.\n", g_sFileName); return 1; } else { g_MountProg.Refresh(); pathFile = true; } } else if (i == argc - 2) { pPath = argv[argc - 2]; //path is before the last parameter char *pCurPathAlias = argv[argc - 1]; //path alias is the last parameter if (pPath != NULL || pCurPathAlias != NULL) { std::vector<std::string> pCurPaths; pCurPaths.push_back(std::string(pPath)); pCurPaths.push_back(std::string(pCurPathAlias)); pPaths.push_back(pCurPaths); } break; } else if (i == argc - 1) { char *pPath = argv[argc - 1]; //path is the last parameter if (pPath != NULL) { char curPathAlias[MAXPATHLEN]; strcpy_s(curPathAlias, pPath); char *pCurPathAlias = curPathAlias; std::vector<std::string> pCurPaths; pCurPaths.push_back(std::string(pPath)); pCurPaths.push_back(std::string(pCurPathAlias)); pPaths.push_back(pCurPaths); } break; } } HWND console = GetConsoleWindow(); if (g_bLogOn == false && IsWindow(console)) { ShowWindow(console, SW_HIDE); // hides the window } if (pPaths.size() <= 0 && !pathFile) { printf("No paths to mount\n"); return 1; } WSAStartup(0x0101, &wsaData); start(pPaths); WSACleanup(); return 0; }