Is there any way of telling if a drive is in use? I have been playing around with VHDs and it seems that my code will detach one while it is in use (in this one case, by chkdsk).
Like when you try and 'safely remove' a USB drive and Windows tells you it's in use and try again.
Some sort of IOCTL? Searching MSDN is torture.
Hi Sinsi,
No IOCTRL in that one, you use the Pdhxxx performance data query api, as I remember the ones your concerned with are 'PhysicalDisk' (234) and '% Disk Time' (200) though I could be having a memory problem with that. I wrote one once but deleted it as mostly useless, the concept is simple though.
first verify that the names I gave above are right using PdhLookupPerfNameByIndex and the index numbers (in brackets)
Next create a counter path using PdhMakeCounterPath
Open a query and add a counter using PdhOpenQuery/PdhAddCounter
then poll the query using PdhCollectQueryData/PdhGetFormattedCounterValue
You'll probably want to set up a timer to poll the query using SetTimer or some such. I can probably throw something together if I get time before I leave for BC.
Edgar
I have some doubts that the PhysicalDisk performance object would report anything for a virtual drive, but if works like a HDD monitor, it should be fairly easy to code.
http://www.masm32.com/board/index.php?topic=4624.0
???
hth
I remember being impressed when this first came out!
farrier
unfortunately - the info is lost....
Quote[attachment deleted by admin]
a lot of good learning material has disappeared :(
Yes Dave i have me wonder Yesterday
I look often on this attachment :'(
I have ask Hutch
Quotedatabase size and disk storage on the entire site was so big
Ok Hutch would make a Achive like
http://www.masm32au.com/files/index.php
Or Masm32Board.zip
and we can download it :wink
Ok The HDDMon project have i saved on my drive and i upload the complete project from this site
http://www.masm32.com/board/index.php?topic=4624.0
HDDMon_Project
http://www.sendspace.com/file/bpwgil
Greets,
that isn't great, either, because we won't know which files go with which threads
they should have made a note like this
Quote[test21.zip attachment deleted by admin]
or - probably better
Quote[archive10025.zip attachment deleted by admin]
now - it's fucked
unless Hutch wants to go through the old forum back-ups
that really diminishes the value of the forum
i - and i am sure many others - used to use it as a reference
without the attachments - those threads are mostly useless
Quotethat really diminishes the value of the forum
i - and i am sure many others - used to use it as a reference
without the attachments - those threads are mostly useless
I agree with you
I used often as reference :'(
A complete zip archive is better
Dave for the HddMon project look on my old post
http://www.masm32.com/board/index.php?topic=18816.msg159383#msg159383
thanks :U
Thanks ragdog, that looks interesting, but I don't want to go off on a tangent :bg
The problem is that a file can be open on the volume but no activity. I've looked at sysinternals 'handle' but it seems to use a driver, way more than I need.
I think I will just ask the user whether to go ahead with a detach.
Interesting thing, to attach you need admin privileges, for detach no elevation required.
QuoteInteresting thing, to attach you need admin privileges, for detach no elevation required.
that makes sense in a way :P
but - having an admin password doesn't mean you know the drive is safe - lol
just because you can afford to buy a Mercedes, doesn't mean you can drive one