Here is the code which I am using:
Assume pszVolume = C:
TCHAR tcVolumeDosDeviceName[MAX_PATH+1];
TCHAR tcDriverDosDeviceName[MAX_PATH+1];
TCHAR tcRepTargetPath[MAX_PATH+1];
TCHAR tcVolumeName[3];
ZeroMemory( tcVolumeName, sizeof(tcVolumeName) );
_tcsncpy( tcVolumeName, pszVolume, 2 ) ;
ZeroMemory( tcVolumeDosDeviceName, sizeof(tcVolumeDosDeviceName)
);
ZeroMemory( tcDriverDosDeviceName, sizeof(tcDriverDosDeviceName)
);
if (!QueryDosDevice( tcVolumeName, tcVolumeDosDeviceName,
MAX_PATH))
{
return 0;
}
TCHAR tcLinkVolumeDosDeviceName[MAX_PATH+1];
// This is a wrapper over NtSymbolicLink
if ( SL_QuerySymbolicLink(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName, MAX_PATH + 1 )
== ERROR_SUCCESS )
_tcscpy(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName);
//
// Remove ‘\’ from device name
//
TCHAR Buffer[MAX_PATH+1];
_tcscpy(Buffer, tcVolumeDosDeviceName);
PTCHAR pcBackSlash;
do
{
pcBackSlash = _tcschr(Buffer, _T(‘\’));
if( pcBackSlash )
*pcBackSlash = _T(‘x’);
}
while( pcBackSlash );
_stprintf( tcDriverDosDeviceName, _T(“Rep%s”), _tcsninc(Buffer,
8) );
_stprintf( tcRepTargetPath, _T(“\Device\XYZ\%s”),
_tcsninc(tcVolumeDosDeviceName, 8) );
if
(!DefineDosDevice(DDD_RAW_TARGET_PATH,tcDriverDosDeviceName,tcRepTargetP
ath))
{
return 0;
}
else
{
_tcscpy( m_tcSSDLink, tcDriverDosDeviceName );
}
if (m_tcSSDLink[0])
{
_stprintf( tcDriverDosDeviceName, _T(“\\.\%s”),
m_tcSSDLink );
m_hSnapShot = CreateFile( tcDriverDosDeviceName, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL
);
if (m_hSnapShot==INVALID_HANDLE_VALUE)
{
return 0;
}
}
return ERROR_SUCCESS;
}
-Upanshu
-----Original Message-----
From: Peter Viscarola [mailto:xxxxx@osr.com]
Sent: Friday, September 12, 2003 1:02 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: DefineDosDevice & DiskPerf problem
“Upanshu Singhal” wrote in message
news:xxxxx@ntdev…
>
> I have a file system filter driver. I am defining a dos device using
> DefineDosDevice API followed by CreateFile to open the handle to the
> newly created Symbolic link. I get error “File not found” (error # 2)
> in few cases.
To what are you directing the dos device you define? In other words,
can you show us your DefineDosDevice?
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@legato.com
To unsubscribe send a blank email to xxxxx@lists.osr.com