I deployed an CGI DLL built with Delphi 2007 on the Windows 2008 server. Internally I need to use the current DLL path.
Normally I can use GetModuleFileName or GetModuleName, but on the server they both return:
\\?\c:\my\correct\path
Why the first 4 characters? It looks like a network path? Is there any way to exclude those first 4 characters?
The pertinent documentation is this:
As long as you are calling Unicode versions of Windows API functions, then there’s no need to strip the
"\\?\"prefix. Because the path that you have been handed is a valid path.As we discovered in the comments, you were calling an ANSI version of an API function. And when you do that, the
"\\?\"prefix is not valid. So, stick to Unicode API functions and it’s all good!