From: SMTP%"rick@rdperf.com" 16-OCT-1997 16:58:27.46 To: NTDEV CC: RICK Subj: Problem with DeviceIoControl on NT Return-Path: owner-ntdev@atria.com Received: by arisia.gce.com (UCX V4.1-12C, OpenVMS V7.1 VAX); Thu, 16 Oct 1997 16:55:50 -0400 Received: from gw.atria.com (gw.atria.com [192.88.237.2]) by bort.mv.net (8.8.5/mem-951016) with SMTP id AAA03957 for ; Thu, 16 Oct 1997 00:30:53 -0400 (EDT) Received: by gw.atria.com id Wed, 15 Oct 1997 19:37:04 -0400 Received: from SPIA by gw.atria.com id Wed, 15 Oct 1997 19:36:50 -0400 From: rick@rdperf.com Date: Wed, 15 Oct 1997 16:30:23 -0700 Message-Id: <97101516302344@rdperf.com> To: ntdev@atria.com Subject: Problem with DeviceIoControl on NT X-VMS-To: NTDEV X-VMS-Cc: RICK Sender: owner-ntdev@atria.com Precedence: bulk I have spent quite a lot of time trying to get the program at the end on this message to work on NT. If someone knows what I have to do differently, I would appreciate the help. I besides doing a CreateFile to devices of type "\\.\C:", I have also tried it with devices like "\\.\PHYSICALDRIVE0". I always get an #1 (ERROR_INVALID_FUNCTION) from GetLastError() after the call to DeviceIoControl. I do the following commands to build/execute it: cl -c test.c link test test c Basically I want to get disk I/O rates so that I can control the amount of work that a process does using a disk in order to not monopolize disk access. Rick Cadruvi R&D Performance Group, Inc. 1180 E Patricia #102 Simi Valley, CA 93065 (805)520-4170 (office) (805)520-4169 (fax) rick@rdperf.com ------------------------------------------------------------ #include #include #include long main (long arg_cnt, char *arg_str[]) { DISK_PERFORMANCE disk_perf; HANDLE volume_handle; unsigned long out_size, status; char open_devname[32]; memset (&disk_perf, 0, sizeof (disk_perf)); out_size = 0; strcpy (open_devname, "\\\\.\\"); strcat (open_devname, arg_str[1]); if (open_devname[strlen (open_devname) - 1] != ':') strcat (open_devname, ":"); printf ("%s\n", open_devname); volume_handle = CreateFile (open_devname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0 ); if (volume_handle == INVALID_HANDLE_VALUE) { printf ("Error in CreateFile = %X\n", GetLastError()); return 0; } status = DeviceIoControl (volume_handle, IOCTL_DISK_PERFORMANCE, NULL, 0, &disk_perf, sizeof (DISK_PERFORMANCE), &out_size, 0); if (status == 0) { printf ("Error in DeviceIOControl = %X (%d)\n", GetLastError(), out_size); return 0; } printf ("\n"); printf ("Bytes Read : %10d\n", disk_perf.BytesRead); printf ("Bytes Written: %10d\n", disk_perf.BytesWritten); printf ("Read Time : %10d\n", disk_perf.ReadTime); printf ("Write Time : %10d\n", disk_perf.WriteTime); printf ("Read Count : %10d\n", disk_perf.ReadCount); printf ("Write Count : %10d\n", disk_perf.WriteCount); printf ("Queue Depth : %10d\n", disk_perf.QueueDepth); return (status); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]