 |
 | how to test these classes baya3 | 9:46 28 May '08 |
|
 |
i tried to imprt the solution to v.studio , but couldnt run it or debyg it. any ideas thx
|
|
|
|
 |
 | Thank you sbsrazor | 16:53 23 May '08 |
|
 |
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
|
|
|
|
 |
 | Nice article Vikas Salvi | 22:23 24 May '06 |
|
 |
Nice article,but from where u find the enum DEFINITION?
Vikas Salvi
Programmer Analyst
|
|
|
|
 |
 | nice, but need WNetGetNetworkInformation Princesse | 6:49 18 Jan '05 |
|
 |
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.
|
|
|
|
 |
 | Re: nice, but need WNetGetNetworkInformation Princesse | 7:02 18 Jan '05 |
|
 |
Sorry...
I meant the WNetGetConnection rather than WNetGetNetworkInformation...
|
|
|
|
 |
|
 |
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!
|
|
|
|
 |
 | Nice Job Eric Rinn | 7:06 21 Dec '03 |
|
 |
Nice job on the downloadable stuff, the article wasn't long, but the code was what I was looking for.
Thanks!
|
|
|
|
 |
 | How do you respond to the Author of these code submissions SilverKitty | 5:52 21 Aug '03 |
|
 |
If there is no email listed?
|
|
|
|
 |
 | such a hi rating Normski | 21:19 19 Aug '03 |
|
 |
for such a skimpy article?
|
|
|
|
 |
|
|
 |