 |
|
|
 |
|
 |
Thank you for this solution. I haven't done much coding with the Windows API, and a new project required me to resolve network paths (using drive letters) to UNC paths. Most of the solutions I found on the web are in VB and not easily converted to VS2005 C++. The only other solution I found used a ManagementObjectSearcher and a SQL'ish statement to resolve the UNC path. However, it took nearly 5-10 seconds per function call. Yours works much better.
Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Really nice, it's exaclty what I was searching for.
The only thing missing to fully feed my need is the WNetGetNetworkInformation function.
Here is what I want to do :
I have a network connection (ex. Z: pointing on \\server\Dir) that I want to redirect temporary on a local directory (ex. Z: pointing on \\Computer_Name\C$\Windows\Temp) and after some job redirect it again to its previous location (\\server\Dir).
When I unmap a connection without making it persistent, the API won't let me redirect it to another location. Consequently, I have to make the change persistent and if so, I cannot use the RestoreConnection function. 
I want to be able to know where a drive connection where accessing before I change it, I suppose that the WNetGetNetworkInformation is the right API to use, but When I tried to add it to your class I had some problem with the Interfacing thing (kind of thing I'm not used to yet).
Is anybody can give me a quick method to get a path drive connection? Or then, can you help me find my problem with my essaie?
Thanks in advance about everyting. 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
With a little time and willing and the help of Calishar (thanks for giving me the www.pinvoke.net link), I sucess to get the network name of a local drive 
Here is the code for that...
(In the API section)
[DllImport("mpr.dll", CharSet=CharSet.Auto, SetLastError=true)] private static extern int WNetGetConnection( string localName, StringBuilder remoteName, ref int length); private const int NO_ERROR = 0x00000000;
(In the core functions sections)
private String zGetConnection(String szDriveLetter) { int length = 100; StringBuilder remoteName = new StringBuilder(length); int res = WNetGetConnection(szDriveLetter, remoteName, ref length); if(res==ERROR_MORE_DATA) { remoteName = new String Builder(length); res = WNetGetConnection(szDriveLetter, remoteName, ref length); }
if(res==NO_ERROR) return remoteNAme.ToString(); else throw new System.ComponentModel.Win32Exception(res); }
That's it!
You can now create a mapping function call "GetDriveFullPath" or equivalent that calls zGetConnection and you're in business.
Hope this will help!
Ciao!
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
Nice job on the downloadable stuff, the article wasn't long, but the code was what I was looking for.
Thanks!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |