Hi there,
We have met quite strange behavior when starting the same application (AutoCAD Civil 3D) from Administrator mode, it shows a much slower performance when we access network sharing paths like \automation_server\some_folder\a.file.
The main APIs we are using is _taccess(), GetFileAttributes(), CreateFile(), GetFileTime().
The problem was found accidentally when we tested performance when working with net share files, and frequent file access does impact the performance. We certainly have a lot of not-needed API calls, but then we start the application from Administrator mode, and it becomes totally unusable - sometimes it looks like a hang although, after 30 minutes, the app can react again. It looks like the net share file access is not cached at all.
The first question is: are there any differences between non-Admin and Admin mode?
And even strangely, if I write some test applications (C#) to call File.Exists() and File.GetLastWriteTime() many times, and the 'cache' seems indeed working. So it looks like it's our own code issue.
Then we found a piece of code like below:
if (::GetFileAttributes(fileName) != INVALID_FILE_ATTRIBUTES) {
HANDLE hFile = ::CreateFIle(fileName,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
FILETIME ftCreationTime, ftLastAccessTime, ftLastWriteTime;
::GetFileTime(hFile, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime);
}
}
And GetFIleAttributes was called for getting the last write time, which was actually not needed. Then we remove it and it seems the non-Admin and Admin now have the same performance.
So the second question is: is this indeed the reason for causing the non-Admin and Admin difference?