comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey D. Cherry" <jdcherry@utech.net>
To: NANCY HEHIR <nanceh.ennis@tinet.ie>
Subject: Re: Access and alias
Date: 2000/04/05
Date: 2000-04-05T00:00:00+00:00	[thread overview]
Message-ID: <38EBAC6E.FDB88D36@utech.net> (raw)
In-Reply-To: v7rG4.1684$sB3.964@news.indigo.ie

I haven't tested the following procedure, but it should work.  You'll have to 
supply the necessary code to modify the device control block fields the way 
you want.  The procedure also demonstrates one way of using the Win32 API 
without resorting to 'address attributes.  I prefer this method since it 
explicitly shows that I'm performing an unchecked operation, and messing 
around with addresses.  Let me know if/how it works.

-- file Change_Comm_State.ads
with Win32.Winbase;
with Win32.Winnt;

procedure Change_Comm_State(
   Handle : in     Win32.Winnt.HANDLE;
   Status :    out Win32.DWORD);

-- file Change_Comm_State.adb
with Win32.Winerror;

procedure Change_Comm_State(
   Handle : in     Win32.Winnt.HANDLE;
   Status :    out Win32.DWORD) is

use type Win32.BOOL;

   Device_Control_Block : aliased Win32.Winbase.DCB;
   Result               : Win32.BOOL;

begin -- Change_Comm_State
   Status := Win32.Winerror.NO_ERROR;

   -- Get the current state of the comm device.
   Result := Win32.Winbase.GetCommState(Handle,
         Device_Control_Block'unchecked_access);
   if Result = Win32.FALSE then
      Status := Win32.Winbase.GetLastError;

   else
      -- Modify Device_Control_Block as necessary.
      -- Set the comm device state.
      Result := Win32.Winbase.SetCommState(Handle,
            Device_Control_Block'unchecked_access);
      if Result = Win32.FALSE then
         Status := Win32.Winbase.GetLastError;
      end if;
   end if;
end Change_Comm_State;

-- 
Regards,
Jeffrey D. Cherry
Senior IV&V Analyst
Logicon Space and Information Operations
Logicon Inc.
a Northrop Grumman company




  parent reply	other threads:[~2000-04-05  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-04  0:00 Access and alias NANCY HEHIR
2000-04-04  0:00 ` Laurent Guerby
2000-04-04  0:00   ` NANCY HEHIR
2000-04-04  0:00     ` Laurent Guerby
2000-04-05  0:00       ` Alfred Hilscher
2000-04-05  0:00         ` Ted Dennison
2000-04-05  0:00           ` Jeff Carter
2000-04-06  0:00             ` Robert Dewar
2000-04-07  0:00               ` Jeff Carter
2000-04-06  0:00             ` Alfred Hilscher
2000-04-07  0:00               ` Jeff Carter
2000-04-06  0:00           ` tmoran
2000-04-07  0:00             ` Robert Dewar
2000-04-07  0:00               ` tmoran
2000-04-09  0:00                 ` Robert Dewar
2000-04-09  0:00                   ` tmoran
2000-04-10  0:00                 ` Jack W. Sharer
2000-04-06  0:00           ` Robert Dewar
2000-04-05  0:00         ` Laurent Guerby
2000-04-05  0:00     ` Jeffrey D. Cherry [this message]
2000-04-04  0:00 ` tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox