An alternative is to execute the cmd "net use L:" (or whatever drive letter is required), send its output to a file and then read and parse the file. This doesn't require the connection to be established as long as it is defined. Sorry, but I can't give you the VB code (as I only use c/c++), but the c++ code is:
This should be fairly easy to translate into VB by someone who knows VB.Code:int main() { system("net use z: > netusez.txt 2> null:"); if (auto f = fopen("netusez.txt", "r"); f != NULL) { char ln[256]; fgets(ln, 255, f); fgets(ln, 255, f); if (strncmp(ln, "Remote name", 11) == 0) if (auto r = strchr(ln, '\\'); r != NULL) cout << r << endl; else cout << "Not a valid remote name\n"; else cout << "Not a valid drive\n"; } else cout << "Problem opening file\n"; }




Reply With Quote
