"File not found" error returned from CreateHardLink() in IIS Filter

"File not found" error returned from CreateHardLink() in IIS Filter

Post by Jame » Wed, 19 Jan 2005 01:36:44

I'm getting a "file not found" error (0x2) returned from the Platform
SDK function CreateHardLink(lpFileName, lpExistingFileName, NULL) that
is being called from within an IIS filter. The function is actually
called using two CStrings that are assigned from char[]variables:

CreateHardLink(CString, CString, NULL);

I am logging activity from the filter into a text file. The log entry
with the error shows a valid source file -- when I cut/paste from the
log into the Windows Explorer's address bar, the file is accessed just
fine, so the file definitely exists. The problem may be with certain
"special characters" in the file name, though some of the file names it
is failing on seem "normal". Here are some of the files I'm getting
the "file not found" with (path not shown):


Note that the '? (ANSI 228) in "Gewhs.zip" and the '? (ANSI 198)
in "Auto?sit" are both ANSI characters, not unicode. The other two
file names contain normal characters (the underscores are ANSI 095).

The directory exists where the link is being created.
The existing file and the link being created are both on the same
locally mounted hard-drive.


I wrote a C++ console app that takes two arguments from the command
line: the Link File (including path) and the Existing File (including
path). It executes CreateHardLink() using those strings passed in.
When executed on the same server that the IIS filter is running on
using the same paths/files mentioned above, it creates the hard-link
with no errors! It's basically the same code that is in the IIS
filter, except the CString arguments that are passed to
CreateHardLink() are assigned from the argv[] values passed in from the

CString csHardLinkFileName(argv[1]);
CString csExistingFileName(argv[2]);
CreateHardLink(csHardLinkFileName, csExistingFileName, NULL);

Essentially this is the same code as in the IIS filter, but this works
and the filter does not!


The IIS filter is running on MS Windows 2000 Server SP4

Platform SDK:
July 2002

C++ Compiler:
VC++ 6.0
Build options:
/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D
"_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /D _WIN32_WINNT=0x500
/Fp"Release/ISAPIFilter.pch" /Yu"stdafx.h" /Fo"Release/"
/Fd"Release/" /FD /c

Very strange! Any answers?

Thank you!

1. IIS could not find .php file, however it finds html files in the same dir

2. QueryDosDevice Returns Peculiar "File Not Found" Error


I am developing a Windows Service (Master Service) that dynamically
installs and starts additional Windows Services (Slave Services) during
runtime. Whenever a Slave Service calls QueryDosDevice(), the function
fails and GetLastError() returns ERROR_FILE_NOT_FOUND. Yet, whenever
the Master Service calls QueryDosDevice(), the function always
succeeds. Does anyone have any clue as to anything that could cause
QueryDosDevice() to behave like this?

Since QueryDosDevice is used to resolve virtual filepaths on SUBST'd
drives, the Slave Service gets ERROR_FILE_NOT_FOUND errors when
attempting to open files on SUBST'd drives where as the Master Service
does not.

The actual call to QueryDosDevice() is made in a common library linked
to by both Services, so there is no difference in the way the function
is called.

I have also tried starting both Windows Services under my user account
instead of the SYSTEM account. However, that made no difference.

Thanks in advance for any help!

Henru Wang

3. "setup.ins" not found error on start-up

4. explorer.exe-entry point not found-error message after updates ins

5. IIS and File not Found with ASP files

6. .flv files = file not found in IIS...help!

7. 404 File not Found on .EXE files in IIS 6.0

8. IIS 5.0 filter notification not called under IIS 6.0

9. IIS Webcast Series: In's and Out's of Authentication in IIS (OWA)

10. A REG QUERY that does not return "ERROR" when key not found

11. IIS Webcast Series: In's and Out's of Authentication in IIS

12. CreateHardLink() not working

13. IIS Webcast Series: In's and Out's of Authentication in IIS (OWA)

14. error running exe to write to exel file: Error 7 New file not found

15. Labview DLL does not return error if NI DLLs not found