It will always fail on any disk with a pagefile on it, or on any disk off
which the apps are now running.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Archims”
To: “Windows File Systems Devs Interest List”
Sent: Sunday, June 27, 2004 7:00 PM
Subject: Re: Re: Re: [ntfsd] how to lock a system volume and purge the FS cache
on it
> Don,
> I’ve tried to open “\.\c:” in non-shared mode, but it was failed 
> Your advise is helpful. Thanks much! 
> The following is my recent codes.
>
> if
(OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hTok
en))
> {
> LookupPrivilegeValue(NULL,SE_MANAGE_VOLUME_NAME,
> &tkp.Privileges[0].Luid);
> tkp.PrivilegeCount = 1; // one privilege to set
> tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
> AdjustTokenPrivileges(hToken, FALSE, &tkp,0,(PTOKEN_PRIVILEGES)NULL,0);
> }
>
> HANDLE lhDisk = CreateFile(L"\\.\c:“,
> GENERIC_WRITE,
> 0,
> 0, OPEN_EXISTING, 0, 0
> );
> if(lhDisk == INVALID_HANDLE_VALUE)
> return ;
>
> the lhDisk got 0xFFFFFFFF
>
>
> best regards,
> Archims
> ======= Original message=======
>
> > No.
> >
> > Purging the cache requires opening a DASD volume file (\.\C:) in
> >non-shared mode for write. This has the same limitations as locking.
> >
> >Maxim Shatskih, Windows DDK MVP
> >StorageCraft Corporation
> >xxxxx@storagecraft.com
> >http://www.storagecraft.com
> >
> >
> >----- Original Message -----
> >From: “Archims”
> >To: “Windows File Systems Devs Interest List”
> >Sent: Sunday, June 27, 2004 4:25 PM
> >Subject: Re: Re: [ntfsd] how to lock a system volume and purge the FS cache
on
> >it
> >
> >
> >> Don,
> >> Is there any way to purge the cache to disk if i can’t lock the volume?
> >>
> >> > Correct.
> >> > Lock fails if there are any open files on the volume.
> >> >
> >> >Maxim Shatskih, Windows DDK MVP
> >> >StorageCraft Corporation
> >> >xxxxx@storagecraft.com
> >> >http://www.storagecraft.com
> >> >
> >> >
> >> >----- Original Message -----
> >> >From: “Archims”
> >> >To: “Windows File Systems Devs Interest List”
> >> >Sent: Sunday, June 27, 2004 11:02 AM
> >> >Subject: [ntfsd] how to lock a system volume and purge the FS cache on it
> >> >
> >> >
> >> >> hi all,
> >> >>
> >> >> I want to lock the system volume and then scan the raw disk(such as the
> >> >Windows Defrag does). I attempt to send
> >> >> FSCTL_LOCK_VOLUME to “\.\C:”. But it always gets failed.
> >> >>
> >> >> Is there any way to lock a system volume and purge it’s cache?
followed
> >with
> >> >my codes.
> >> >>
> >> >> {
> >> >> ULONG luReval;
> >> >> BOOL lbReval;
> >> >>
> >> >> HANDLE lhDisk = CreateFile(L”\\.\C:",
> >> >> GENERIC_READ | GENERIC_WRITE,
> >> >> FILE_SHARE_READ | FILE_SHARE_WRITE,
> >> >> 0, OPEN_EXISTING, 0, 0 );
> >> >>
> >> >> lbReval = DeviceIoControl(lhDisk,
> >> >> FSCTL_LOCK_VOLUME,
> >> >> 0,0,0,0, &luReval,NULL );
> >> >>
> >> >> lbReval = DeviceIoControl(lhDisk,
> >> >> FSCTL_DISMOUNT_VOLUME,
> >> >> 0,0,0,0, &luReval,NULL );
> >> >>
> >> >> lbReval = DeviceIoControl(lhDisk,
> >> >> FSCTL_UNLOCK_VOLUME,
> >> >> 0,0,0,0,&luReval,NULL );
> >> >>
> >> >> CloseHandle(lhDisk);
> >> >> }
> >> >>
> >> >> Thanks,
> >> >> Archims
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> —
> >> >> Questions? First check the IFS FAQ at
> >> >https://www.osronline.com/article.cfm?id=17
> >> >>
> >> >> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> >> >> To unsubscribe send a blank email to xxxxx@lists.osr.com
> >> >
> >> >
> >> >—
> >> >Questions? First check the IFS FAQ at
> >https://www.osronline.com/article.cfm?id=17
> >> >
> >> >You are currently subscribed to ntfsd as: xxxxx@ensurebit.com
> >> >To unsubscribe send a blank email to xxxxx@lists.osr.com
> >> >.
> >>
> >>
> >>
> >>
> >> —
> >> Questions? First check the IFS FAQ at
> >https://www.osronline.com/article.cfm?id=17
> >>
> >> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> >> To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >—
> >Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
> >
> >You are currently subscribed to ntfsd as: xxxxx@ensurebit.com
> >To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> = = = = = = = = = = = = = = = = = = = =
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com