Michael Knight
asked on
How to Convert from Local to UNC path?
I can see how to do this using a MAPI command that may or may not be supported in the future. How is this supposed to be handled. I'm getting a file name and path back from a CFileDialog. I want this to be in a UNC format. I'm using MSVC++ 5.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmm, that's from the VC5 docs:
WNetGetConnection
Windows NT
Yes
Win95
Yes
Win32s
Yes
Import Library
mpr.lib
Header File
winnetwk.h
Unicode
WinNT
Platform Notes
None
It only says that the UNICODE version is available on NT only...
WNetGetConnection
Windows NT
Yes
Win95
Yes
Win32s
Yes
Import Library
mpr.lib
Header File
winnetwk.h
Unicode
WinNT
Platform Notes
None
It only says that the UNICODE version is available on NT only...
ASKER
I'll give it a shot. Here's what on my VC5 online docs:
WNetGetUniversalName
Windows NT
Yes
Win95
No
Win32s
No
Import Library
mpr.lib
Header File
winnetwk.h
Unicode
WinNT
Platform Notes
None
WNetGetUniversalName
Windows NT
Yes
Win95
No
Win32s
No
Import Library
mpr.lib
Header File
winnetwk.h
Unicode
WinNT
Platform Notes
None
That's REALLY strange - I copied the above from the VC5 online docs, too...
BTW: A 3rd opinion ;-)
http://msdn.microsoft.com/library/sdkdoc/network/networks_84a6.htm
"Remarks
Windows NT/Windows 2000: If the network connection was made using the Microsoft LAN Manager network, and the calling application is running in a different logon session than the application that made the connection, a call to the WNetGetConnection function for the associated local device will fail. The function fails with ERROR_NOT_CONNECTED or ERROR_CONNECTION_UNAVAIL. This is because a connection made using Microsoft LAN Manager is visible only to applications running in the same logon session as the application that made the connection. (To prevent the call to WNetGetConnection from failing it is not sufficient for the application to be running in the user account that created the connection.)
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Windows CE: Requires version 2.0 or later.
Header: Declared in winnetwk.h.
Import Library: Use mpr.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000."
BTW: A 3rd opinion ;-)
http://msdn.microsoft.com/library/sdkdoc/network/networks_84a6.htm
"Remarks
Windows NT/Windows 2000: If the network connection was made using the Microsoft LAN Manager network, and the calling application is running in a different logon session than the application that made the connection, a call to the WNetGetConnection function for the associated local device will fail. The function fails with ERROR_NOT_CONNECTED or ERROR_CONNECTION_UNAVAIL. This is because a connection made using Microsoft LAN Manager is visible only to applications running in the same logon session as the application that made the connection. (To prevent the call to WNetGetConnection from failing it is not sufficient for the application to be running in the user account that created the connection.)
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Windows CE: Requires version 2.0 or later.
Header: Declared in winnetwk.h.
Import Library: Use mpr.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000."
ASKER
OK. How in the world do I use this LPVOID thing?
Err - which LPVOID?
Hmm, this API is intended to be used like this:
char acNetName[MAX_PATH];
DWORD dwSize = MAX_PATH;
char* pszLocalName="C:\\";
WNetGetConnection( pszLocalName, acNetName, &dwSize);
char acNetName[MAX_PATH];
DWORD dwSize = MAX_PATH;
char* pszLocalName="C:\\";
WNetGetConnection( pszLocalName, acNetName, &dwSize);
ASKER
Got It! I increased the points too. Thanks for the assistance.
ASKER
BTW: I was looking at WNetGetUniversalName, and not WNetGetConnection. That's why we were not synced up very well with the documentation.
Ooops, this explains a lot ;-)
Thanx!
Thanx!
ASKER