Solved

Opening Files with UNC Names

Posted on 1997-10-15
1
713 Views
Last Modified: 2008-03-06
Is there a function in Microsoft Visual C/C++ 4.2 that will open a file if I send it:

\\SERVER\VOLUME\DIRECTORY\FILENAME

I am in the process of trying CreateFile, but it doesn't look like that supports UNC...

Any help would be greatly appreciated.

0
Comment
Question by:tward
1 Comment
 
LVL 5

Accepted Solution

by:
y96andha earned 100 total points
ID: 1255907
All functions I know in MSVC++ 4.0 support UNC paths. CreateFile does, open does, fopen does. There is even a note in the CreateFile documentation that you can enter UNC paths with lengths of up to 32k:

Windows NT: You can transcend this limit and send in paths longer than MAX_PATH characters by calling the wide (W) version of CreateFile and prepending "\\?\" to the path. The "\\?\" tells the function to turn off path parsing. This lets you use paths that are nearly 32k Unicode characters long. You must use fully-qualified paths with this technique. This also works with UNC names. The "\\?\" is ignored as part of the path. For example, "\\?\C:\myworld\private" is seen as "C:\myworld\private", and "\\?\UNC\tom_1\hotstuff\coolapps" is seen as "\\tom_1\hotstuff\coolapps".


But, with paths of normal lengths, you can just send them in.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now