I have some problems writing to a mapped network drive (P:) in Windows 7 from my Delphi program. When I try, for example, ForceDirectories('P:\test\folder'), I get an error (path not found).
I have tried typing in the UNC path in the code (ForceDirectories('\\computername\share\test\folder')) and that works. However, ExpandUNCFileName('P:\') does not seem to work; it returns 'P:\'.
On Windows XP, ExpandUNCFileName('P:\') returns the UNC path.
How do I get the UNC path in Delphi on Windows 7, or otherwise write to a mapped network drive?
Upon further investigation, it is as if I'm missing some kind of initialization in Windows. I have another application (app2) that uses a TcxShellComboBox (a DevExpress component). After having navigated to P: in that combobox, in app2, calls to ExpandUNCFileName work correctly in the first application. Same with FileExists on files under P:, returns False before navigating to P: in app2, returns true after and until computer restart.