From: SMTP%"rick@rdperf.com" 16-OCT-1997 21:32:24.44 To: SMTP%"franck.le_mouel@ocegr.fr" CC: NTDEV,RICK Subj: Re: 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 21:28:14 -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 TAA13829 for ; Thu, 16 Oct 1997 19:32:16 -0400 (EDT) Received: by gw.atria.com id Thu, 16 Oct 1997 13:21:03 -0400 Received: from SPIA by gw.atria.com id Thu, 16 Oct 1997 13:20:56 -0400 From: rick@rdperf.com Date: Thu, 16 Oct 1997 10:17:23 -0700 Message-Id: <97101610172370@rdperf.com> To: franck.le_mouel@ocegr.fr, ntdev@atria.com Subject: Re: Problem with DeviceIoControl on NT X-VMS-To: SMTP%"franck.le_mouel@ocegr.fr" X-VMS-Cc: NTDEV,RICK Sender: owner-ntdev@atria.com Precedence: bulk As a follow up on my DeviceIoControl Problem, Franck provided me with the correct solution. It indeed does turn out that the DeviceIoControl function IOCTL_DISK_PERFORMANCE requires turning on Disk Counters using DISKPERF. I thought I should provide this message so that anyone else out there would know that this does indeed solve the problem. Thanks Franck. 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 > >The perf monitor needs a call to diskperf to enable the >disk counters, maybe it is the same with the DeviceIoControl ??? > >>>>>>>>>>>>>>>>>>>>>>>>perfmon help<<<<<<<<<<<<<<<<<<<<<<<<<<< >Activating the Physical and Logical Disk Counters >To activate the physical and logical disk counters > >1 Log on as a member of the Administrators group. > >2 At the command prompt, type diskperf to view Help > on how to turn on and turn off diskperf, and how to > specify a remote computer. > >It will also state whether or not the disk performance counters >have been activated already on that computer. > >3 Restart the computer to activate the disk-performance counters. > >Notes > >You do not need special privileges to open Performance Monitor, >but must be logged on as a member of the Administrators group to use the >diskperf command. > >Disk counters can increase disk access time by approximately 1.5% on 386 >processors. >>>>>>>>>>>>>>>>>>>>>>>>perfmon help<<<<<<<<<<<<<<<<<<<<<<<<<<< > > >HTH, > >Franck. >-- > >rick@rdperf.com wrote: >> >> 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. >> >> ------------------------------------------------------------ >> >> #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). ]